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

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

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

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

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

示例1: vshAdmDaemon

static intvshAdmDaemon(vshControl *ctl, unsigned int flags){    vshAdmControlPtr priv = ctl->privData;    priv->dmn = virAdmDaemonOpen(priv->name, flags);    if (!priv->dmn) {        if (priv->wantReconnect)            vshError(ctl, "%s", _("Failed to reconnect to the admin server"));        else            vshError(ctl, "%s", _("Failed to connect to the admin server"));        return -1;    } else {        if (virAdmDaemonRegisterCloseCallback(priv->dmn, vshAdmCatchDisconnect,                                              NULL, NULL) < 0)            vshError(ctl, "%s", _("Unable to register disconnect callback"));        if (priv->wantReconnect)            vshPrint(ctl, "%s/n", _("Reconnected to the admin server"));        else            vshPrint(ctl, "%s/n", _("Connected to the admin server"));    }    return 0;}
开发者ID:borisroman,项目名称:libvirt,代码行数:26,


示例2: cmdVolInfo

static boolcmdVolInfo(vshControl *ctl, const vshCmd *cmd){    virStorageVolInfo info;    virStorageVolPtr vol;    bool ret = true;    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))        return false;    vshPrint(ctl, "%-15s %s/n", _("Name:"), virStorageVolGetName(vol));    if (virStorageVolGetInfo(vol, &info) == 0) {        double val;        const char *unit;        vshPrint(ctl, "%-15s %s/n", _("Type:"),                 vshVolumeTypeToString(info.type));        val = vshPrettyCapacity(info.capacity, &unit);        vshPrint(ctl, "%-15s %2.2lf %s/n", _("Capacity:"), val, unit);        val = vshPrettyCapacity(info.allocation, &unit);        vshPrint(ctl, "%-15s %2.2lf %s/n", _("Allocation:"), val, unit);    } else {        ret = false;    }    virStorageVolFree(vol);    return ret;}
开发者ID:aurex-linux,项目名称:libvirt,代码行数:31,


示例3: cmdVolClone

static boolcmdVolClone(vshControl *ctl, const vshCmd *cmd){    virStoragePoolPtr origpool = NULL;    virStorageVolPtr origvol = NULL, newvol = NULL;    const char *name = NULL;    char *origxml = NULL;    xmlChar *newxml = NULL;    bool ret = false;    unsigned int flags = 0;    if (!(origvol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))        goto cleanup;    if (vshCommandOptBool(cmd, "prealloc-metadata"))        flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;    origpool = virStoragePoolLookupByVolume(origvol);    if (!origpool) {        vshError(ctl, "%s", _("failed to get parent pool"));        goto cleanup;    }    if (vshCommandOptStringReq(ctl, cmd, "newname", &name) < 0)        goto cleanup;    origxml = virStorageVolGetXMLDesc(origvol, 0);    if (!origxml)        goto cleanup;    newxml = vshMakeCloneXML(origxml, name);    if (!newxml) {        vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));        goto cleanup;    }    newvol = virStorageVolCreateXMLFrom(origpool, (char *) newxml, origvol, flags);    if (newvol != NULL) {        vshPrint(ctl, _("Vol %s cloned from %s/n"),                 virStorageVolGetName(newvol), virStorageVolGetName(origvol));    } else {        vshError(ctl, _("Failed to clone vol from %s"),                 virStorageVolGetName(origvol));        goto cleanup;    }    ret = true; cleanup:    VIR_FREE(origxml);    xmlFree(newxml);    if (origvol)        virStorageVolFree(origvol);    if (newvol)        virStorageVolFree(newvol);    if (origpool)        virStoragePoolFree(origpool);    return ret;}
开发者ID:aurex-linux,项目名称:libvirt,代码行数:60,


示例4: cmdNetworkAutostart

static boolcmdNetworkAutostart(vshControl *ctl, const vshCmd *cmd){    virNetworkPtr network;    const char *name;    int autostart;    if (!(network = virshCommandOptNetwork(ctl, cmd, &name)))        return false;    autostart = !vshCommandOptBool(cmd, "disable");    if (virNetworkSetAutostart(network, autostart) < 0) {        if (autostart)            vshError(ctl, _("failed to mark network %s as autostarted"), name);        else            vshError(ctl, _("failed to unmark network %s as autostarted"), name);        virNetworkFree(network);        return false;    }    if (autostart)        vshPrint(ctl, _("Network %s marked as autostarted/n"), name);    else        vshPrint(ctl, _("Network %s unmarked as autostarted/n"), name);    virNetworkFree(network);    return true;}
开发者ID:FrankYu,项目名称:libvirt,代码行数:29,


示例5: cmdVolClone

static boolcmdVolClone(vshControl *ctl, const vshCmd *cmd){    virStoragePoolPtr origpool = NULL;    virStorageVolPtr origvol = NULL, newvol = NULL;    const char *name = NULL;    char *origxml = NULL;    xmlChar *newxml = NULL;    bool ret = false;    if (!vshConnectionUsability(ctl, ctl->conn))        goto cleanup;    if (!(origvol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))        goto cleanup;    origpool = virStoragePoolLookupByVolume(origvol);    if (!origpool) {        vshError(ctl, "%s", _("failed to get parent pool"));        goto cleanup;    }    if (vshCommandOptString(cmd, "newname", &name) <= 0)        goto cleanup;    origxml = virStorageVolGetXMLDesc(origvol, 0);    if (!origxml)        goto cleanup;    newxml = makeCloneXML(origxml, name);    if (!newxml) {        vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));        goto cleanup;    }    newvol = virStorageVolCreateXMLFrom(origpool, (char *) newxml, origvol, 0);    if (newvol != NULL) {        vshPrint(ctl, _("Vol %s cloned from %s/n"),                 virStorageVolGetName(newvol), virStorageVolGetName(origvol));    } else {        vshError(ctl, _("Failed to clone vol from %s"),                 virStorageVolGetName(origvol));        goto cleanup;    }    ret = true;cleanup:    VIR_FREE(origxml);    xmlFree(newxml);    if (origvol)        virStorageVolFree(origvol);    if (newvol)        virStorageVolFree(newvol);    if (origpool)        virStoragePoolFree(origpool);    return ret;}
开发者ID:pdf,项目名称:libvirt,代码行数:59,


示例6: cmdSecretDefine

static boolcmdSecretDefine(vshControl *ctl, const vshCmd *cmd){    const char *from = NULL;    char *buffer;    virSecretPtr res;    char uuid[VIR_UUID_STRING_BUFLEN];    bool ret = false;    if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)        return false;    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)        return false;    if (!(res = virSecretDefineXML(ctl->conn, buffer, 0))) {        vshError(ctl, _("Failed to set attributes from %s"), from);        goto cleanup;    }    if (virSecretGetUUIDString(res, &(uuid[0])) < 0) {        vshError(ctl, "%s", _("Failed to get UUID of created secret"));        goto cleanup;    }    vshPrint(ctl, _("Secret %s created/n"), uuid);    ret = true; cleanup:    VIR_FREE(buffer);    if (res)        virSecretFree(res);    return ret;}
开发者ID:AGSaidi,项目名称:hacked-libvirt,代码行数:34,


示例7: cmdSecretGetValue

static boolcmdSecretGetValue(vshControl *ctl, const vshCmd *cmd){    virSecretPtr secret;    VIR_AUTODISPOSE_STR base64 = NULL;    unsigned char *value;    size_t value_size;    bool ret = false;    secret = virshCommandOptSecret(ctl, cmd, NULL);    if (secret == NULL)        return false;    value = virSecretGetValue(secret, &value_size, 0);    if (value == NULL)        goto cleanup;    if (!(base64 = virStringEncodeBase64(value, value_size)))        goto cleanup;    vshPrint(ctl, "%s", base64);    ret = true; cleanup:    VIR_DISPOSE_N(value, value_size);    virSecretFree(secret);    return ret;}
开发者ID:libvirt,项目名称:libvirt,代码行数:28,


示例8: cmdNetworkDefine

static boolcmdNetworkDefine(vshControl *ctl, const vshCmd *cmd){    virNetworkPtr network;    const char *from = NULL;    bool ret = true;    char *buffer;    virshControlPtr priv = ctl->privData;    if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)        return false;    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)        return false;    network = virNetworkDefineXML(priv->conn, buffer);    VIR_FREE(buffer);    if (network != NULL) {        vshPrint(ctl, _("Network %s defined from %s/n"),                 virNetworkGetName(network), from);        virNetworkFree(network);    } else {        vshError(ctl, _("Failed to define network from %s"), from);        ret = false;    }    return ret;}
开发者ID:FrankYu,项目名称:libvirt,代码行数:28,


示例9: cmdNetworkDumpXML

static boolcmdNetworkDumpXML(vshControl *ctl, const vshCmd *cmd){    virNetworkPtr network;    bool ret = true;    char *dump;    unsigned int flags = 0;    int inactive;    if (!(network = virshCommandOptNetwork(ctl, cmd, NULL)))        return false;    inactive = vshCommandOptBool(cmd, "inactive");    if (inactive)        flags |= VIR_NETWORK_XML_INACTIVE;    dump = virNetworkGetXMLDesc(network, flags);    if (dump != NULL) {        vshPrint(ctl, "%s", dump);        VIR_FREE(dump);    } else {        ret = false;    }    virNetworkFree(network);    return ret;}
开发者ID:FrankYu,项目名称:libvirt,代码行数:28,


示例10: cmdSecretGetValue

static boolcmdSecretGetValue(vshControl *ctl, const vshCmd *cmd){    virSecretPtr secret;    char *base64;    unsigned char *value;    size_t value_size;    bool ret = false;    secret = vshCommandOptSecret(ctl, cmd, NULL);    if (secret == NULL)        return false;    value = virSecretGetValue(secret, &value_size, 0);    if (value == NULL)        goto cleanup;    base64_encode_alloc((char *)value, value_size, &base64);    memset(value, 0, value_size);    VIR_FREE(value);    if (base64 == NULL) {        vshError(ctl, "%s", _("Failed to allocate memory"));        goto cleanup;    }    vshPrint(ctl, "%s", base64);    memset(base64, 0, strlen(base64));    VIR_FREE(base64);    ret = true; cleanup:    virSecretFree(secret);    return ret;}
开发者ID:AGSaidi,项目名称:hacked-libvirt,代码行数:34,


示例11: cmdNodeDeviceCreate

static boolcmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd){    virNodeDevicePtr dev = NULL;    const char *from = NULL;    bool ret = true;    char *buffer;    if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)        return false;    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)        return false;    dev = virNodeDeviceCreateXML(ctl->conn, buffer, 0);    VIR_FREE(buffer);    if (dev != NULL) {        vshPrint(ctl, _("Node device %s created from %s/n"),                 virNodeDeviceGetName(dev), from);        virNodeDeviceFree(dev);    } else {        vshError(ctl, _("Failed to create node device from %s"), from);        ret = false;    }    return ret;}
开发者ID:siboulet,项目名称:libvirt-openvz,代码行数:28,


示例12: cmdVolResize

static boolcmdVolResize(vshControl *ctl, const vshCmd *cmd){    virStorageVolPtr vol;    const char *capacityStr = NULL;    unsigned long long capacity = 0;    unsigned int flags = 0;    bool ret = false;    bool delta = false;    if (vshCommandOptBool(cmd, "allocate"))        flags |= VIR_STORAGE_VOL_RESIZE_ALLOCATE;    if (vshCommandOptBool(cmd, "delta")) {        delta = true;        flags |= VIR_STORAGE_VOL_RESIZE_DELTA;    }    if (vshCommandOptBool(cmd, "shrink"))        flags |= VIR_STORAGE_VOL_RESIZE_SHRINK;    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))        return false;    if (vshCommandOptStringReq(ctl, cmd, "capacity", &capacityStr) < 0)        goto cleanup;    virSkipSpaces(&capacityStr);    if (*capacityStr == '-') {        /* The API always requires a positive value; but we allow a         * negative value for convenience.  */        if (delta && vshCommandOptBool(cmd, "shrink")){            capacityStr++;        } else {            vshError(ctl, "%s",                     _("negative size requires --delta and --shrink"));            goto cleanup;        }    }    if (vshVolSize(capacityStr, &capacity) < 0) {        vshError(ctl, _("Malformed size %s"), capacityStr);        goto cleanup;    }    if (virStorageVolResize(vol, capacity, flags) == 0) {        vshPrint(ctl,                 delta ? _("Size of volume '%s' successfully changed by %s/n")                 : _("Size of volume '%s' successfully changed to %s/n"),                 virStorageVolGetName(vol), capacityStr);        ret = true;    } else {        vshError(ctl,                 delta ? _("Failed to change size of volume '%s' by %s/n")                 : _("Failed to change size of volume '%s' to %s/n"),                 virStorageVolGetName(vol), capacityStr);        ret = false;    } cleanup:    virStorageVolFree(vol);    return ret;}
开发者ID:aurex-linux,项目名称:libvirt,代码行数:59,


示例13: cmdVolInfo

static boolcmdVolInfo(vshControl *ctl, const vshCmd *cmd){    virStorageVolInfo info;    virStorageVolPtr vol;    bool ret = true;    if (!vshConnectionUsability(ctl, ctl->conn))        return false;    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))        return false;    vshPrint(ctl, "%-15s %s/n", _("Name:"), virStorageVolGetName(vol));    if (virStorageVolGetInfo(vol, &info) == 0) {        double val;        const char *unit;        switch(info.type) {        case VIR_STORAGE_VOL_FILE:            vshPrint(ctl, "%-15s %s/n", _("Type:"), _("file"));            break;        case VIR_STORAGE_VOL_BLOCK:            vshPrint(ctl, "%-15s %s/n", _("Type:"), _("block"));            break;        case VIR_STORAGE_VOL_DIR:            vshPrint(ctl, "%-15s %s/n", _("Type:"), _("dir"));            break;        case VIR_STORAGE_VOL_NETWORK:            vshPrint(ctl, "%-15s %s/n", _("Type:"), _("network"));            break;        default:            vshPrint(ctl, "%-15s %s/n", _("Type:"), _("unknown"));        }        val = prettyCapacity(info.capacity, &unit);        vshPrint(ctl, "%-15s %2.2lf %s/n", _("Capacity:"), val, unit);        val = prettyCapacity(info.allocation, &unit);        vshPrint(ctl, "%-15s %2.2lf %s/n", _("Allocation:"), val, unit);    } else {        ret = false;    }    virStorageVolFree(vol);    return ret;}
开发者ID:pdf,项目名称:libvirt,代码行数:51,


示例14: cmdVolCreateFrom

static boolcmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd){    virStoragePoolPtr pool = NULL;    virStorageVolPtr newvol = NULL, inputvol = NULL;    const char *from = NULL;    bool ret = false;    char *buffer = NULL;    if (!vshConnectionUsability(ctl, ctl->conn))        goto cleanup;    if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))        goto cleanup;    if (vshCommandOptString(cmd, "file", &from) <= 0) {        goto cleanup;    }    if (!(inputvol = vshCommandOptVol(ctl, cmd, "vol", "inputpool", NULL)))        goto cleanup;    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {        virshReportError(ctl);        goto cleanup;    }    newvol = virStorageVolCreateXMLFrom(pool, buffer, inputvol, 0);    if (newvol != NULL) {        vshPrint(ctl, _("Vol %s created from input vol %s/n"),                 virStorageVolGetName(newvol), virStorageVolGetName(inputvol));    } else {        vshError(ctl, _("Failed to create vol from %s"), from);        goto cleanup;    }    ret = true;cleanup:    VIR_FREE(buffer);    if (pool)        virStoragePoolFree(pool);    if (inputvol)        virStorageVolFree(inputvol);    if (newvol)        virStorageVolFree(newvol);    return ret;}
开发者ID:pdf,项目名称:libvirt,代码行数:48,


示例15: cmdVolCreateFrom

static boolcmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd){    virStoragePoolPtr pool = NULL;    virStorageVolPtr newvol = NULL, inputvol = NULL;    const char *from = NULL;    bool ret = false;    char *buffer = NULL;    unsigned int flags = 0;    if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))        goto cleanup;    if (vshCommandOptBool(cmd, "prealloc-metadata"))        flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;    if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)        goto cleanup;    if (!(inputvol = vshCommandOptVol(ctl, cmd, "vol", "inputpool", NULL)))        goto cleanup;    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {        vshReportError(ctl);        goto cleanup;    }    newvol = virStorageVolCreateXMLFrom(pool, buffer, inputvol, flags);    if (newvol != NULL) {        vshPrint(ctl, _("Vol %s created from input vol %s/n"),                 virStorageVolGetName(newvol), virStorageVolGetName(inputvol));    } else {        vshError(ctl, _("Failed to create vol from %s"), from);        goto cleanup;    }    ret = true; cleanup:    VIR_FREE(buffer);    if (pool)        virStoragePoolFree(pool);    if (inputvol)        virStorageVolFree(inputvol);    if (newvol)        virStorageVolFree(newvol);    return ret;}
开发者ID:aurex-linux,项目名称:libvirt,代码行数:48,


示例16: cmdNodeDeviceDestroy

static boolcmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd){    virNodeDevicePtr dev = NULL;    bool ret = false;    const char *device_value = NULL;    char **arr = NULL;    int narr;    if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0)        return false;    if (strchr(device_value, ',')) {        narr = vshStringToArray(device_value, &arr);        if (narr != 2) {            vshError(ctl, _("Malformed device value '%s'"), device_value);            goto cleanup;        }        if (!virValidateWWN(arr[0]) || !virValidateWWN(arr[1]))            goto cleanup;        dev = virNodeDeviceLookupSCSIHostByWWN(ctl->conn, arr[0], arr[1], 0);    } else {        dev = virNodeDeviceLookupByName(ctl->conn, device_value);    }    if (!dev) {        vshError(ctl, "%s '%s'", _("Could not find matching device"), device_value);        goto cleanup;    }    if (virNodeDeviceDestroy(dev) == 0) {        vshPrint(ctl, _("Destroyed node device '%s'/n"), device_value);    } else {        vshError(ctl, _("Failed to destroy node device '%s'"), device_value);        goto cleanup;    }    ret = true;cleanup:    if (arr) {        VIR_FREE(*arr);        VIR_FREE(arr);    }    virNodeDeviceFree(dev);    return ret;}
开发者ID:siboulet,项目名称:libvirt-openvz,代码行数:48,


示例17: cmdVolWipe

static boolcmdVolWipe(vshControl *ctl, const vshCmd *cmd){    virStorageVolPtr vol;    bool ret = false;    const char *name;    const char *algorithm_str = NULL;    int algorithm = VIR_STORAGE_VOL_WIPE_ALG_ZERO;    int funcRet;    if (!vshConnectionUsability(ctl, ctl->conn))        return false;    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {        return false;    }    if (vshCommandOptString(cmd, "algorithm", &algorithm_str) < 0) {        vshError(ctl, "%s", _("missing argument"));        goto out;    }    if (algorithm_str &&        (algorithm = virStorageVolWipeAlgorithmTypeFromString(algorithm_str)) < 0) {        vshError(ctl, _("Unsupported algorithm '%s'"), algorithm_str);        goto out;    }    if ((funcRet = virStorageVolWipePattern(vol, algorithm, 0)) < 0) {        if (last_error->code == VIR_ERR_NO_SUPPORT &&            algorithm == VIR_STORAGE_VOL_WIPE_ALG_ZERO)            funcRet = virStorageVolWipe(vol, 0);    }    if (funcRet < 0) {        vshError(ctl, _("Failed to wipe vol %s"), name);        goto out;    }    vshPrint(ctl, _("Vol %s wiped/n"), name);    ret = true;out:    virStorageVolFree(vol);    return ret;}
开发者ID:pdf,项目名称:libvirt,代码行数:45,


示例18: cmdNetworkInfo

static boolcmdNetworkInfo(vshControl *ctl, const vshCmd *cmd){    virNetworkPtr network;    char uuid[VIR_UUID_STRING_BUFLEN];    int autostart;    int persistent = -1;    int active = -1;    char *bridge = NULL;    if (!(network = virshCommandOptNetwork(ctl, cmd, NULL)))        return false;    vshPrint(ctl, "%-15s %s/n", _("Name:"), virNetworkGetName(network));    if (virNetworkGetUUIDString(network, uuid) == 0)        vshPrint(ctl, "%-15s %s/n", _("UUID:"), uuid);    active = virNetworkIsActive(network);    if (active >= 0)        vshPrint(ctl, "%-15s %s/n", _("Active:"), active? _("yes") : _("no"));    persistent = virNetworkIsPersistent(network);    if (persistent < 0)        vshPrint(ctl, "%-15s %s/n", _("Persistent:"), _("unknown"));    else        vshPrint(ctl, "%-15s %s/n", _("Persistent:"), persistent ? _("yes") : _("no"));    if (virNetworkGetAutostart(network, &autostart) < 0)        vshPrint(ctl, "%-15s %s/n", _("Autostart:"), _("no autostart"));    else        vshPrint(ctl, "%-15s %s/n", _("Autostart:"), autostart ? _("yes") : _("no"));    bridge = virNetworkGetBridgeName(network);    if (bridge)        vshPrint(ctl, "%-15s %s/n", _("Bridge:"), bridge);    VIR_FREE(bridge);    virNetworkFree(network);    return true;}
开发者ID:FrankYu,项目名称:libvirt,代码行数:41,


示例19: cmdNetworkDestroy

static boolcmdNetworkDestroy(vshControl *ctl, const vshCmd *cmd){    virNetworkPtr network;    bool ret = true;    const char *name;    if (!(network = virshCommandOptNetwork(ctl, cmd, &name)))        return false;    if (virNetworkDestroy(network) == 0) {        vshPrint(ctl, _("Network %s destroyed/n"), name);    } else {        vshError(ctl, _("Failed to destroy network %s"), name);        ret = false;    }    virNetworkFree(network);    return ret;}
开发者ID:FrankYu,项目名称:libvirt,代码行数:20,


示例20: cmdVolCreate

static boolcmdVolCreate(vshControl *ctl, const vshCmd *cmd){    virStoragePoolPtr pool;    virStorageVolPtr vol;    const char *from = NULL;    bool ret = true;    char *buffer;    if (!vshConnectionUsability(ctl, ctl->conn))        return false;    if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,                                           VSH_BYNAME)))        return false;    if (vshCommandOptString(cmd, "file", &from) <= 0) {        virStoragePoolFree(pool);        return false;    }    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {        virshReportError(ctl);        virStoragePoolFree(pool);        return false;    }    vol = virStorageVolCreateXML(pool, buffer, 0);    VIR_FREE(buffer);    virStoragePoolFree(pool);    if (vol != NULL) {        vshPrint(ctl, _("Vol %s created from %s/n"),                 virStorageVolGetName(vol), from);        virStorageVolFree(vol);    } else {        vshError(ctl, _("Failed to create vol from %s"), from);        ret = false;    }    return ret;}
开发者ID:pdf,项目名称:libvirt,代码行数:41,


示例21: cmdVolDumpXML

static boolcmdVolDumpXML(vshControl *ctl, const vshCmd *cmd){    virStorageVolPtr vol;    bool ret = true;    char *dump;    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))        return false;    dump = virStorageVolGetXMLDesc(vol, 0);    if (dump != NULL) {        vshPrint(ctl, "%s", dump);        VIR_FREE(dump);    } else {        ret = false;    }    virStorageVolFree(vol);    return ret;}
开发者ID:aurex-linux,项目名称:libvirt,代码行数:21,


示例22: cmdVolDelete

static boolcmdVolDelete(vshControl *ctl, const vshCmd *cmd){    virStorageVolPtr vol;    bool ret = true;    const char *name;    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {        return false;    }    if (virStorageVolDelete(vol, 0) == 0) {        vshPrint(ctl, _("Vol %s deleted/n"), name);    } else {        vshError(ctl, _("Failed to delete vol %s"), name);        ret = false;    }    virStorageVolFree(vol);    return ret;}
开发者ID:aurex-linux,项目名称:libvirt,代码行数:21,


示例23: cmdSecretSetValue

static boolcmdSecretSetValue(vshControl *ctl, const vshCmd *cmd){    virSecretPtr secret;    size_t value_size;    const char *base64 = NULL;    char *value;    int res;    bool ret = false;    if (!(secret = vshCommandOptSecret(ctl, cmd, NULL)))        return false;    if (vshCommandOptStringReq(ctl, cmd, "base64", &base64) < 0)        goto cleanup;    if (!base64_decode_alloc(base64, strlen(base64), &value, &value_size)) {        vshError(ctl, "%s", _("Invalid base64 data"));        goto cleanup;    }    if (value == NULL) {        vshError(ctl, "%s", _("Failed to allocate memory"));        goto cleanup;    }    res = virSecretSetValue(secret, (unsigned char *)value, value_size, 0);    memset(value, 0, value_size);    VIR_FREE(value);    if (res != 0) {        vshError(ctl, "%s", _("Failed to set secret value"));        goto cleanup;    }    vshPrint(ctl, "%s", _("Secret value set/n"));    ret = true; cleanup:    virSecretFree(secret);    return ret;}
开发者ID:AGSaidi,项目名称:hacked-libvirt,代码行数:40,


示例24: cmdSecretDumpXML

static boolcmdSecretDumpXML(vshControl *ctl, const vshCmd *cmd){    virSecretPtr secret;    bool ret = false;    char *xml;    secret = virshCommandOptSecret(ctl, cmd, NULL);    if (secret == NULL)        return false;    xml = virSecretGetXMLDesc(secret, 0);    if (xml == NULL)        goto cleanup;    vshPrint(ctl, "%s", xml);    VIR_FREE(xml);    ret = true; cleanup:    virSecretFree(secret);    return ret;}
开发者ID:libvirt,项目名称:libvirt,代码行数:22,


示例25: cmdSecretUndefine

static boolcmdSecretUndefine(vshControl *ctl, const vshCmd *cmd){    virSecretPtr secret;    bool ret = false;    const char *uuid;    secret = vshCommandOptSecret(ctl, cmd, &uuid);    if (secret == NULL)        return false;    if (virSecretUndefine(secret) < 0) {        vshError(ctl, _("Failed to delete secret %s"), uuid);        goto cleanup;    }    vshPrint(ctl, _("Secret %s deleted/n"), uuid);    ret = true; cleanup:    virSecretFree(secret);    return ret;}
开发者ID:AGSaidi,项目名称:hacked-libvirt,代码行数:22,


示例26: cmdInterfaceEdit

static boolcmdInterfaceEdit(vshControl *ctl, const vshCmd *cmd){    bool ret = false;    virInterfacePtr iface = NULL;    virInterfacePtr iface_edited = NULL;    unsigned int flags = VIR_INTERFACE_XML_INACTIVE;    virshControlPtr priv = ctl->privData;    iface = virshCommandOptInterface(ctl, cmd, NULL);    if (iface == NULL)        goto cleanup;#define EDIT_GET_XML virInterfaceGetXMLDesc(iface, flags)#define EDIT_NOT_CHANGED                                                /    do {                                                                /        vshPrint(ctl, _("Interface %s XML configuration not changed./n"), /                 virInterfaceGetName(iface));                           /        ret = true;                                                     /        goto edit_cleanup;                                              /    } while (0)#define EDIT_DEFINE /    (iface_edited = virInterfaceDefineXML(priv->conn, doc_edited, 0))#include "virsh-edit.c"    vshPrint(ctl, _("Interface %s XML configuration edited./n"),             virInterfaceGetName(iface_edited));    ret = true; cleanup:    if (iface)        virInterfaceFree(iface);    if (iface_edited)        virInterfaceFree(iface_edited);    return ret;}
开发者ID:carriercomm,项目名称:libvirt,代码行数:38,


示例27: cmdVolCreate

static boolcmdVolCreate(vshControl *ctl, const vshCmd *cmd){    virStoragePoolPtr pool;    virStorageVolPtr vol;    const char *from = NULL;    bool ret = false;    unsigned int flags = 0;    char *buffer = NULL;    if (vshCommandOptBool(cmd, "prealloc-metadata"))        flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;    if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))        return false;    if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)        goto cleanup;    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {        vshSaveLibvirtError();        goto cleanup;    }    if ((vol = virStorageVolCreateXML(pool, buffer, flags))) {        vshPrint(ctl, _("Vol %s created from %s/n"),                 virStorageVolGetName(vol), from);        virStorageVolFree(vol);        ret = true;    } else {        vshError(ctl, _("Failed to create vol from %s"), from);    } cleanup:    VIR_FREE(buffer);    virStoragePoolFree(pool);    return ret;}
开发者ID:aurex-linux,项目名称:libvirt,代码行数:37,


示例28: cmdVolCreateAs

//.........这里部分代码省略.........    }    virBufferAddLit(&buf, "<volume>/n");    virBufferAsprintf(&buf, "  <name>%s</name>/n", name);    virBufferAsprintf(&buf, "  <capacity>%llu</capacity>/n", capacity);    if (allocationStr)        virBufferAsprintf(&buf, "  <allocation>%llu</allocation>/n", allocation);    if (format) {        virBufferAddLit(&buf, "  <target>/n");        virBufferAsprintf(&buf, "    <format type='%s'/>/n",format);        virBufferAddLit(&buf, "  </target>/n");    }    /* Convert the snapshot parameters into backingStore XML */    if (snapshotStrVol) {        /* Lookup snapshot backing volume.  Try the backing-vol         *  parameter as a name */        vshDebug(ctl, VSH_ERR_DEBUG,                 "%s: Look up backing store volume '%s' as name/n",                 cmd->def->name, snapshotStrVol);        virStorageVolPtr snapVol = virStorageVolLookupByName(pool, snapshotStrVol);        if (snapVol)                vshDebug(ctl, VSH_ERR_DEBUG,                         "%s: Backing store volume found using '%s' as name/n",                         cmd->def->name, snapshotStrVol);        if (snapVol == NULL) {            /* Snapshot backing volume not found by name.  Try the             *  backing-vol parameter as a key */            vshDebug(ctl, VSH_ERR_DEBUG,                     "%s: Look up backing store volume '%s' as key/n",                     cmd->def->name, snapshotStrVol);            snapVol = virStorageVolLookupByKey(ctl->conn, snapshotStrVol);            if (snapVol)                vshDebug(ctl, VSH_ERR_DEBUG,                         "%s: Backing store volume found using '%s' as key/n",                         cmd->def->name, snapshotStrVol);        }        if (snapVol == NULL) {            /* Snapshot backing volume not found by key.  Try the             *  backing-vol parameter as a path */            vshDebug(ctl, VSH_ERR_DEBUG,                     "%s: Look up backing store volume '%s' as path/n",                     cmd->def->name, snapshotStrVol);            snapVol = virStorageVolLookupByPath(ctl->conn, snapshotStrVol);            if (snapVol)                vshDebug(ctl, VSH_ERR_DEBUG,                         "%s: Backing store volume found using '%s' as path/n",                         cmd->def->name, snapshotStrVol);        }        if (snapVol == NULL) {            vshError(ctl, _("failed to get vol '%s'"), snapshotStrVol);            goto cleanup;        }        char *snapshotStrVolPath;        if ((snapshotStrVolPath = virStorageVolGetPath(snapVol)) == NULL) {            virStorageVolFree(snapVol);            goto cleanup;        }        /* Create XML for the backing store */        virBufferAddLit(&buf, "  <backingStore>/n");        virBufferAsprintf(&buf, "    <path>%s</path>/n",snapshotStrVolPath);        if (snapshotStrFormat)            virBufferAsprintf(&buf, "    <format type='%s'/>/n",snapshotStrFormat);        virBufferAddLit(&buf, "  </backingStore>/n");        /* Cleanup snapshot allocations */        VIR_FREE(snapshotStrVolPath);        virStorageVolFree(snapVol);    }    virBufferAddLit(&buf, "</volume>/n");    if (virBufferError(&buf)) {        vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));        goto cleanup;    }    xml = virBufferContentAndReset(&buf);    vol = virStorageVolCreateXML(pool, xml, 0);    VIR_FREE(xml);    virStoragePoolFree(pool);    if (vol != NULL) {        vshPrint(ctl, _("Vol %s created/n"), name);        virStorageVolFree(vol);        return true;    } else {        vshError(ctl, _("Failed to create vol %s"), name);        return false;    } cleanup:    virBufferFreeAndReset(&buf);    virStoragePoolFree(pool);    return false;}
开发者ID:pdf,项目名称:libvirt,代码行数:101,



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


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