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

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

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

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

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

示例1: 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,


示例2: 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,


示例3: 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,


示例4: 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,


示例5: 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,


示例6: 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,


示例7: 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,


示例8: 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,


示例9: 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,


示例10: 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,


示例11: 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,


示例12: 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,


示例13: 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,


示例14: 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,


示例15: 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,


示例16: 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,


示例17: 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,


示例18: 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,


示例19: 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,


示例20: 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,


示例21: 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,


示例22: iptablesCommandRunAndFree

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


示例23: 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,


示例24: virISCSIConnection

static intvirISCSIConnection(const char *portal,                   const char *initiatoriqn,                   const char *target,                   const char **extraargv){    int ret = -1;    const char *const baseargv[] = {        ISCSIADM,        "--mode", "node",        "--portal", portal,        "--targetname", target,        NULL    };    virCommandPtr cmd;    char *ifacename = NULL;    cmd = virCommandNewArgs(baseargv);    virCommandAddArgSet(cmd, extraargv);    if (initiatoriqn) {        switch (virStorageBackendIQNFound(initiatoriqn, &ifacename)) {        case IQN_FOUND:            VIR_DEBUG("ifacename: '%s'", ifacename);            break;        case IQN_MISSING:            if (virStorageBackendCreateIfaceIQN(initiatoriqn, &ifacename) != 0)                goto cleanup;            /*             * iscsiadm doesn't let you send commands to the Interface IQN,             * unless you've first issued a 'sendtargets' command to the             * portal. Without the sendtargets all that is received is a             * "iscsiadm: No records found"             */            if (virISCSIScanTargets(portal, NULL, NULL) < 0)                goto cleanup;            break;        case IQN_ERROR:        default:            goto cleanup;        }        virCommandAddArgList(cmd, "--interface", ifacename, NULL);    }    if (virCommandRun(cmd, NULL) < 0)        goto cleanup;    ret = 0; cleanup:    virCommandFree(cmd);    VIR_FREE(ifacename);    return ret;}
开发者ID:RWTH-OS,项目名称:libvirt,代码行数:56,


示例25: virIpTablesOnceInit

static intvirIpTablesOnceInit(void){    virCommandPtr cmd;    int status;#if HAVE_FIREWALLD    firewall_cmd_path = virFindFileInPath("firewall-cmd");    if (!firewall_cmd_path) {        VIR_INFO("firewall-cmd not found on system. "                 "firewalld support disabled for iptables.");    } else {        cmd = virCommandNew(firewall_cmd_path);        virCommandAddArgList(cmd, "--state", NULL);        /* don't log non-zero status */        if (virCommandRun(cmd, &status) < 0 || status != 0) {            VIR_INFO("firewall-cmd found but disabled for iptables");            VIR_FREE(firewall_cmd_path);            firewall_cmd_path = NULL;        } else {            VIR_INFO("using firewalld for iptables commands");        }        virCommandFree(cmd);    }    if (firewall_cmd_path)        return 0;#endif    cmd = virCommandNew(IPTABLES_PATH);    virCommandAddArgList(cmd, "-w", "-L", "-n", NULL);    /* don't log non-zero status */    if (virCommandRun(cmd, &status) < 0 || status != 0) {        VIR_INFO("xtables locking not supported by your iptables");    } else {        VIR_INFO("using xtables locking for iptables");        iptables_supports_xlock = true;    }    virCommandFree(cmd);    return 0;}
开发者ID:i-ninth,项目名称:libvirt,代码行数:43,


示例26: virISCSIRescanLUNs

intvirISCSIRescanLUNs(const char *session){    virCommandPtr cmd = virCommandNewArgList(ISCSIADM,                                             "--mode", "session",                                             "-r", session,                                             "-R",                                             NULL);    int ret = virCommandRun(cmd, NULL);    virCommandFree(cmd);    return ret;}
开发者ID:RWTH-OS,项目名称:libvirt,代码行数:12,


示例27: vmwareExtractVersion

intvmwareExtractVersion(struct vmware_driver *driver){    int ret = -1;    virCommandPtr cmd = NULL;    char * outbuf = NULL;    char *bin = NULL;    char *vmwarePath = NULL;    if ((vmwarePath = mdir_name(driver->vmrun)) == NULL)        goto cleanup;    switch (driver->type) {        case VMWARE_DRIVER_PLAYER:            if (virAsprintf(&bin, "%s/%s", vmwarePath, "vmplayer") < 0)                goto cleanup;            break;        case VMWARE_DRIVER_WORKSTATION:            if (virAsprintf(&bin, "%s/%s", vmwarePath, "vmware") < 0)                goto cleanup;            break;        case VMWARE_DRIVER_FUSION:            if (virAsprintf(&bin, "%s/%s", vmwarePath, "vmware-vmx") < 0)                goto cleanup;            break;        default:            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",                           _("invalid driver type for version detection"));            goto cleanup;    }    cmd = virCommandNewArgList(bin, "-v", NULL);    virCommandSetOutputBuffer(cmd, &outbuf);    virCommandSetErrorBuffer(cmd, &outbuf);    if (virCommandRun(cmd, NULL) < 0)        goto cleanup;    if (vmwareParseVersionStr(driver->type, outbuf, &driver->version) < 0)        goto cleanup;    ret = 0; cleanup:    virCommandFree(cmd);    VIR_FREE(outbuf);    VIR_FREE(bin);    VIR_FREE(vmwarePath);    return ret;}
开发者ID:AGSaidi,项目名称:hacked-libvirt,代码行数:53,


示例28: virStorageBackendISCSIRescanLUNs

static intvirStorageBackendISCSIRescanLUNs(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,                                 const char *session){    virCommandPtr cmd = virCommandNewArgList(ISCSIADM,                                             "--mode", "session",                                             "-r", session,                                             "-R",                                             NULL);    int ret = virCommandRun(cmd, NULL);    virCommandFree(cmd);    return ret;}
开发者ID:hzguanqiang,项目名称:libvirt,代码行数:13,


示例29: virStorageBackendZFSFindVols

static intvirStorageBackendZFSFindVols(virStoragePoolObjPtr pool,                             virStorageVolDefPtr vol){    virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);    virCommandPtr cmd = NULL;    char *volumes_list = NULL;    char **lines = NULL;    size_t i;    /**     * $ zfs list -Hp -t volume -o name,volsize -r test     * test/vol1       5368709120     * test/vol3       1073741824     * test/vol4       1572864000     * $     *     * Arguments description:     *  -t volume -- we want to see only volumes     *  -o name,volsize -- limit output to name and volume size     *  -r -- we want to see all the childer of our pool     */    cmd = virCommandNewArgList(ZFS,                               "list", "-Hp",                               "-t", "volume", "-r",                               "-o", "name,volsize,refreservation",                               def->source.name,                               NULL);    virCommandSetOutputBuffer(cmd, &volumes_list);    if (virCommandRun(cmd, NULL) < 0)        goto cleanup;    if (!(lines = virStringSplit(volumes_list, "/n", 0)))        goto cleanup;    for (i = 0; lines[i]; i++) {        if (STREQ(lines[i], ""))            continue;        if (virStorageBackendZFSParseVol(pool, vol, lines[i]) < 0)            continue;    } cleanup:    virCommandFree(cmd);    virStringListFree(lines);    VIR_FREE(volumes_list);    return 0;}
开发者ID:RWTH-OS,项目名称:libvirt,代码行数:50,


示例30: virNetSocketForkDaemon

static int virNetSocketForkDaemon(const char *binary){    int ret;    virCommandPtr cmd = virCommandNewArgList(binary,                                             "--timeout=30",                                             NULL);    virCommandAddEnvPassCommon(cmd);    virCommandClearCaps(cmd);    virCommandDaemonize(cmd);    ret = virCommandRun(cmd, NULL);    virCommandFree(cmd);    return ret;}
开发者ID:soulxu,项目名称:libvirt-xuhj,代码行数:14,



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


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