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

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

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

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

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

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


示例2: 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;    virshControlPtr priv = ctl->privData;    if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)        return false;    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)        return false;    if (!(res = virSecretDefineXML(priv->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;    }    vshPrintExtra(ctl, _("Secret %s created/n"), uuid);    ret = true; cleanup:    VIR_FREE(buffer);    if (res)        virSecretFree(res);    return ret;}
开发者ID:libvirt,项目名称:libvirt,代码行数:35,


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


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


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


示例7: vshCommandOptVolBy

static virStorageVolPtrvshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd,                   const char *optname,                   const char *pooloptname,                   const char **name, int flag){    virStorageVolPtr vol = NULL;    virStoragePoolPtr pool = NULL;    const char *n = NULL, *p = NULL;    if (vshCommandOptString(cmd, optname, &n) <= 0)        return NULL;    if (pooloptname != NULL && vshCommandOptString(cmd, pooloptname, &p) < 0) {        vshError(ctl, "%s", _("missing option"));        return NULL;    }    if (p)        pool = vshCommandOptPoolBy(ctl, cmd, pooloptname, name, flag);    vshDebug(ctl, VSH_ERR_DEBUG, "%s: found option <%s>: %s/n",             cmd->def->name, optname, n);    if (name)        *name = n;    /* try it by name */    if (pool && (flag & VSH_BYNAME)) {        vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as vol name/n",                 cmd->def->name, optname);        vol = virStorageVolLookupByName(pool, n);    }    /* try it by key */    if (vol == NULL && (flag & VSH_BYUUID)) {        vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as vol key/n",                 cmd->def->name, optname);        vol = virStorageVolLookupByKey(ctl->conn, n);    }    /* try it by path */    if (vol == NULL && (flag & VSH_BYUUID)) {        vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as vol path/n",                 cmd->def->name, optname);        vol = virStorageVolLookupByPath(ctl->conn, n);    }    if (!vol) {        if (pool)            vshError(ctl, _("failed to get vol '%s'"), n);        else            vshError(ctl, _("failed to get vol '%s', specifying --%s "                            "might help"), n, pooloptname);    }    if (pool)        virStoragePoolFree(pool);    return vol;}
开发者ID:pdf,项目名称:libvirt,代码行数:59,


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


示例9: vshCommandOptSecret

static virSecretPtrvshCommandOptSecret(vshControl *ctl, const vshCmd *cmd, const char **name){    virSecretPtr secret = NULL;    const char *n = NULL;    const char *optname = "secret";    if (!vshCmdHasOption(ctl, cmd, optname))        return NULL;    if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0)        return NULL;    vshDebug(ctl, VSH_ERR_DEBUG,             "%s: found option <%s>: %s/n", cmd->def->name, optname, n);    if (name != NULL)        *name = n;    secret = virSecretLookupByUUIDString(ctl->conn, n);    if (secret == NULL)        vshError(ctl, _("failed to get secret '%s'"), n);    return secret;}
开发者ID:6WIND,项目名称:libvirt,代码行数:26,


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


示例12: vshAdmGetTimeStr

/* * vshAdmGetTimeStr: * * Produces string representation (local time) of @then * (seconds since epoch UTC) using format 'YYYY-MM-DD HH:MM:SS+ZZZZ'. * * Returns 0 if conversion finished successfully, -1 in case of an error. * Caller is responsible for freeing the string returned. */static intvshAdmGetTimeStr(vshControl *ctl, time_t then, char **result){    char *tmp = NULL;    struct tm timeinfo;    if (!localtime_r(&then, &timeinfo))        goto error;    if (VIR_ALLOC_N(tmp, VIRT_ADMIN_TIME_BUFLEN) < 0)        goto error;    if (strftime(tmp, VIRT_ADMIN_TIME_BUFLEN, "%Y-%m-%d %H:%M:%S%z",                 &timeinfo) == 0) {        VIR_FREE(tmp);        goto error;    }    *result = tmp;    return 0; error:    vshError(ctl, "%s", _("Timestamp string conversion failed"));    return -1;}
开发者ID:Archer-sys,项目名称:libvirt,代码行数:35,


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


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


示例15: cmdConnect

static boolcmdConnect(vshControl *ctl, const vshCmd *cmd){    bool ro = vshCommandOptBool(cmd, "readonly");    const char *name = NULL;    virshControlPtr priv = ctl->privData;    if (priv->conn) {        int ret;        virConnectUnregisterCloseCallback(priv->conn, virshCatchDisconnect);        ret = virConnectClose(priv->conn);        if (ret < 0)            vshError(ctl, "%s", _("Failed to disconnect from the hypervisor"));        else if (ret > 0)            vshError(ctl, "%s", _("One or more references were leaked after "                                  "disconnect from the hypervisor"));        priv->conn = NULL;    }    VIR_FREE(ctl->connname);    if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0)        return false;    ctl->connname = vshStrdup(ctl, name);    priv->useGetInfo = false;    priv->useSnapshotOld = false;    priv->blockJobNoBytes = false;    priv->readonly = ro;    priv->conn = virshConnect(ctl, ctl->connname, priv->readonly);    if (!priv->conn) {        vshError(ctl, "%s", _("Failed to connect to the hypervisor"));        return false;    }    if (virConnectRegisterCloseCallback(priv->conn, virshCatchDisconnect,                                        NULL, NULL) < 0)        vshError(ctl, "%s", _("Unable to register disconnect callback"));    return true;}
开发者ID:carriercomm,项目名称:libvirt,代码行数:44,


示例16: virshDeinit

/* * Deinitialize virsh */static boolvirshDeinit(vshControl *ctl){    virshControlPtr priv = ctl->privData;    vshDeinit(ctl);    VIR_FREE(ctl->connname);    if (priv->conn) {        int ret;        virConnectUnregisterCloseCallback(priv->conn, virshCatchDisconnect);        ret = virConnectClose(priv->conn);        if (ret < 0)            vshError(ctl, "%s", _("Failed to disconnect from the hypervisor"));        else if (ret > 0)            vshError(ctl, "%s", _("One or more references were leaked after "                                  "disconnect from the hypervisor"));    }    virResetLastError();    if (ctl->eventLoopStarted) {        int timer;        virMutexLock(&ctl->lock);        ctl->quit = true;        /* HACK: Add a dummy timeout to break event loop */        timer = virEventAddTimeout(0, virshDeinitTimer, NULL, NULL);        virMutexUnlock(&ctl->lock);        virThreadJoin(&ctl->eventLoop);        if (timer != -1)            virEventRemoveTimeout(timer);        if (ctl->eventTimerId != -1)            virEventRemoveTimeout(ctl->eventTimerId);        ctl->eventLoopStarted = false;    }    virMutexDestroy(&ctl->lock);    return true;}
开发者ID:carriercomm,项目名称:libvirt,代码行数:46,


示例17: vshAdmDisconnect

static intvshAdmDisconnect(vshControl *ctl){    int ret = 0;    vshAdmControlPtr priv = ctl->privData;    if (!priv->dmn)        return ret;    virAdmDaemonUnregisterCloseCallback(priv->dmn, vshAdmCatchDisconnect);    ret = virAdmDaemonClose(priv->dmn);    if (ret < 0)        vshError(ctl, "%s", _("Failed to disconnect from the admin server"));    else if (ret > 0)        vshError(ctl, "%s", _("One or more references were leaked after "                              "disconnect from the hypervisor"));    priv->dmn = NULL;    return ret;}
开发者ID:borisroman,项目名称:libvirt,代码行数:19,


示例18: 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 = virshCommandOptSecret(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;    }    vshPrintExtra(ctl, "%s", _("Secret value set/n"));    ret = true; cleanup:    virSecretFree(secret);    return ret;}
开发者ID:libvirt,项目名称:libvirt,代码行数:40,


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


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


示例21: virshConnectionUsability

static boolvirshConnectionUsability(vshControl *ctl, virConnectPtr conn){    if (!conn ||        virConnectIsAlive(conn) == 0) {        vshError(ctl, "%s", _("no valid connection"));        return false;    }    /* The connection is considered dead only if     * virConnectIsAlive() successfuly says so.     */    vshResetLibvirtError();    return true;}
开发者ID:carriercomm,项目名称:libvirt,代码行数:16,


示例22: virshReconnect

/* * virshReconnect: * * Reconnect after a disconnect from libvirtd * */static intvirshReconnect(vshControl *ctl, const char *name, bool readonly, bool force){    bool connected = false;    virshControlPtr priv = ctl->privData;    /* If the flag was not specified, then it depends on whether we are     * reconnecting to the current URI (in which case we want to keep the     * readonly flag as it was) or to a specified URI in which case it     * should stay false */    if (!readonly && !name)        readonly = priv->readonly;    if (priv->conn) {        int ret;        connected = true;        virConnectUnregisterCloseCallback(priv->conn, virshCatchDisconnect);        ret = virConnectClose(priv->conn);        if (ret < 0)            vshError(ctl, "%s", _("Failed to disconnect from the hypervisor"));        else if (ret > 0)            vshError(ctl, "%s", _("One or more references were leaked after "                                  "disconnect from the hypervisor"));    }    priv->conn = virshConnect(ctl, name ? name : ctl->connname, readonly);    if (!priv->conn) {        if (disconnected)            vshError(ctl, "%s", _("Failed to reconnect to the hypervisor"));        else            vshError(ctl, "%s", _("failed to connect to the hypervisor"));        return -1;    } else {        if (name) {            VIR_FREE(ctl->connname);            ctl->connname = vshStrdup(ctl, name);        }        priv->readonly = readonly;        if (virConnectRegisterCloseCallback(priv->conn, virshCatchDisconnect,                                            ctl, NULL) < 0)            vshError(ctl, "%s", _("Unable to register disconnect callback"));        if (connected && !force)            vshError(ctl, "%s", _("Reconnected to the hypervisor"));    }    disconnected = 0;    priv->useGetInfo = false;    priv->useSnapshotOld = false;    priv->blockJobNoBytes = false;    return 0;}
开发者ID:libvirt,项目名称:libvirt,代码行数:60,


示例23: vshCommandOptInterfaceBy

virInterfacePtrvshCommandOptInterfaceBy(vshControl *ctl, const vshCmd *cmd,                         const char *optname,                         const char **name, unsigned int flags){    virInterfacePtr iface = NULL;    const char *n = NULL;    bool is_mac = false;    virMacAddr dummy;    virCheckFlags(VSH_BYNAME | VSH_BYMAC, NULL);    if (!optname)       optname = "interface";    if (!vshCmdHasOption(ctl, cmd, optname))        return NULL;    if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0)        return NULL;    vshDebug(ctl, VSH_ERR_INFO, "%s: found option <%s>: %s/n",             cmd->def->name, optname, n);    if (name)        *name = n;    if (virMacAddrParse(n, &dummy) == 0)        is_mac = true;    /* try it by NAME */    if (!is_mac && (flags & VSH_BYNAME)) {        vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as interface NAME/n",                 cmd->def->name, optname);        iface = virInterfaceLookupByName(ctl->conn, n);    /* try it by MAC */    } else if (is_mac && (flags & VSH_BYMAC)) {        vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as interface MAC/n",                 cmd->def->name, optname);        iface = virInterfaceLookupByMACString(ctl->conn, n);    }    if (!iface)        vshError(ctl, _("failed to get interface '%s'"), n);    return iface;}
开发者ID:cardoe,项目名称:libvirt,代码行数:46,


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


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


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


示例27: vshAdmCatchDisconnect

/* * vshAdmCatchDisconnect: * * We get here when the connection was closed. Unlike virsh, we do not save * the fact that the event was raised, sice there is virAdmConnectIsAlive to * check if the communication channel has not been closed by remote party. */static voidvshAdmCatchDisconnect(virAdmConnectPtr conn ATTRIBUTE_UNUSED,                      int reason,                      void *opaque){    vshControl *ctl = opaque;    const char *str = "unknown reason";    virErrorPtr error;    char *uri = NULL;    if (reason == VIR_CONNECT_CLOSE_REASON_CLIENT)        return;    error = virSaveLastError();    uri = virAdmConnectGetURI(conn);    switch ((virConnectCloseReason) reason) {    case VIR_CONNECT_CLOSE_REASON_ERROR:        str = N_("Disconnected from %s due to I/O error");        break;    case VIR_CONNECT_CLOSE_REASON_EOF:        str = N_("Disconnected from %s due to end of file");        break;    case VIR_CONNECT_CLOSE_REASON_KEEPALIVE:        str = N_("Disconnected from %s due to keepalive timeout");        break;        /* coverity[dead_error_condition] */    case VIR_CONNECT_CLOSE_REASON_CLIENT:    case VIR_CONNECT_CLOSE_REASON_LAST:        break;    }    vshError(ctl, _(str), NULLSTR(uri));    VIR_FREE(uri);    if (error) {        virSetError(error);        virFreeError(error);    }}
开发者ID:Archer-sys,项目名称:libvirt,代码行数:47,


示例28: cmdSecretUndefine

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


示例29: vshCommandOptNetworkBy

virNetworkPtrvshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd,                       const char **name, unsigned int flags){    virNetworkPtr network = NULL;    const char *n = NULL;    const char *optname = "network";    virCheckFlags(VSH_BYUUID | VSH_BYNAME, NULL);    if (!vshCmdHasOption(ctl, cmd, optname))        return NULL;    if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0)        return NULL;    vshDebug(ctl, VSH_ERR_INFO, "%s: found option <%s>: %s/n",             cmd->def->name, optname, n);    if (name)        *name = n;    /* try it by UUID */    if ((flags & VSH_BYUUID) && strlen(n) == VIR_UUID_STRING_BUFLEN-1) {        vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as network UUID/n",                 cmd->def->name, optname);        network = virNetworkLookupByUUIDString(ctl->conn, n);    }    /* try it by NAME */    if (!network && (flags & VSH_BYNAME)) {        vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as network NAME/n",                 cmd->def->name, optname);        network = virNetworkLookupByName(ctl->conn, n);    }    if (!network)        vshError(ctl, _("failed to get network '%s'"), n);    return network;}
开发者ID:aurex-linux,项目名称:libvirt,代码行数:39,


示例30: virshConnect

/* Main Function which should be used for connecting. * This function properly handles keepalive settings. */virConnectPtrvirshConnect(vshControl *ctl, const char *uri, bool readonly){    virConnectPtr c = NULL;    int interval = 5; /* Default */    int count = 6;    /* Default */    bool keepalive_forced = false;    if (ctl->keepalive_interval >= 0) {        interval = ctl->keepalive_interval;        keepalive_forced = true;    }    if (ctl->keepalive_count >= 0) {        count = ctl->keepalive_count;        keepalive_forced = true;    }    c = virConnectOpenAuth(uri, virConnectAuthPtrDefault,                           readonly ? VIR_CONNECT_RO : 0);    if (!c)        return NULL;    if (interval > 0 &&        virConnectSetKeepAlive(c, interval, count) != 0) {        if (keepalive_forced) {            vshError(ctl, "%s",                     _("Cannot setup keepalive on connection "                       "as requested, disconnecting"));            virConnectClose(c);            return NULL;        }        vshDebug(ctl, VSH_ERR_INFO, "%s",                 _("Failed to setup keepalive on connection/n"));    }    return c;}
开发者ID:carriercomm,项目名称:libvirt,代码行数:39,



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


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