您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ virCommandFree函数代码示例

51自学网 2021-06-03 09:41:27
  C++
这篇教程C++ virCommandFree函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中virCommandFree函数的典型用法代码示例。如果您正苦于以下问题:C++ virCommandFree函数的具体用法?C++ virCommandFree怎么用?C++ virCommandFree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了virCommandFree函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: openvzGetVEID

int openvzGetVEID(const char *name){    virCommandPtr cmd;    char *outbuf;    char *temp;    int veid;    bool ok;    cmd = virCommandNewArgList(VZLIST, name, "-ovpsid", "-H", NULL);    virCommandSetOutputBuffer(cmd, &outbuf);    if (virCommandRun(cmd, NULL) < 0) {        virCommandFree(cmd);        VIR_FREE(outbuf);        return -1;    }    virCommandFree(cmd);    ok = virStrToLong_i(outbuf, &temp, 10, &veid) == 0 && *temp == '/n';    VIR_FREE(outbuf);    if (ok && veid >= 0)        return veid;    virReportError(VIR_ERR_INTERNAL_ERROR, "%s",                   _("Failed to parse vzlist output"));    return -1;}
开发者ID:noxdafox,项目名称:libvirt,代码行数:27,


示例2: virNetDevBandwidthClear

/** * virNetDevBandwidthClear: * @ifname: on which interface * * This function tries to disable QoS on specified interface * by deleting root and ingress qdisc. However, this may fail * if we try to remove the default one. * * Return 0 on success, -1 otherwise. */intvirNetDevBandwidthClear(const char *ifname){    int ret = 0;    int dummy; /* for ignoring the exit status */    virCommandPtr cmd = NULL;    cmd = virCommandNew(TC);    virCommandAddArgList(cmd, "qdisc", "del", "dev", ifname, "root", NULL);    if (virCommandRun(cmd, &dummy) < 0)        ret = -1;    virCommandFree(cmd);    cmd = virCommandNew(TC);    virCommandAddArgList(cmd, "qdisc",  "del", "dev", ifname, "ingress", NULL);    if (virCommandRun(cmd, &dummy) < 0)        ret = -1;    virCommandFree(cmd);    return ret;}
开发者ID:avdv,项目名称:libvirt,代码行数:35,


示例3: mymain

static intmymain(void){    int id = 0;    int ro = 0;    virConnectPtr conn;    virDomainPtr dom;    int status;    virCommandPtr cmd;    struct utsname ut;    /* Skip test if xend is not running.  Calling xend on a non-xen       kernel causes some versions of xend to issue a crash report, so       we first probe uname results.  */    uname(&ut);    if (strstr(ut.release, "xen") == NULL)        return EXIT_AM_SKIP;    cmd = virCommandNewArgList("/usr/sbin/xend", "status", NULL);    if (virCommandRun(cmd, &status) != 0 || status != 0) {        virCommandFree(cmd);        return EXIT_AM_SKIP;    }    virCommandFree(cmd);    virSetErrorFunc(NULL, errorHandler);    conn = virConnectOpen(NULL);    if (conn == NULL) {        ro = 1;        conn = virConnectOpenReadOnly(NULL);    }    if (conn == NULL) {        fprintf(stderr, "First virConnectOpen() failed/n");        return EXIT_FAILURE;    }    dom = virDomainLookupByID(conn, id);    if (dom == NULL) {        fprintf(stderr, "First lookup for domain %d failed/n", id);        return EXIT_FAILURE;    }    virDomainFree(dom);    virConnectClose(conn);    if (ro == 1)        conn = virConnectOpenReadOnly(NULL);    else        conn = virConnectOpen(NULL);    if (conn == NULL) {        fprintf(stderr, "Second virConnectOpen() failed/n");        return EXIT_FAILURE;    }    dom = virDomainLookupByID(conn, id);    if (dom == NULL) {        fprintf(stderr, "Second lookup for domain %d failed/n", id);        return EXIT_FAILURE;    }    virDomainFree(dom);    virConnectClose(conn);    return EXIT_SUCCESS;}
开发者ID:ansisatteka,项目名称:libvirt-ovs,代码行数:60,


示例4: bhyveConnectDomainXMLToNative

static char *bhyveConnectDomainXMLToNative(virConnectPtr conn,                              const char *format,                              const char *xmlData,                              unsigned int flags){    virBuffer buf = VIR_BUFFER_INITIALIZER;    bhyveConnPtr privconn = conn->privateData;    virDomainDefPtr def = NULL;    virCommandPtr cmd = NULL, loadcmd = NULL;    virCapsPtr caps = NULL;    char *ret = NULL;    virCheckFlags(0, NULL);    if (virConnectDomainXMLToNativeEnsureACL(conn) < 0)        goto cleanup;    if (STRNEQ(format, BHYVE_CONFIG_FORMAT_ARGV)) {        virReportError(VIR_ERR_INVALID_ARG,                       _("Unsupported config type %s"), format);        goto cleanup;    }    if (!(caps = bhyveDriverGetCapabilities(privconn)))        goto cleanup;    if (!(def = virDomainDefParseString(xmlData, caps, privconn->xmlopt,                                  1 << VIR_DOMAIN_VIRT_BHYVE,                                  VIR_DOMAIN_XML_INACTIVE)))        goto cleanup;    if (bhyveDomainAssignAddresses(def, NULL) < 0)        goto cleanup;    if (!(loadcmd = virBhyveProcessBuildLoadCmd(privconn, def)))        goto cleanup;    if (!(cmd = virBhyveProcessBuildBhyveCmd(privconn, def, true)))        goto cleanup;    virBufferAdd(&buf, virCommandToString(loadcmd), -1);    virBufferAddChar(&buf, '/n');    virBufferAdd(&buf, virCommandToString(cmd), -1);    if (virBufferError(&buf)) {        virReportOOMError();        goto cleanup;    }    ret = virBufferContentAndReset(&buf); cleanup:    virCommandFree(loadcmd);    virCommandFree(cmd);    virDomainDefFree(def);    virObjectUnref(caps);    return ret;}
开发者ID:hitchiker42,项目名称:libvirt,代码行数:59,


示例5: testCompareXMLToArgvFiles

static int testCompareXMLToArgvFiles(const char *xml,                                     const char *cmdline,                                     const char *ldcmdline,                                     const char *dmcmdline){    char *actualargv = NULL, *actualld = NULL, *actualdm = NULL;    virDomainDefPtr vmdef = NULL;    virCommandPtr cmd = NULL, ldcmd = NULL;    virConnectPtr conn;    int ret = -1;    if (!(conn = virGetConnect()))        goto out;    if (!(vmdef = virDomainDefParseFile(xml, driver.caps, driver.xmlopt,                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))        goto out;    conn->privateData = &driver;    if (!(cmd = virBhyveProcessBuildBhyveCmd(conn, vmdef, false)))        goto out;    if (!(actualargv = virCommandToString(cmd)))        goto out;    if (!(ldcmd = virBhyveProcessBuildLoadCmd(conn, vmdef, "<device.map>",                                              &actualdm)))        goto out;    if (actualdm != NULL)        virTrimSpaces(actualdm, NULL);    if (!(actualld = virCommandToString(ldcmd)))        goto out;    if (virtTestCompareToFile(actualargv, cmdline) < 0)        goto out;    if (virtTestCompareToFile(actualld, ldcmdline) < 0)        goto out;    if (virFileExists(dmcmdline) || actualdm) {        if (virtTestCompareToFile(actualdm, dmcmdline) < 0)            goto out;    }    ret = 0; out:    VIR_FREE(actualargv);    VIR_FREE(actualld);    VIR_FREE(actualdm);    virCommandFree(cmd);    virCommandFree(ldcmd);    virDomainDefFree(vmdef);    return ret;}
开发者ID:carriercomm,项目名称:libvirt,代码行数:58,


示例6: virNetDevBandwidthUnplug

/* * virNetDevBandwidthUnplug: * @brname: from which bridge are we unplugging * @id: unique identifier (MUST be greater than 2) * * Remove QoS settings from bridge. * * Returns 0 on success, -1 otherwise. */intvirNetDevBandwidthUnplug(const char *brname,                         unsigned int id){    int ret = -1;    int cmd_ret = 0;    virCommandPtr cmd = NULL;    char *class_id = NULL;    char *qdisc_id = NULL;    char *filter_id = NULL;    if (id <= 2) {        virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid class ID %d"), id);        return -1;    }    if (virAsprintf(&class_id, "1:%x", id) < 0 ||        virAsprintf(&qdisc_id, "%x:", id) < 0 ||        virAsprintf(&filter_id, "%u", id) < 0) {        virReportOOMError();        goto cleanup;    }    cmd = virCommandNew(TC);    virCommandAddArgList(cmd, "qdisc", "del", "dev", brname,                         "handle", qdisc_id, NULL);    /* Don't threat tc errors as fatal, but     * try to remove as much as possible */    if (virCommandRun(cmd, &cmd_ret) < 0)        goto cleanup;    virCommandFree(cmd);    cmd = virCommandNew(TC);    virCommandAddArgList(cmd, "filter", "del", "dev", brname,                         "prio", filter_id, NULL);    if (virCommandRun(cmd, &cmd_ret) < 0)        goto cleanup;    cmd = virCommandNew(TC);    virCommandAddArgList(cmd, "class", "del", "dev", brname,                         "classid", class_id, NULL);    if (virCommandRun(cmd, &cmd_ret) < 0)        goto cleanup;    ret = 0;cleanup:    VIR_FREE(filter_id);    VIR_FREE(qdisc_id);    VIR_FREE(class_id);    virCommandFree(cmd);    return ret;}
开发者ID:avdv,项目名称:libvirt,代码行数:65,


示例7: virISCSINodeNew

/* * virISCSINodeNew: * @portal: address for iSCSI target * @target: IQN and specific LUN target * * Usage of nonpersistent discovery in virISCSIScanTargets is useful primarily * only when the target IQN is not known; however, since we have the target IQN * usage of the "--op new" can be done. This avoids problems if "--op delete" * had been used wiping out the static nodes determined by the scanning of * all targets. * * NB: If an iSCSI node record is already created for this portal and * target, subsequent "--op new" commands do not return an error. * * Returns 0 on success, -1 w/ error message on error */intvirISCSINodeNew(const char *portal,                const char *target){    virCommandPtr cmd = NULL;    int status;    int ret = -1;    cmd = virCommandNewArgList(ISCSIADM,                               "--mode", "node",                               "--portal", portal,                               "--targetname", target,                               "--op", "new",                               NULL);    if (virCommandRun(cmd, &status) < 0) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       _("Failed new node mode for target '%s'"),                       target);        goto cleanup;    }    if (status != 0) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       _("%s failed new mode for target '%s' with status '%d'"),                       ISCSIADM, target, status);        goto cleanup;    }    ret = 0; cleanup:    virCommandFree(cmd);    return ret;}
开发者ID:RWTH-OS,项目名称:libvirt,代码行数:50,


示例8: virStorageBackendDiskReadPartitions

/* To get a list of partitions we run an external helper * tool which then uses parted APIs. This is because * parted's API is not compatible with libvirt's license * but we really really want to use parted because the * other options all suck :-) * * All the other storage backends run an external tool for * listing volumes so this really isn't too much of a pain, * and we can even ensure the output is friendly. */static intvirStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool,                                    virStorageVolDefPtr vol){    /*     *  # libvirt_parthelper DEVICE     * /dev/sda1      normal       data        32256    106928128    106896384     * /dev/sda2      normal       data    106928640 100027629568  99920701440     * -              normal   metadata 100027630080 100030242304      2612736     *     */    virCommandPtr cmd = virCommandNewArgList(PARTHELPER,                                             pool->def->source.devices[0].path,                                             NULL);    int ret;    pool->def->allocation = pool->def->capacity = pool->def->available = 0;    ret = virStorageBackendRunProgNul(pool,                                      cmd,                                      6,                                      virStorageBackendDiskMakeVol,                                      vol);    virCommandFree(cmd);    return ret;}
开发者ID:emaste,项目名称:libvirt,代码行数:36,


示例9: virStorageBackendZFSDeleteVol

static intvirStorageBackendZFSDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,                              virStoragePoolObjPtr pool,                              virStorageVolDefPtr vol,                              unsigned int flags){    int ret = -1;    virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);    virCommandPtr destroy_cmd = NULL;    virCheckFlags(0, -1);    destroy_cmd = virCommandNewArgList(ZFS, "destroy", NULL);    virCommandAddArgFormat(destroy_cmd, "%s/%s",                           def->source.name, vol->name);    if (virCommandRun(destroy_cmd, NULL) < 0)        goto cleanup;    ret = 0; cleanup:    virCommandFree(destroy_cmd);    return ret;}
开发者ID:RWTH-OS,项目名称:libvirt,代码行数:25,


示例10: virBhyveProbeCaps

intvirBhyveProbeCaps(unsigned int *caps){    char *binary, *help;    virCommandPtr cmd = NULL;    int ret = 0, exit;    binary = virFindFileInPath("bhyve");    if (binary == NULL)        goto out;    if (!virFileIsExecutable(binary))        goto out;    cmd = virCommandNew(binary);    virCommandAddArg(cmd, "-h");    virCommandSetErrorBuffer(cmd, &help);    if (virCommandRun(cmd, &exit) < 0) {        ret = -1;        goto out;    }    if (strstr(help, "-u:") != NULL)        *caps |= BHYVE_CAP_RTC_UTC; out:    VIR_FREE(help);    virCommandFree(cmd);    VIR_FREE(binary);    return ret;}
开发者ID:JGulic,项目名称:libvirt,代码行数:30,


示例11: libxlDomainGetEmulatorType

intlibxlDomainGetEmulatorType(const virDomainDef *def){    int ret = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN;    virCommandPtr cmd = NULL;    char *output = NULL;    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {        if (def->emulator) {            if (!virFileExists(def->emulator))                goto cleanup;            cmd = virCommandNew(def->emulator);            virCommandAddArgList(cmd, "-help", NULL);            virCommandSetOutputBuffer(cmd, &output);            if (virCommandRun(cmd, NULL) < 0)                goto cleanup;            if (strstr(output, LIBXL_QEMU_DM_STR))                ret = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;        }    } cleanup:    VIR_FREE(output);    virCommandFree(cmd);    return ret;}
开发者ID:open-power-host-os,项目名称:libvirt,代码行数:30,


示例12: virNetDevBandwidthUpdateRate

/** * virNetDevBandwidthUpdateRate: * @ifname: interface name * @classid: ID of class to update * @new_rate: new rate * * This function updates the 'rate' attribute of HTB class. * It can be used whenever a new interface is plugged to a * bridge to adjust average throughput of non guaranteed * NICs. * * Returns 0 on success, -1 otherwise. */intvirNetDevBandwidthUpdateRate(const char *ifname,                             const char *class_id,                             virNetDevBandwidthPtr bandwidth,                             unsigned long long new_rate){    int ret = -1;    virCommandPtr cmd = NULL;    char *rate = NULL;    char *ceil = NULL;    if (virAsprintf(&rate, "%llukbps", new_rate) < 0 ||        virAsprintf(&ceil, "%llukbps", bandwidth->in->peak ?                    bandwidth->in->peak :                    bandwidth->in->average) < 0) {        virReportOOMError();        goto cleanup;    }    cmd = virCommandNew(TC);    virCommandAddArgList(cmd, "class", "change", "dev", ifname,                         "classid", class_id, "htb", "rate", rate,                         "ceil", ceil, NULL);    if (virCommandRun(cmd, NULL) < 0)        goto cleanup;    ret = 0;cleanup:    virCommandFree(cmd);    VIR_FREE(rate);    VIR_FREE(ceil);    return ret;}
开发者ID:avdv,项目名称:libvirt,代码行数:48,


示例13: virStorageBackendSheepdogCreateVol

static intvirStorageBackendSheepdogCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,                                   virStoragePoolObjPtr pool,                                   virStorageVolDefPtr vol){    int ret = -1;    if (vol->target.encryption != NULL) {        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",                       _("Sheepdog does not support encrypted volumes"));        return -1;    }    virCommandPtr cmd = virCommandNewArgList(COLLIE, "vdi", "create", vol->name, NULL);    virCommandAddArgFormat(cmd, "%llu", vol->capacity);    virStorageBackendSheepdogAddHostArg(cmd, pool);    if (virCommandRun(cmd, NULL) < 0)        goto cleanup;    if (virStorageBackendSheepdogRefreshVol(conn, pool, vol) < 0)        goto cleanup;    ret = 0;cleanup:    virCommandFree(cmd);    return ret;}
开发者ID:avdv,项目名称:libvirt,代码行数:28,


示例14: iptablesForwardDontMasquerade

/* Don't masquerade traffic coming from the network associated with the bridge * if said traffic targets @destaddr. */static intiptablesForwardDontMasquerade(virSocketAddr *netaddr,                              unsigned int prefix,                              const char *physdev,                              const char *destaddr,                              int action){    int ret = -1;    char *networkstr = NULL;    virCommandPtr cmd = NULL;    if (!(networkstr = iptablesFormatNetwork(netaddr, prefix)))        return -1;    if (!VIR_SOCKET_ADDR_IS_FAMILY(netaddr, AF_INET)) {        /* Higher level code *should* guaranteee it's impossible to get here. */        virReportError(VIR_ERR_INTERNAL_ERROR,                       _("Attempted to NAT '%s'. NAT is only supported for IPv4."),                       networkstr);        goto cleanup;    }    cmd = iptablesCommandNew("nat", "POSTROUTING", AF_INET, action);    if (physdev && physdev[0])        virCommandAddArgList(cmd, "--out-interface", physdev, NULL);    virCommandAddArgList(cmd, "--source", networkstr,                         "--destination", destaddr, "--jump", "RETURN", NULL);    ret = virCommandRun(cmd, NULL); cleanup:    virCommandFree(cmd);    VIR_FREE(networkstr);    return ret;}
开发者ID:i-ninth,项目名称:libvirt,代码行数:38,


示例15: virBhyveProbeGrubCaps

intvirBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps){    char *binary, *help;    virCommandPtr cmd;    int ret, exit;    ret = 0;    *caps = 0;    cmd = NULL;    help = NULL;    binary = virFindFileInPath("grub-bhyve");    if (binary == NULL)        goto out;    if (!virFileIsExecutable(binary))        goto out;    cmd = virCommandNew(binary);    virCommandAddArg(cmd, "--help");    virCommandSetOutputBuffer(cmd, &help);    if (virCommandRun(cmd, &exit) < 0) {        ret = -1;        goto out;    }    if (strstr(help, "--cons-dev") != NULL)        *caps |= BHYVE_GRUB_CAP_CONSDEV; out:    VIR_FREE(help);    virCommandFree(cmd);    VIR_FREE(binary);    return ret;}
开发者ID:JGulic,项目名称:libvirt,代码行数:35,


示例16: parallelsDoCmdRun

static intparallelsDoCmdRun(char **outbuf, const char *binary, va_list list){    virCommandPtr cmd = virCommandNewVAList(binary, list);    char *scmd = NULL;    int ret = -1;    if (outbuf)        virCommandSetOutputBuffer(cmd, outbuf);    scmd = virCommandToString(cmd);    if (!scmd)        goto cleanup;    if (virCommandRun(cmd, NULL))        goto cleanup;    ret = 0;  cleanup:    VIR_FREE(scmd);    virCommandFree(cmd);    if (ret)        VIR_FREE(*outbuf);    return ret;}
开发者ID:mohankku,项目名称:libvirt,代码行数:26,


示例17: virISCSINodeUpdate

intvirISCSINodeUpdate(const char *portal,                   const char *target,                   const char *name,                   const char *value){    virCommandPtr cmd = NULL;    int status;    int ret = -1;    cmd = virCommandNewArgList(ISCSIADM,                               "--mode", "node",                               "--portal", portal,                               "--target", target,                               "--op", "update",                               "--name", name,                               "--value", value,                               NULL);    /* Ignore non-zero status.  */    if (virCommandRun(cmd, &status) < 0) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       _("Failed to update '%s' of node mode for target '%s'"),                       name, target);        goto cleanup;    }    ret = 0; cleanup:    virCommandFree(cmd);    return ret;}
开发者ID:RWTH-OS,项目名称:libvirt,代码行数:32,


示例18: virStorageBackendSheepdogRefreshVol

static intvirStorageBackendSheepdogRefreshVol(virConnectPtr conn ATTRIBUTE_UNUSED,                                    virStoragePoolObjPtr pool,                                    virStorageVolDefPtr vol){    int ret;    char *output = NULL;    virCommandPtr cmd = virCommandNewArgList(COLLIE, "vdi", "list", vol->name, "-r", NULL);    virStorageBackendSheepdogAddHostArg(cmd, pool);    virCommandSetOutputBuffer(cmd, &output);    ret = virCommandRun(cmd, NULL);    if (ret < 0)        goto cleanup;    if ((ret = virStorageBackendSheepdogParseVdiList(vol, output)) < 0)        goto cleanup;    vol->type = VIR_STORAGE_VOL_NETWORK;    VIR_FREE(vol->key);    if (virAsprintf(&vol->key, "%s/%s",                    pool->def->source.name, vol->name) == -1)        goto cleanup;    VIR_FREE(vol->target.path);    ignore_value(VIR_STRDUP(vol->target.path, vol->name)); cleanup:    virCommandFree(cmd);    return ret;}
开发者ID:6WIND,项目名称:libvirt,代码行数:32,


示例19: virStorageBackendSCSISerial

static char *virStorageBackendSCSISerial(const char *dev){    char *serial = NULL;#ifdef WITH_UDEV    virCommandPtr cmd = virCommandNewArgList(        "/lib/udev/scsi_id",        "--replace-whitespace",        "--whitelisted",        "--device", dev,        NULL        );    /* Run the program and capture its output */    virCommandSetOutputBuffer(cmd, &serial);    if (virCommandRun(cmd, NULL) < 0)        goto cleanup;#endif    if (serial && STRNEQ(serial, "")) {        char *nl = strchr(serial, '/n');        if (nl)            *nl = '/0';    } else {        VIR_FREE(serial);        ignore_value(VIR_STRDUP(serial, dev));    }#ifdef WITH_UDEVcleanup:    virCommandFree(cmd);#endif    return serial;}
开发者ID:TelekomCloud,项目名称:libvirt,代码行数:35,


示例20: virNetDevVethDelete

/** * virNetDevVethDelete: * @veth: name for one end of veth pair * * This will delete both veth devices in a pair.  Only one end needs to * be specified.  The ip command will identify and delete the other veth * device as well. * ip link del veth * * Returns 0 on success or -1 in case of error */int virNetDevVethDelete(const char *veth){    virCommandPtr cmd = virCommandNewArgList("ip", "link", "del", veth, NULL);    int status;    int ret = -1;    if (virCommandRun(cmd, &status) < 0)        goto cleanup;    if (status != 0) {        if (!virNetDevExists(veth)) {            VIR_DEBUG("Device %s already deleted (by kernel namespace cleanup)", veth);            ret = 0;            goto cleanup;        }        virReportError(VIR_ERR_INTERNAL_ERROR,                       _("Failed to delete veth device %s"), veth);        goto cleanup;    }    ret = 0;cleanup:    virCommandFree(cmd);    return ret;}
开发者ID:dmitryilyin,项目名称:libvirt,代码行数:36,


示例21: virStorageBackendFileSystemNetFindNFSPoolSources

static voidvirStorageBackendFileSystemNetFindNFSPoolSources(virNetfsDiscoverState *state){    /*     *  # showmount --no-headers -e HOSTNAME     *  /tmp   *     *  /A dir demo1.foo.bar,demo2.foo.bar     *     * Extract directory name (including possible interior spaces ...).     */    const char *regexes[] = {        "^(/.*//S) +//S+$"    };    int vars[] = {        1    };    virCommandPtr cmd = NULL;    cmd = virCommandNewArgList(SHOWMOUNT,                               "--no-headers",                               "--exports",                               state->host,                               NULL);    if (virCommandRunRegex(cmd, 1, regexes, vars,                           virStorageBackendFileSystemNetFindPoolSourcesFunc,                           &state, NULL) < 0)        virResetLastError();    virCommandFree(cmd);}
开发者ID:ramielrowe,项目名称:libvirt,代码行数:33,


示例22: virNetDevMidonetBindPort

/** * virNetDevMidonetBindPort: * @ifname: the network interface name * @virtualport: the midonet specific fields * * Bind an interface to a Midonet virtual port * * Returns 0 in case of success or -1 in case of failure. */intvirNetDevMidonetBindPort(const char *ifname,                         virNetDevVPortProfilePtr virtualport){    int ret = -1;    virCommandPtr cmd = NULL;    char virtportuuid[VIR_UUID_STRING_BUFLEN];    virUUIDFormat(virtualport->interfaceID, virtportuuid);    cmd = virCommandNew(MMCTL);    virCommandAddArgList(cmd, "--bind-port", virtportuuid, ifname, NULL);    if (virCommandRun(cmd, NULL) < 0) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       _("Unable to bind port %s to the virtual port %s"),                       ifname, virtportuuid);        goto cleanup;    }    ret = 0; cleanup:    virCommandFree(cmd);    return ret;}
开发者ID:Antique,项目名称:libvirt,代码行数:35,


示例23: virStorageBackendZFSVolModeNeeded

/** * virStorageBackendZFSVolModeNeeded: * * Checks if it's necessary to specify 'volmode' (i.e. that * we're working with BSD ZFS implementation). * * Returns 1 if 'volmode' is need, 0 if not needed, -1 on error */static intvirStorageBackendZFSVolModeNeeded(void){    virCommandPtr cmd = NULL;    int ret = -1, exit = -1;    char *error = NULL;    /* 'zfs get' without arguments prints out     * usage information to stderr, including     * list of supported options, and exits with     * exit code 2     */    cmd = virCommandNewArgList(ZFS, "get", NULL);    virCommandAddEnvString(cmd, "LC_ALL=C");    virCommandSetErrorBuffer(cmd, &error);    ret = virCommandRun(cmd, &exit);    if ((ret < 0) || (exit != 2)) {        VIR_WARN("Command 'zfs get' either failed "                 "to run or exited with unexpected status");        goto cleanup;    }    if (strstr(error, " volmode "))        ret = 1;    else        ret = 0; cleanup:    virCommandFree(cmd);    VIR_FREE(error);    return ret;}
开发者ID:vtolstov,项目名称:libvirt,代码行数:41,


示例24: virStorageBackendZFSBuildPool

static intvirStorageBackendZFSBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,                              virStoragePoolObjPtr pool,                              unsigned int flags){    virCommandPtr cmd = NULL;    size_t i;    int ret = -1;    virCheckFlags(0, -1);    if (pool->def->source.ndevice == 0) {        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,                       "%s", _("missing source devices"));        return -1;    }    cmd = virCommandNewArgList(ZPOOL, "create",                               pool->def->source.name, NULL);    for (i = 0; i < pool->def->source.ndevice; i++)        virCommandAddArg(cmd, pool->def->source.devices[i].path);    if (virCommandRun(cmd, NULL) < 0)        goto cleanup;    ret = 0; cleanup:    virCommandFree(cmd);    return ret;}
开发者ID:vtolstov,项目名称:libvirt,代码行数:32,


示例25: virStorageBackendLogicalFindLVs

static intvirStorageBackendLogicalFindLVs(virStoragePoolObjPtr pool,                                virStorageVolDefPtr vol){    /*     * # lvs --separator , --noheadings --units b --unbuffered --nosuffix --options /     * "lv_name,origin,uuid,devices,seg_size,vg_extent_size,size,lv_attr" VGNAME     *     * RootLV,,06UgP5-2rhb-w3Bo-3mdR-WeoL-pytO-SAa2ky,/dev/hda2(0),5234491392,33554432,5234491392,-wi-ao     * SwapLV,,oHviCK-8Ik0-paqS-V20c-nkhY-Bm1e-zgzU0M,/dev/hda2(156),1040187392,33554432,1040187392,-wi-ao     * Test2,,3pg3he-mQsA-5Sui-h0i6-HNmc-Cz7W-QSndcR,/dev/hda2(219),1073741824,33554432,1073741824,owi-a-     * Test3,,UB5hFw-kmlm-LSoX-EI1t-ioVd-h7GL-M0W8Ht,/dev/hda2(251),2181038080,33554432,2181038080,-wi-a-     * Test3,Test2,UB5hFw-kmlm-LSoX-EI1t-ioVd-h7GL-M0W8Ht,/dev/hda2(187),1040187392,33554432,1040187392,swi-a-     *     * Pull out name, origin, & uuid, device, device extent start #,     * segment size, extent size, size, attrs     *     * NB can be multiple rows per volume if they have many extents     *     * NB lvs from some distros (e.g. SLES10 SP2) outputs trailing "," on each line     *     * NB Encrypted logical volumes can print ':' in their name, so it is     *    not a suitable separator (rhbz 470693).     * NB "devices" field has multiple device paths and "," if the volume is     *    striped, so "," is not a suitable separator either (rhbz 727474).     */    const char *regexes[] = {       "^//s*(//S+)#(//S*)#(//S+)#(//S+)#(//S+)#([0-9]+)#(//S+)#([0-9]+)#([0-9]+)#(//S+)#?//s*$"    };    int vars[] = {        10    };    int ret = -1;    virCommandPtr cmd;    cmd = virCommandNewArgList(LVS,                               "--separator", "#",                               "--noheadings",                               "--units", "b",                               "--unbuffered",                               "--nosuffix",                               "--options",                               "lv_name,origin,uuid,devices,segtype,stripes,seg_size,vg_extent_size,size,lv_attr",                               pool->def->source.name,                               NULL);    if (virStorageBackendRunProgRegex(pool,                                      cmd,                                      1,                                      regexes,                                      vars,                                      virStorageBackendLogicalMakeVol,                                      vol, "lvs") < 0)        goto cleanup;    ret = 0;cleanup:    virCommandFree(cmd);    return ret;}
开发者ID:ISI-apex,项目名称:libvirt-ARM,代码行数:59,


示例26: virSysinfoRead

virSysinfoDefPtrvirSysinfoRead(void) {    char *path;    virSysinfoDefPtr ret = NULL;    char *outbuf = NULL;    virCommandPtr cmd;    path = virFindFileInPath(SYSINFO_SMBIOS_DECODER);    if (path == NULL) {        virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,                             _("Failed to find path for %s binary"),                             SYSINFO_SMBIOS_DECODER);        return NULL;    }    cmd = virCommandNewArgList(path, "-q", "-t", "0,1,4,17", NULL);    VIR_FREE(path);    virCommandSetOutputBuffer(cmd, &outbuf);    if (virCommandRun(cmd, NULL) < 0) {        virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,                             _("Failed to execute command %s"),                             path);        goto cleanup;    }    if (VIR_ALLOC(ret) < 0)        goto no_memory;    ret->type = VIR_SYSINFO_SMBIOS;    if (virSysinfoParseBIOS(outbuf, ret) < 0)        goto no_memory;    if (virSysinfoParseSystem(outbuf, ret) < 0)        goto no_memory;    ret->nprocessor = 0;    ret->processor = NULL;    if (virSysinfoParseProcessor(outbuf, ret) < 0)        goto no_memory;    ret->nmemory = 0;    ret->memory = NULL;    if (virSysinfoParseMemory(outbuf, ret) < 0)        goto no_memory;cleanup:    VIR_FREE(outbuf);    virCommandFree(cmd);    return ret;no_memory:    virReportOOMError();    virSysinfoDefFree(ret);    ret = NULL;    goto cleanup;}
开发者ID:rmarwaha,项目名称:libvirt1,代码行数:59,


示例27: virBhyveProcessBuildBhyveCmd

virCommandPtrvirBhyveProcessBuildBhyveCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED,                             virDomainObjPtr vm){    /*     * /usr/sbin/bhyve -c 2 -m 256 -AI -H -P /     *            -s 0:0,hostbridge /     *            -s 1:0,virtio-net,tap0 /     *            -s 2:0,ahci-hd,${IMG} /     *            -S 31,uart,stdio /     *            vm0     */    virCommandPtr cmd = virCommandNew(BHYVE);    /* CPUs */    virCommandAddArg(cmd, "-c");    virCommandAddArgFormat(cmd, "%d", vm->def->vcpus);    /* Memory */    virCommandAddArg(cmd, "-m");    virCommandAddArgFormat(cmd, "%llu",                           VIR_DIV_UP(vm->def->mem.max_balloon, 1024));    /* Options */    if (vm->def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_DOMAIN_FEATURE_STATE_ON)        virCommandAddArg(cmd, "-A"); /* Create an ACPI table */    if (vm->def->features[VIR_DOMAIN_FEATURE_APIC] == VIR_DOMAIN_FEATURE_STATE_ON)        virCommandAddArg(cmd, "-I"); /* Present ioapic to the guest */    /* Clarification about -H and -P flags from Peter Grehan:     * -H and -P flags force the guest to exit when it executes IA32 HLT and PAUSE     * instructions respectively.     *     * For the HLT exit, bhyve uses that to infer that the guest is idling and can     * be put to sleep until an external event arrives. If this option is not used,     * the guest will always use 100% of CPU on the host.     *     * The PAUSE exit is most useful when there are large numbers of guest VMs running,     * since it forces the guest to exit when it spins on a lock acquisition.     */    virCommandAddArg(cmd, "-H"); /* vmexit from guest on hlt */    virCommandAddArg(cmd, "-P"); /* vmexit from guest on pause */    virCommandAddArgList(cmd, "-s", "0:0,hostbridge", NULL);    /* Devices */    if (bhyveBuildNetArgStr(vm->def, cmd) < 0)        goto error;    if (bhyveBuildDiskArgStr(vm->def, cmd) < 0)        goto error;    if (bhyveBuildConsoleArgStr(vm->def, cmd) < 0)        goto error;    virCommandAddArg(cmd, vm->def->name);    return cmd; error:    virCommandFree(cmd);    return NULL;}
开发者ID:Thingee,项目名称:libvirt,代码行数:59,


示例28: iptablesCommandRunAndFree

static intiptablesCommandRunAndFree(virCommandPtr cmd){    int ret;    ret = virCommandRun(cmd, NULL);    virCommandFree(cmd);    return ret;}
开发者ID:mithleshvrts,项目名称:libvirt-0.10.2,代码行数:8,


示例29: vmwareUpdateVMStatus

static intvmwareUpdateVMStatus(struct vmware_driver *driver, virDomainObjPtr vm){    virCommandPtr cmd;    char *outbuf = NULL;    char *vmxAbsolutePath = NULL;    char *parsedVmxPath = NULL;    char *str;    char *saveptr = NULL;    bool found = false;    int oldState = virDomainObjGetState(vm, NULL);    int newState;    int ret = -1;    cmd = virCommandNewArgList(VMRUN, "-T", vmw_types[driver->type],                               "list", NULL);    virCommandSetOutputBuffer(cmd, &outbuf);    if (virCommandRun(cmd, NULL) < 0)        goto cleanup;    if (virFileResolveAllLinks(((vmwareDomainPtr) vm->privateData)->vmxPath,                               &vmxAbsolutePath) < 0)        goto cleanup;    for (str = outbuf ; (parsedVmxPath = strtok_r(str, "/n", &saveptr)) != NULL;         str = NULL) {        if (parsedVmxPath[0] != '/')            continue;        if (STREQ(parsedVmxPath, vmxAbsolutePath)) {            found = true;            /* If the vmx path is in the output, the domain is running or             * is paused but we have no way to detect if it is paused or not. */            if (oldState == VIR_DOMAIN_PAUSED)                newState = oldState;            else                newState = VIR_DOMAIN_RUNNING;            break;        }    }    if (!found) {        vm->def->id = -1;        newState = VIR_DOMAIN_SHUTOFF;    }    virDomainObjSetState(vm, newState, 0);    ret = 0;cleanup:    virCommandFree(cmd);    VIR_FREE(outbuf);    VIR_FREE(vmxAbsolutePath);    return ret;}
开发者ID:bigclouds,项目名称:libvirt,代码行数:57,


示例30: virPolkitAgentDestroy

/* virPolkitAgentDestroy: * @cmd: Pointer to the virCommandPtr created during virPolkitAgentCreate * * Destroy resources used by Polkit Agent */voidvirPolkitAgentDestroy(virPolkitAgentPtr agent){    if (!agent)        return;    virCommandFree(agent->cmd);    VIR_FREE(agent);}
开发者ID:Archer-sys,项目名称:libvirt,代码行数:14,



注:本文中的virCommandFree函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ virCommandNewArgList函数代码示例
C++ virClassNew函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。