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

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

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

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

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

示例1: virNodeDeviceDefParseXML

static virNodeDeviceDefPtrvirNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, int create){    virNodeDeviceDefPtr def;    virNodeDevCapsDefPtr *next_cap;    xmlNodePtr *nodes;    int n, i;    if (VIR_ALLOC(def) < 0) {        virReportOOMError();        return NULL;    }    /* Extract device name */    if (create == EXISTING_DEVICE) {        def->name = virXPathString("string(./name[1])", ctxt);        if (!def->name) {            virNodeDeviceReportError(VIR_ERR_NO_NAME, NULL);            goto error;        }    } else {        def->name = strdup("new device");        if (!def->name) {            virReportOOMError();            goto error;        }    }    /* Extract device parent, if any */    def->parent = virXPathString("string(./parent[1])", ctxt);    /* Parse device capabilities */    nodes = NULL;    if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) <= 0) {        virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR,                                 _("no device capabilities for '%s'"),                                 def->name);        goto error;    }    next_cap = &def->caps;    for (i = 0 ; i < n ; i++) {        *next_cap = virNodeDevCapsDefParseXML(ctxt, def, nodes[i], create);        if (!*next_cap) {            VIR_FREE(nodes);            goto error;        }        next_cap = &(*next_cap)->next;    }    VIR_FREE(nodes);    return def; error:    virNodeDeviceDefFree(def);    return NULL;}
开发者ID:hjwsm1989,项目名称:libvirt,代码行数:60,


示例2: virStorageEncryptionSecretParse

static virStorageEncryptionSecretPtrvirStorageEncryptionSecretParse(xmlXPathContextPtr ctxt,                                xmlNodePtr node){    xmlNodePtr old_node;    virStorageEncryptionSecretPtr ret;    char *type_str;    int type;    char *uuidstr = NULL;    if (VIR_ALLOC(ret) < 0) {        virReportOOMError();        return NULL;    }    old_node = ctxt->node;    ctxt->node = node;    type_str = virXPathString("string(./@type)", ctxt);    if (type_str == NULL) {        virReportError(VIR_ERR_XML_ERROR, "%s",                       _("unknown volume encryption secret type"));        goto cleanup;    }    type = virStorageEncryptionSecretTypeTypeFromString(type_str);    if (type < 0) {        virReportError(VIR_ERR_XML_ERROR,                       _("unknown volume encryption secret type %s"),                       type_str);        VIR_FREE(type_str);        goto cleanup;    }    VIR_FREE(type_str);    ret->type = type;    uuidstr = virXPathString("string(./@uuid)", ctxt);    if (uuidstr) {        if (virUUIDParse(uuidstr, ret->uuid) < 0) {            virReportError(VIR_ERR_XML_ERROR,                           _("malformed volume encryption uuid '%s'"),                           uuidstr);            goto cleanup;        }        VIR_FREE(uuidstr);    } else {        virReportError(VIR_ERR_XML_ERROR, "%s",                       _("missing volume encryption uuid"));        goto cleanup;    }    ctxt->node = old_node;    return ret;  cleanup:    virStorageEncryptionSecretFree(ret);    VIR_FREE(uuidstr);    ctxt->node = old_node;    return NULL;}
开发者ID:bigclouds,项目名称:libvirt,代码行数:58,


示例3: virNodeDevCapPciDevParseXML

static intvirNodeDevCapPciDevParseXML(xmlXPathContextPtr ctxt,                            virNodeDeviceDefPtr def,                            xmlNodePtr node,                            union _virNodeDevCapData *data){    xmlNodePtr orignode;    int ret = -1;    orignode = ctxt->node;    ctxt->node = node;    if (virNodeDevCapsDefParseULong("number(./domain[1])", ctxt,                                    &data->pci_dev.domain, def,                                    _("no PCI domain ID supplied for '%s'"),                                    _("invalid PCI domain ID supplied for '%s'")) < 0)        goto out;    if (virNodeDevCapsDefParseULong("number(./bus[1])", ctxt,                                    &data->pci_dev.bus, def,                                    _("no PCI bus ID supplied for '%s'"),                                    _("invalid PCI bus ID supplied for '%s'")) < 0)        goto out;    if (virNodeDevCapsDefParseULong("number(./slot[1])", ctxt,                                    &data->pci_dev.slot, def,                                    _("no PCI slot ID supplied for '%s'"),                                    _("invalid PCI slot ID supplied for '%s'")) < 0)        goto out;    if (virNodeDevCapsDefParseULong("number(./function[1])", ctxt,                                    &data->pci_dev.function, def,                                    _("no PCI function ID supplied for '%s'"),                                    _("invalid PCI function ID supplied for '%s'")) < 0)        goto out;    if (virNodeDevCapsDefParseHexId("string(./vendor[1]/@id)", ctxt,                                    &data->pci_dev.vendor, def,                                    _("no PCI vendor ID supplied for '%s'"),                                    _("invalid PCI vendor ID supplied for '%s'")) < 0)        goto out;    if (virNodeDevCapsDefParseHexId("string(./product[1]/@id)", ctxt,                                    &data->pci_dev.product, def,                                    _("no PCI product ID supplied for '%s'"),                                    _("invalid PCI product ID supplied for '%s'")) < 0)        goto out;    data->pci_dev.vendor_name  = virXPathString("string(./vendor[1])", ctxt);    data->pci_dev.product_name = virXPathString("string(./product[1])", ctxt);    ret = 0;out:    ctxt->node = orignode;    return ret;}
开发者ID:hjwsm1989,项目名称:libvirt,代码行数:56,


示例4: virInterfaceDefParseDhcp

static intvirInterfaceDefParseDhcp(virInterfaceProtocolDefPtr def,                         xmlNodePtr dhcp, xmlXPathContextPtr ctxt) {    xmlNodePtr save;    char *tmp;    int ret = 0;    def->dhcp = 1;    save = ctxt->node;    ctxt->node = dhcp;    /* Not much to do in the current version */    tmp = virXPathString("string(./@peerdns)", ctxt);    if (tmp) {        if (STREQ(tmp, "yes"))            def->peerdns = 1;        else if (STREQ(tmp, "no"))            def->peerdns = 0;        else {            virInterfaceReportError(VIR_ERR_XML_ERROR,                              _("unknown dhcp peerdns value %s"), tmp);            ret = -1;        }        VIR_FREE(tmp);    } else        def->peerdns = -1;    ctxt->node = save;    return ret;}
开发者ID:foomango,项目名称:libvirt,代码行数:29,


示例5: virInterfaceDefParseBondMode

static intvirInterfaceDefParseBondMode(xmlXPathContextPtr ctxt) {    char *tmp;    int ret = 0;    tmp = virXPathString("string(./@mode)", ctxt);    if (tmp == NULL)        return VIR_INTERFACE_BOND_NONE;    if (STREQ(tmp, "balance-rr"))        ret = VIR_INTERFACE_BOND_BALRR;    else if (STREQ(tmp, "active-backup"))        ret = VIR_INTERFACE_BOND_ABACKUP;    else if (STREQ(tmp, "balance-xor"))        ret = VIR_INTERFACE_BOND_BALXOR;    else if (STREQ(tmp, "broadcast"))        ret = VIR_INTERFACE_BOND_BCAST;    else if (STREQ(tmp, "802.3ad"))        ret = VIR_INTERFACE_BOND_8023AD;    else if (STREQ(tmp, "balance-tlb"))        ret = VIR_INTERFACE_BOND_BALTLB;    else if (STREQ(tmp, "balance-alb"))        ret = VIR_INTERFACE_BOND_BALALB;    else {        virInterfaceReportError(VIR_ERR_XML_ERROR,                                _("unknown bonding mode %s"), tmp);        ret = -1;    }    VIR_FREE(tmp);    return ret;}
开发者ID:foomango,项目名称:libvirt,代码行数:30,


示例6: virNodeDevCapScsiTargetParseXML

static intvirNodeDevCapScsiTargetParseXML(xmlXPathContextPtr ctxt,                                virNodeDeviceDefPtr def,                                xmlNodePtr node,                                union _virNodeDevCapData *data){    xmlNodePtr orignode;    int ret = -1;    orignode = ctxt->node;    ctxt->node = node;    data->scsi_target.name = virXPathString("string(./name[1])", ctxt);    if (!data->scsi_target.name) {        virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR,                                 _("no target name supplied for '%s'"),                                 def->name);        goto out;    }    ret = 0;out:    ctxt->node = orignode;    return ret;}
开发者ID:hjwsm1989,项目名称:libvirt,代码行数:26,


示例7: ppc64VendorParse

static struct ppc64_vendor *ppc64VendorParse(xmlXPathContextPtr ctxt,                 struct ppc64_map *map){    struct ppc64_vendor *vendor;    if (VIR_ALLOC(vendor) < 0)        return NULL;    vendor->name = virXPathString("string(@name)", ctxt);    if (!vendor->name) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       "%s", _("Missing CPU vendor name"));        goto error;    }    if (ppc64VendorFind(map, vendor->name)) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       _("CPU vendor %s already defined"), vendor->name);        goto error;    }    return vendor; error:    ppc64VendorFree(vendor);    return NULL;}
开发者ID:MountainWei,项目名称:libvirt,代码行数:28,


示例8: qemuMigrationCookieGraphicsXMLParse

static qemuMigrationCookieGraphicsPtrqemuMigrationCookieGraphicsXMLParse(xmlXPathContextPtr ctxt){    qemuMigrationCookieGraphicsPtr grap;    char *tmp;    if (VIR_ALLOC(grap) < 0)        goto error;    if (!(tmp = virXPathString("string(./graphics/@type)", ctxt))) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       "%s", _("missing type attribute in migration data"));        goto error;    }    if ((grap->type = virDomainGraphicsTypeFromString(tmp)) < 0) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       _("unknown graphics type %s"), tmp);        VIR_FREE(tmp);        goto error;    }    VIR_FREE(tmp);    if (virXPathInt("string(./graphics/@port)", ctxt, &grap->port) < 0) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       "%s", _("missing port attribute in migration data"));        goto error;    }    if (grap->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {        if (virXPathInt("string(./graphics/@tlsPort)", ctxt, &grap->tlsPort) < 0) {            virReportError(VIR_ERR_INTERNAL_ERROR,                           "%s", _("missing tlsPort attribute in migration data"));            goto error;        }    }    if (!(grap->listen = virXPathString("string(./graphics/@listen)", ctxt))) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       "%s", _("missing listen attribute in migration data"));        goto error;    }    /* Optional */    grap->tlsSubject = virXPathString("string(./graphics/cert[@info='subject']/@value)", ctxt);    return grap; error:    qemuMigrationCookieGraphicsFree(grap);    return NULL;}
开发者ID:RWTH-OS,项目名称:libvirt,代码行数:47,


示例9: virInterfaceDefParseProtoIPv6

static intvirInterfaceDefParseProtoIPv6(virInterfaceProtocolDefPtr def,                              xmlXPathContextPtr ctxt) {    xmlNodePtr dhcp, autoconf;    xmlNodePtr *ipNodes = NULL;    int nIpNodes, ii, ret = -1;    char *tmp;    tmp = virXPathString("string(./route[1]/@gateway)", ctxt);    def->gateway = tmp;    autoconf = virXPathNode("./autoconf", ctxt);    if (autoconf != NULL)        def->autoconf = 1;    dhcp = virXPathNode("./dhcp", ctxt);    if (dhcp != NULL) {        ret = virInterfaceDefParseDhcp(def, dhcp, ctxt);        if (ret != 0)           return ret;    }    nIpNodes = virXPathNodeSet("./ip", ctxt, &ipNodes);    if (nIpNodes < 0)        return -1;    if (ipNodes == NULL)        return 0;    if (VIR_ALLOC_N(def->ips, nIpNodes) < 0) {        virReportOOMError();        goto error;    }    def->nips = 0;    for (ii = 0; ii < nIpNodes; ii++) {        virInterfaceIpDefPtr ip;        if (VIR_ALLOC(ip) < 0) {            virReportOOMError();            goto error;        }        ctxt->node = ipNodes[ii];        ret = virInterfaceDefParseIp(ip, ctxt);        if (ret != 0) {            virInterfaceIpDefFree(ip);            goto error;        }        def->ips[def->nips++] = ip;    }    ret = 0;error:    VIR_FREE(ipNodes);    return ret;}
开发者ID:foomango,项目名称:libvirt,代码行数:58,


示例10: virNodeDevCapUsbDevParseXML

static intvirNodeDevCapUsbDevParseXML(xmlXPathContextPtr ctxt,                            virNodeDeviceDefPtr def,                            xmlNodePtr node,                            union _virNodeDevCapData *data){    xmlNodePtr orignode;    int ret = -1;    orignode = ctxt->node;    ctxt->node = node;    if (virNodeDevCapsDefParseULong("number(./bus[1])", ctxt,                                    &data->usb_dev.bus, def,                                    _("no USB bus number supplied for '%s'"),                                    _("invalid USB bus number supplied for '%s'")) < 0)        goto out;    if (virNodeDevCapsDefParseULong("number(./device[1])", ctxt,                                    &data->usb_dev.device, def,                                    _("no USB device number supplied for '%s'"),                                    _("invalid USB device number supplied for '%s'")) < 0)        goto out;    if (virNodeDevCapsDefParseHexId("string(./vendor[1]/@id)", ctxt,                                    &data->usb_dev.vendor, def,                                    _("no USB vendor ID supplied for '%s'"),                                    _("invalid USB vendor ID supplied for '%s'")) < 0)        goto out;    if (virNodeDevCapsDefParseHexId("string(./product[1]/@id)", ctxt,                                    &data->usb_dev.product, def,                                    _("no USB product ID supplied for '%s'"),                                    _("invalid USB product ID supplied for '%s'")) < 0)        goto out;    data->usb_dev.vendor_name  = virXPathString("string(./vendor[1])", ctxt);    data->usb_dev.product_name = virXPathString("string(./product[1])", ctxt);    ret = 0;out:    ctxt->node = orignode;    return ret;}
开发者ID:hjwsm1989,项目名称:libvirt,代码行数:44,


示例11: virInterfaceDefParseVlan

static intvirInterfaceDefParseVlan(virInterfaceDefPtr def,                         xmlXPathContextPtr ctxt) {    def->data.vlan.tag = virXPathString("string(./@tag)", ctxt);    if (def->data.vlan.tag == NULL) {        virInterfaceReportError(VIR_ERR_XML_ERROR,                    "%s", _("vlan interface misses the tag attribute"));        return -1;    }    def->data.vlan.devname =         virXPathString("string(./interface/@name)", ctxt);    if (def->data.vlan.devname == NULL) {        virInterfaceReportError(VIR_ERR_XML_ERROR,                    "%s", _("vlan interface misses name attribute"));        return -1;    }    return 0;}
开发者ID:foomango,项目名称:libvirt,代码行数:19,


示例12: virNodeDevCapNetParseXML

static intvirNodeDevCapNetParseXML(xmlXPathContextPtr ctxt,                         virNodeDeviceDefPtr def,                         xmlNodePtr node,                         union _virNodeDevCapData *data){    xmlNodePtr orignode;    int ret = -1;    char *tmp;    orignode = ctxt->node;    ctxt->node = node;    data->net.ifname = virXPathString("string(./interface[1])", ctxt);    if (!data->net.ifname) {        virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR,                                 _("no network interface supplied for '%s'"),                                 def->name);        goto out;    }    data->net.address = virXPathString("string(./address[1])", ctxt);    data->net.subtype = VIR_NODE_DEV_CAP_NET_LAST;    tmp = virXPathString("string(./capability/@type)", ctxt);    if (tmp) {        int val = virNodeDevNetCapTypeFromString(tmp);        VIR_FREE(tmp);        if (val < 0) {            virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR,                                     _("invalid network type supplied for '%s'"),                                     def->name);            goto out;        }        data->net.subtype = val;    }    ret = 0;out:    ctxt->node = orignode;    return ret;}
开发者ID:hjwsm1989,项目名称:libvirt,代码行数:43,


示例13: libxlDomainObjPrivateXMLParse

static intlibxlDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,                              virDomainObjPtr vm,                              virDomainDefParserConfigPtr config ATTRIBUTE_UNUSED){    libxlDomainObjPrivatePtr priv = vm->privateData;    priv->lockState = virXPathString("string(./lockstate)", ctxt);    return 0;}
开发者ID:FrankYu,项目名称:libvirt,代码行数:11,


示例14: virStorageEncryptionParseXML

static virStorageEncryptionPtrvirStorageEncryptionParseXML(xmlXPathContextPtr ctxt){    xmlNodePtr *nodes = NULL;    virStorageEncryptionPtr ret;    char *format_str;    int format, i, n;    if (VIR_ALLOC(ret) < 0) {        virReportOOMError();        return NULL;    }    format_str = virXPathString("string(./@format)", ctxt);    if (format_str == NULL) {        virReportError(VIR_ERR_XML_ERROR, "%s",                       _("unknown volume encryption format"));        goto cleanup;    }    format = virStorageEncryptionFormatTypeFromString(format_str);    if (format < 0) {        virReportError(VIR_ERR_XML_ERROR,                       _("unknown volume encryption format type %s"),                       format_str);        VIR_FREE(format_str);        goto cleanup;    }    VIR_FREE(format_str);    ret->format = format;    n = virXPathNodeSet("./secret", ctxt, &nodes);    if (n < 0){        goto cleanup;    }    if (n != 0 && VIR_ALLOC_N(ret->secrets, n) < 0) {        virReportOOMError();        goto cleanup;    }    ret->nsecrets = n;    for (i = 0; i < n; i++) {        ret->secrets[i] = virStorageEncryptionSecretParse(ctxt, nodes[i]);        if (ret->secrets[i] == NULL)            goto cleanup;    }    VIR_FREE(nodes);    return ret;  cleanup:    VIR_FREE(nodes);    virStorageEncryptionFree(ret);    return NULL;}
开发者ID:bigclouds,项目名称:libvirt,代码行数:53,


示例15: virStorageEncryptionParseXML

static virStorageEncryptionPtrvirStorageEncryptionParseXML(xmlXPathContextPtr ctxt){    xmlNodePtr *nodes = NULL;    virStorageEncryptionPtr ret;    char *format_str = NULL;    int n;    size_t i;    if (VIR_ALLOC(ret) < 0)        return NULL;    if (!(format_str = virXPathString("string(./@format)", ctxt))) {        virReportError(VIR_ERR_XML_ERROR, "%s",                       _("unknown volume encryption format"));        goto cleanup;    }    if ((ret->format =         virStorageEncryptionFormatTypeFromString(format_str)) < 0) {        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,                       _("unknown volume encryption format type %s"),                       format_str);        goto cleanup;    }    VIR_FREE(format_str);    if ((n = virXPathNodeSet("./secret", ctxt, &nodes)) < 0)        goto cleanup;    if (n > 0) {        if (VIR_ALLOC_N(ret->secrets, n) < 0)            goto cleanup;        ret->nsecrets = n;        for (i = 0; i < n; i++) {            if (!(ret->secrets[i] =                  virStorageEncryptionSecretParse(ctxt, nodes[i])))                goto cleanup;        }        VIR_FREE(nodes);    }    return ret; cleanup:    VIR_FREE(format_str);    VIR_FREE(nodes);    virStorageEncryptionFree(ret);    return NULL;}
开发者ID:JGulic,项目名称:libvirt,代码行数:51,


示例16: virInterfaceDefParseName

static intvirInterfaceDefParseName(virInterfaceDefPtr def,                         xmlXPathContextPtr ctxt) {    char *tmp;    tmp = virXPathString("string(./@name)", ctxt);    if (tmp == NULL) {        virInterfaceReportError(VIR_ERR_XML_ERROR,                                "%s",  _("interface has no name"));        return -1;    }    def->name = tmp;    return 0;}
开发者ID:foomango,项目名称:libvirt,代码行数:14,


示例17: virInterfaceDefParseProtoIPv4

static intvirInterfaceDefParseProtoIPv4(virInterfaceProtocolDefPtr def,                              xmlXPathContextPtr ctxt) {    xmlNodePtr dhcp;    xmlNodePtr *ipNodes = NULL;    int nIpNodes, ret = -1;    size_t i;    char *tmp;    tmp = virXPathString("string(./route[1]/@gateway)", ctxt);    def->gateway = tmp;    dhcp = virXPathNode("./dhcp", ctxt);    if (dhcp != NULL) {        if (virInterfaceDefParseDhcp(def, dhcp, ctxt) < 0)            return -1;    }    nIpNodes = virXPathNodeSet("./ip", ctxt, &ipNodes);    if (nIpNodes < 0)        return -1;    if (ipNodes == NULL)        return 0;    if (VIR_ALLOC_N(def->ips, nIpNodes) < 0)        goto error;    def->nips = 0;    for (i = 0; i < nIpNodes; i++) {        virInterfaceIpDefPtr ip;        if (VIR_ALLOC(ip) < 0)            goto error;        ctxt->node = ipNodes[i];        if (virInterfaceDefParseIp(ip, ctxt) < 0) {            virInterfaceIpDefFree(ip);            goto error;        }        def->ips[def->nips++] = ip;    }    ret = 0;error:    VIR_FREE(ipNodes);    return ret;}
开发者ID:ISI-apex,项目名称:libvirt-ARM,代码行数:49,


示例18: qemuMigrationCookieNetworkXMLParse

static qemuMigrationCookieNetworkPtrqemuMigrationCookieNetworkXMLParse(xmlXPathContextPtr ctxt){    qemuMigrationCookieNetworkPtr optr;    size_t i;    int n;    xmlNodePtr *interfaces = NULL;    char *vporttype;    xmlNodePtr save_ctxt = ctxt->node;    if (VIR_ALLOC(optr) < 0)        goto error;    if ((n = virXPathNodeSet("./network/interface", ctxt, &interfaces)) < 0) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       "%s", _("missing interface information"));        goto error;    }    optr->nnets = n;    if (VIR_ALLOC_N(optr->net, optr->nnets) < 0)        goto error;    for (i = 0; i < n; i++) {        /* portdata is optional, and may not exist */        ctxt->node = interfaces[i];        optr->net[i].portdata = virXPathString("string(./portdata[1])", ctxt);        if (!(vporttype = virXMLPropString(interfaces[i], "vporttype"))) {            virReportError(VIR_ERR_INTERNAL_ERROR,                           "%s", _("missing vporttype attribute in migration data"));            goto error;        }        optr->net[i].vporttype = virNetDevVPortTypeFromString(vporttype);    }    VIR_FREE(interfaces); cleanup:    ctxt->node = save_ctxt;    return optr; error:    VIR_FREE(interfaces);    qemuMigrationCookieNetworkFree(optr);    optr = NULL;    goto cleanup;}
开发者ID:RWTH-OS,项目名称:libvirt,代码行数:48,


示例19: virXPathStringLimit

/** * virXPathStringLimit: * @xpath: the XPath string to evaluate * @maxlen: maximum length permittred string * @ctxt: an XPath context * * Wrapper for virXPathString, which validates the length of the returned * string. * * Returns a new string which must be deallocated by the caller or NULL if * the evaluation failed. */char *virXPathStringLimit(const char *xpath,                    size_t maxlen,                    xmlXPathContextPtr ctxt){    char *tmp = virXPathString(xpath, ctxt);    if (tmp != NULL && strlen(tmp) >= maxlen) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       _("/'%s/' value longer than %zu bytes"),                       xpath, maxlen);        VIR_FREE(tmp);        return NULL;    }    return tmp;}
开发者ID:hzguanqiang,项目名称:libvirt,代码行数:29,


示例20: virNodeDevCapSystemParseXML

static intvirNodeDevCapSystemParseXML(xmlXPathContextPtr ctxt,                            virNodeDeviceDefPtr def,                            xmlNodePtr node,                            union _virNodeDevCapData *data){    xmlNodePtr orignode;    int ret = -1;    char *tmp;    orignode = ctxt->node;    ctxt->node = node;    data->system.product_name = virXPathString("string(./product[1])", ctxt);    data->system.hardware.vendor_name = virXPathString("string(./hardware/vendor[1])", ctxt);    data->system.hardware.version     = virXPathString("string(./hardware/version[1])", ctxt);    data->system.hardware.serial      = virXPathString("string(./hardware/serial[1])", ctxt);    tmp = virXPathString("string(./hardware/uuid[1])", ctxt);    if (!tmp) {        virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR,                                 _("no system UUID supplied for '%s'"), def->name);        goto out;    }    if (virUUIDParse(tmp, data->system.hardware.uuid) < 0) {        virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR,                                 _("malformed uuid element for '%s'"), def->name);        VIR_FREE(tmp);        goto out;    }    VIR_FREE(tmp);    data->system.firmware.vendor_name  = virXPathString("string(./firmware/vendor[1])", ctxt);    data->system.firmware.version      = virXPathString("string(./firmware/version[1])", ctxt);    data->system.firmware.release_date = virXPathString("string(./firmware/release_date[1])", ctxt);    ret = 0;out:    ctxt->node = orignode;    return ret;}
开发者ID:hjwsm1989,项目名称:libvirt,代码行数:43,


示例21: virStorageEncryptionSecretParse

static virStorageEncryptionSecretPtrvirStorageEncryptionSecretParse(xmlXPathContextPtr ctxt,                                xmlNodePtr node){    xmlNodePtr old_node;    virStorageEncryptionSecretPtr ret;    char *type_str = NULL;    char *uuidstr = NULL;    char *usagestr = NULL;    if (VIR_ALLOC(ret) < 0)        return NULL;    old_node = ctxt->node;    ctxt->node = node;    if (!(type_str = virXPathString("string(./@type)", ctxt))) {        virReportError(VIR_ERR_XML_ERROR, "%s",                       _("unknown volume encryption secret type"));        goto cleanup;    }    if ((ret->type = virStorageEncryptionSecretTypeFromString(type_str)) < 0) {        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,                       _("unknown volume encryption secret type %s"),                       type_str);        goto cleanup;    }    if (virSecretLookupParseSecret(node, &ret->seclookupdef) < 0)        goto cleanup;    VIR_FREE(type_str);    ctxt->node = old_node;    return ret; cleanup:    VIR_FREE(type_str);    virStorageEncryptionSecretFree(ret);    VIR_FREE(uuidstr);    VIR_FREE(usagestr);    ctxt->node = old_node;    return NULL;}
开发者ID:Lantame,项目名称:libvirt,代码行数:45,


示例22: virNodeDevCapUsbInterfaceParseXML

static intvirNodeDevCapUsbInterfaceParseXML(xmlXPathContextPtr ctxt,                                  virNodeDeviceDefPtr def,                                  xmlNodePtr node,                                  union _virNodeDevCapData *data){    xmlNodePtr orignode;    int ret = -1;    orignode = ctxt->node;    ctxt->node = node;    if (virNodeDevCapsDefParseULong("number(./number[1])", ctxt,                                    &data->usb_if.number, def,                                    _("no USB interface number supplied for '%s'"),                                    _("invalid USB interface number supplied for '%s'")) < 0)        goto out;    if (virNodeDevCapsDefParseULong("number(./class[1])", ctxt,                                    &data->usb_if._class, def,                                    _("no USB interface class supplied for '%s'"),                                    _("invalid USB interface class supplied for '%s'")) < 0)        goto out;    if (virNodeDevCapsDefParseULong("number(./subclass[1])", ctxt,                                    &data->usb_if.subclass, def,                                    _("no USB interface subclass supplied for '%s'"),                                    _("invalid USB interface subclass supplied for '%s'")) < 0)        goto out;    if (virNodeDevCapsDefParseULong("number(./protocol[1])", ctxt,                                    &data->usb_if.protocol, def,                                    _("no USB interface protocol supplied for '%s'"),                                    _("invalid USB interface protocol supplied for '%s'")) < 0)        goto out;    data->usb_if.description = virXPathString("string(./description[1])", ctxt);    ret = 0;out:    ctxt->node = orignode;    return ret;}
开发者ID:hjwsm1989,项目名称:libvirt,代码行数:43,


示例23: virNodeDevCapScsiParseXML

static intvirNodeDevCapScsiParseXML(xmlXPathContextPtr ctxt,                          virNodeDeviceDefPtr def,                          xmlNodePtr node,                          union _virNodeDevCapData *data){    xmlNodePtr orignode;    int ret = -1;    orignode = ctxt->node;    ctxt->node = node;    if (virNodeDevCapsDefParseULong("number(./host[1])", ctxt,                                    &data->scsi.host, def,                                    _("no SCSI host ID supplied for '%s'"),                                    _("invalid SCSI host ID supplied for '%s'")) < 0)        goto out;    if (virNodeDevCapsDefParseULong("number(./bus[1])", ctxt,                                    &data->scsi.bus, def,                                    _("no SCSI bus ID supplied for '%s'"),                                    _("invalid SCSI bus ID supplied for '%s'")) < 0)        goto out;    if (virNodeDevCapsDefParseULong("number(./target[1])", ctxt,                                    &data->scsi.target, def,                                    _("no SCSI target ID supplied for '%s'"),                                    _("invalid SCSI target ID supplied for '%s'")) < 0)        goto out;    if (virNodeDevCapsDefParseULong("number(./lun[1])", ctxt,                                    &data->scsi.lun, def,                                    _("no SCSI LUN ID supplied for '%s'"),                                    _("invalid SCSI LUN ID supplied for '%s'")) < 0)        goto out;    data->scsi.type = virXPathString("string(./type[1])", ctxt);    ret = 0;out:    ctxt->node = orignode;    return ret;}
开发者ID:hjwsm1989,项目名称:libvirt,代码行数:43,


示例24: virNodeDevCapsDefParseString

static intvirNodeDevCapsDefParseString(const char *xpath,                             xmlXPathContextPtr ctxt,                             char **string,                             virNodeDeviceDefPtr def,                             const char *missing_error_fmt){    char *s;    s = virXPathString(xpath, ctxt);    if (s == NULL) {        virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR,                                 missing_error_fmt,                                 def->name);        return -1;    }    *string = s;    return 0;}
开发者ID:hjwsm1989,项目名称:libvirt,代码行数:20,


示例25: virInterfaceDefParseBondMiiCarrier

static intvirInterfaceDefParseBondMiiCarrier(xmlXPathContextPtr ctxt) {    char *tmp;    int ret = 0;    tmp = virXPathString("string(./miimon/@carrier)", ctxt);    if (tmp == NULL)        return VIR_INTERFACE_BOND_MII_NONE;    if (STREQ(tmp, "ioctl"))        ret = VIR_INTERFACE_BOND_MII_IOCTL;    else if (STREQ(tmp, "netif"))        ret = VIR_INTERFACE_BOND_MII_NETIF;    else {        virInterfaceReportError(VIR_ERR_XML_ERROR,                                _("unknown mii bonding carrier %s"), tmp);        ret = -1;    }    VIR_FREE(tmp);    return ret;}
开发者ID:foomango,项目名称:libvirt,代码行数:20,


示例26: virCPUDataParse

/** * virCPUDataParse: * * @xmlStr: XML string produced by virCPUDataFormat * * Parses XML representation of virCPUData structure for test purposes. * * Returns internal CPU data structure parsed from the XML or NULL on error. */virCPUDataPtrvirCPUDataParse(const char *xmlStr){    struct cpuArchDriver *driver;    xmlDocPtr xml = NULL;    xmlXPathContextPtr ctxt = NULL;    virCPUDataPtr data = NULL;    char *arch = NULL;    VIR_DEBUG("xmlStr=%s", xmlStr);    if (!(xml = virXMLParseStringCtxt(xmlStr, _("CPU data"), &ctxt))) {        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",                       _("cannot parse CPU data"));        goto cleanup;    }    if (!(arch = virXPathString("string(/cpudata/@arch)", ctxt))) {        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",                       _("missing CPU data architecture"));        goto cleanup;    }    if (!(driver = cpuGetSubDriverByName(arch)))        goto cleanup;    if (!driver->dataParse) {        virReportError(VIR_ERR_NO_SUPPORT,                       _("cannot parse %s CPU data"), arch);        goto cleanup;    }    data = driver->dataParse(ctxt); cleanup:    xmlXPathFreeContext(ctxt);    xmlFreeDoc(xml);    VIR_FREE(arch);    return data;}
开发者ID:RWTH-OS,项目名称:libvirt,代码行数:49,


示例27: virInterfaceDefParseBondArpValid

static intvirInterfaceDefParseBondArpValid(xmlXPathContextPtr ctxt) {    char *tmp;    int ret = 0;    tmp = virXPathString("string(./arpmon/@validate)", ctxt);    if (tmp == NULL)        return VIR_INTERFACE_BOND_ARP_NONE;    if (STREQ(tmp, "active"))        ret = VIR_INTERFACE_BOND_ARP_ACTIVE;    else if (STREQ(tmp, "backup"))        ret = VIR_INTERFACE_BOND_ARP_BACKUP;    else if (STREQ(tmp, "all"))        ret = VIR_INTERFACE_BOND_ARP_ALL;    else {        virInterfaceReportError(VIR_ERR_XML_ERROR,                                _("unknown arp bonding validate %s"), tmp);        ret = -1;    }    VIR_FREE(tmp);    return ret;}
开发者ID:foomango,项目名称:libvirt,代码行数:22,


示例28: virInterfaceDefParseIp

static intvirInterfaceDefParseIp(virInterfaceIpDefPtr def,                       xmlXPathContextPtr ctxt) {    int ret = 0;    char *tmp;    long l;    tmp = virXPathString("string(./@address)", ctxt);    def->address = tmp;    if (tmp != NULL) {        ret = virXPathLong("string(./@prefix)", ctxt, &l);        if (ret == 0)            def->prefix = (int) l;        else if (ret == -2) {            virInterfaceReportError(VIR_ERR_XML_ERROR,                              "%s", _("Invalid ip address prefix value"));            return -1;        }    }    return 0;}
开发者ID:foomango,项目名称:libvirt,代码行数:22,


示例29: ppcVendorLoad

static intppcVendorLoad(xmlXPathContextPtr ctxt,              struct ppc_map *map){    struct ppc_vendor *vendor = NULL;    if (VIR_ALLOC(vendor) < 0) {        virReportOOMError();        return -1;    }    vendor->name = virXPathString("string(@name)", ctxt);    if (!vendor->name) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       "%s", _("Missing CPU vendor name"));        goto ignore;    }    if (ppcVendorFind(map, vendor->name)) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       _("CPU vendor %s already defined"), vendor->name);        goto ignore;    }    if (!map->vendors) {        map->vendors = vendor;    } else {        vendor->next = map->vendors;        map->vendors = vendor;    }cleanup:    return 0;ignore:    ppcVendorFree(vendor);    goto cleanup;}
开发者ID:avdv,项目名称:libvirt,代码行数:38,


示例30: virInterfaceDefParseStartMode

static intvirInterfaceDefParseStartMode(virInterfaceDefPtr def,                              xmlXPathContextPtr ctxt) {    char *tmp;    tmp = virXPathString("string(./start/@mode)", ctxt);    if (tmp == NULL)        def->startmode = VIR_INTERFACE_START_UNSPECIFIED;    else if (STREQ(tmp, "onboot"))        def->startmode = VIR_INTERFACE_START_ONBOOT;    else if (STREQ(tmp, "hotplug"))        def->startmode = VIR_INTERFACE_START_HOTPLUG;    else if (STREQ(tmp, "none"))        def->startmode = VIR_INTERFACE_START_NONE;    else {        virInterfaceReportError(VIR_ERR_XML_ERROR,                                _("unknown interface startmode %s"), tmp);        VIR_FREE(tmp);        return -1;    }    VIR_FREE(tmp);    return 0;}
开发者ID:foomango,项目名称:libvirt,代码行数:23,



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


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