It was used for error reporting only. --- ...-Step-7-of-8-Implement-the-driver-methods.patch | 8 +- src/conf/cpu_conf.c | 18 ++-- src/conf/domain_conf.c | 98 ++++++++++---------- src/conf/interface_conf.c | 70 +++++++------- src/conf/network_conf.c | 24 +++--- src/conf/node_device_conf.c | 70 +++++++------- src/conf/secret_conf.c | 15 ++-- src/conf/storage_conf.c | 69 +++++++------- src/conf/storage_encryption_conf.c | 8 +- src/cpu/cpu_map.c | 2 +- src/cpu/cpu_x86.c | 22 ++-- src/esx/esx_vi.c | 7 +- src/qemu/qemu_driver.c | 8 +- src/security/virt-aa-helper.c | 4 +- src/test/test_driver.c | 28 +++--- src/util/xml.c | 73 ++++++--------- src/util/xml.h | 38 +++----- 17 files changed, 267 insertions(+), 295 deletions(-) diff --git a/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch b/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch index 7586cd4..09ddc65 100644 --- a/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch +++ b/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch @@ -550,7 +550,7 @@ index 6e04112..5b35b60 100644 +{ + char *s; + -+ s = virXPathString(conn, xpath, ctxt); ++ s = virXPathString(xpath, ctxt); + if (s == NULL) { + virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, + missing_error_fmt, @@ -611,7 +611,7 @@ index 6e04112..5b35b60 100644 goto out; + } + -+ if ((n = virXPathNodeSet(conn, "./capability", ctxt, &nodes)) < 0) { ++ if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0) { + virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, + _("error parsing SCSI host capabilities for '%s'"), + def->name); @@ -713,9 +713,9 @@ index 6e04112..5b35b60 100644 } /* Extract device name */ -- def->name = virXPathString(conn, "string(./name[1])", ctxt); +- def->name = virXPathString("string(./name[1])", ctxt); + if (create == EXISTING_DEVICE) { -+ def->name = virXPathString(conn, "string(./name[1])", ctxt); ++ def->name = virXPathString("string(./name[1])", ctxt); + } else { + def->name = strdup("new device"); + } diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 002fde3..fabbede 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -85,7 +85,7 @@ virCPUDefParseXML(virConnectPtr conn, } if (mode == VIR_CPU_TYPE_AUTO) { - if (virXPathBoolean(conn, "boolean(./arch)", ctxt)) + if (virXPathBoolean("boolean(./arch)", ctxt)) def->type = VIR_CPU_TYPE_HOST; else def->type = VIR_CPU_TYPE_GUEST; @@ -96,7 +96,7 @@ virCPUDefParseXML(virConnectPtr conn, char *match = virXMLPropString(node, "match"); if (!match) { - if (virXPathBoolean(conn, "boolean(./model)", ctxt)) { + if (virXPathBoolean("boolean(./model)", ctxt)) { virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("Missing match attribute for CPU specification")); goto error; @@ -115,7 +115,7 @@ virCPUDefParseXML(virConnectPtr conn, } if (def->type == VIR_CPU_TYPE_HOST) { - def->arch = virXPathString(conn, "string(./arch[1])", ctxt); + def->arch = virXPathString("string(./arch[1])", ctxt); if (!def->arch) { virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("Missing CPU architecture")); @@ -123,18 +123,18 @@ virCPUDefParseXML(virConnectPtr conn, } } - if (!(def->model = virXPathString(conn, "string(./model[1])", ctxt)) && + if (!(def->model = virXPathString("string(./model[1])", ctxt)) && def->type == VIR_CPU_TYPE_HOST) { virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("Missing CPU model name")); goto error; } - if (virXPathNode(conn, "./topology[1]", ctxt)) { + if (virXPathNode("./topology[1]", ctxt)) { int ret; unsigned long ul; - ret = virXPathULong(conn, "string(./topology[1]/@sockets)", + ret = virXPathULong("string(./topology[1]/@sockets)", ctxt, &ul); if (ret < 0) { virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -143,7 +143,7 @@ virCPUDefParseXML(virConnectPtr conn, } def->sockets = (unsigned int) ul; - ret = virXPathULong(conn, "string(./topology[1]/@cores)", + ret = virXPathULong("string(./topology[1]/@cores)", ctxt, &ul); if (ret < 0) { virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -152,7 +152,7 @@ virCPUDefParseXML(virConnectPtr conn, } def->cores = (unsigned int) ul; - ret = virXPathULong(conn, "string(./topology[1]/@threads)", + ret = virXPathULong("string(./topology[1]/@threads)", ctxt, &ul); if (ret < 0) { virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -168,7 +168,7 @@ virCPUDefParseXML(virConnectPtr conn, } } - n = virXPathNodeSet(conn, "./feature", ctxt, &nodes); + n = virXPathNodeSet("./feature", ctxt, &nodes); if (n < 0) goto error; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index daa63a9..811cd38 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3029,7 +3029,7 @@ static int virDomainLifecycleParseXML(virConnectPtr conn, int *val, int defaultVal) { - char *tmp = virXPathString(conn, xpath, ctxt); + char *tmp = virXPathString(xpath, ctxt); if (tmp == NULL) { *val = defaultVal; } else { @@ -3053,10 +3053,10 @@ virSecurityLabelDefParseXML(virConnectPtr conn, { char *p; - if (virXPathNode(conn, "./seclabel", ctxt) == NULL) + if (virXPathNode("./seclabel", ctxt) == NULL) return 0; - p = virXPathStringLimit(conn, "string(./seclabel/@type)", + p = virXPathStringLimit("string(./seclabel/@type)", VIR_SECURITY_LABEL_BUFLEN-1, ctxt); if (p == NULL) { virDomainReportError(conn, VIR_ERR_XML_ERROR, @@ -3076,7 +3076,7 @@ virSecurityLabelDefParseXML(virConnectPtr conn, */ if (def->seclabel.type == VIR_DOMAIN_SECLABEL_STATIC || !(flags & VIR_DOMAIN_XML_INACTIVE)) { - p = virXPathStringLimit(conn, "string(./seclabel/@model)", + p = virXPathStringLimit("string(./seclabel/@model)", VIR_SECURITY_MODEL_BUFLEN-1, ctxt); if (p == NULL) { virDomainReportError(conn, VIR_ERR_XML_ERROR, @@ -3085,7 +3085,7 @@ virSecurityLabelDefParseXML(virConnectPtr conn, } def->seclabel.model = p; - p = virXPathStringLimit(conn, "string(./seclabel/label[1])", + p = virXPathStringLimit("string(./seclabel/label[1])", VIR_SECURITY_LABEL_BUFLEN-1, ctxt); if (p == NULL) { virDomainReportError(conn, VIR_ERR_XML_ERROR, @@ -3099,7 +3099,7 @@ virSecurityLabelDefParseXML(virConnectPtr conn, /* Only parse imagelabel, if requested live XML for dynamic label */ if (def->seclabel.type == VIR_DOMAIN_SECLABEL_DYNAMIC && !(flags & VIR_DOMAIN_XML_INACTIVE)) { - p = virXPathStringLimit(conn, "string(./seclabel/imagelabel[1])", + p = virXPathStringLimit("string(./seclabel/imagelabel[1])", VIR_SECURITY_LABEL_BUFLEN-1, ctxt); if (p == NULL) { virDomainReportError(conn, VIR_ERR_XML_ERROR, @@ -3357,12 +3357,12 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } if (!(flags & VIR_DOMAIN_XML_INACTIVE)) - if ((virXPathLong(conn, "string(./@id)", ctxt, &id)) < 0) + if ((virXPathLong("string(./@id)", ctxt, &id)) < 0) id = -1; def->id = (int)id; /* Find out what type of virtualization to use */ - if (!(tmp = virXPathString(conn, "string(./@type)", ctxt))) { + if (!(tmp = virXPathString("string(./@type)", ctxt))) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("missing domain type attribute")); goto error; @@ -3376,13 +3376,13 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, VIR_FREE(tmp); /* Extract domain name */ - if (!(def->name = virXPathString(conn, "string(./name[1])", ctxt))) { + if (!(def->name = virXPathString("string(./name[1])", ctxt))) { virDomainReportError(conn, VIR_ERR_NO_NAME, NULL); goto error; } /* Extract domain uuid */ - tmp = virXPathString(conn, "string(./uuid[1])", ctxt); + tmp = virXPathString("string(./uuid[1])", ctxt); if (!tmp) { if (virUUIDGenerate(def->uuid)) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -3399,26 +3399,26 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } /* Extract documentation if present */ - def->description = virXPathString(conn, "string(./description[1])", ctxt); + def->description = virXPathString("string(./description[1])", ctxt); /* Extract domain memory */ - if (virXPathULong(conn, "string(./memory[1])", ctxt, &def->maxmem) < 0) { + if (virXPathULong("string(./memory[1])", ctxt, &def->maxmem) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("missing memory element")); goto error; } - if (virXPathULong(conn, "string(./currentMemory[1])", ctxt, &def->memory) < 0) + if (virXPathULong("string(./currentMemory[1])", ctxt, &def->memory) < 0) def->memory = def->maxmem; - node = virXPathNode(conn, "./memoryBacking/hugepages", ctxt); + node = virXPathNode("./memoryBacking/hugepages", ctxt); if (node) def->hugepage_backed = 1; - if (virXPathULong(conn, "string(./vcpu[1])", ctxt, &def->vcpus) < 0) + if (virXPathULong("string(./vcpu[1])", ctxt, &def->vcpus) < 0) def->vcpus = 1; - tmp = virXPathString(conn, "string(./vcpu[1]/@cpuset)", ctxt); + tmp = virXPathString("string(./vcpu[1]/@cpuset)", ctxt); if (tmp) { char *set = tmp; def->cpumasklen = VIR_DOMAIN_CPUMASK_LEN; @@ -3433,7 +3433,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, VIR_FREE(tmp); } - n = virXPathNodeSet(conn, "./features/*", ctxt, &nodes); + n = virXPathNodeSet("./features/*", ctxt, &nodes); if (n < 0) goto error; if (n) { @@ -3463,15 +3463,15 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, goto error; - tmp = virXPathString(conn, "string(./clock/@offset)", ctxt); + tmp = virXPathString("string(./clock/@offset)", ctxt); if (tmp && STREQ(tmp, "localtime")) def->localtime = 1; VIR_FREE(tmp); - def->os.bootloader = virXPathString(conn, "string(./bootloader)", ctxt); - def->os.bootloaderArgs = virXPathString(conn, "string(./bootloader_args)", ctxt); + def->os.bootloader = virXPathString("string(./bootloader)", ctxt); + def->os.bootloaderArgs = virXPathString("string(./bootloader_args)", ctxt); - def->os.type = virXPathString(conn, "string(./os/type[1])", ctxt); + def->os.type = virXPathString("string(./os/type[1])", ctxt); if (!def->os.type) { if (def->os.bootloader) { def->os.type = strdup("xen"); @@ -3505,7 +3505,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, goto error; } - def->os.arch = virXPathString(conn, "string(./os/type[1]/@arch)", ctxt); + def->os.arch = virXPathString("string(./os/type[1]/@arch)", ctxt); if (def->os.arch) { if (!virCapabilitiesSupportsGuestArch(caps, def->os.type, def->os.arch)) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -3527,7 +3527,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } } - def->os.machine = virXPathString(conn, "string(./os/type[1]/@machine)", ctxt); + def->os.machine = virXPathString("string(./os/type[1]/@machine)", ctxt); if (!def->os.machine) { const char *defaultMachine = virCapabilitiesDefaultGuestMachine(caps, def->os.type, @@ -3551,22 +3551,22 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, */ if (STREQ(def->os.type, "exe")) { - def->os.init = virXPathString(conn, "string(./os/init[1])", ctxt); + def->os.init = virXPathString("string(./os/init[1])", ctxt); } if (STREQ(def->os.type, "xen") || STREQ(def->os.type, "hvm") || STREQ(def->os.type, "uml")) { - def->os.kernel = virXPathString(conn, "string(./os/kernel[1])", ctxt); - def->os.initrd = virXPathString(conn, "string(./os/initrd[1])", ctxt); - def->os.cmdline = virXPathString(conn, "string(./os/cmdline[1])", ctxt); - def->os.root = virXPathString(conn, "string(./os/root[1])", ctxt); - def->os.loader = virXPathString(conn, "string(./os/loader[1])", ctxt); + def->os.kernel = virXPathString("string(./os/kernel[1])", ctxt); + def->os.initrd = virXPathString("string(./os/initrd[1])", ctxt); + def->os.cmdline = virXPathString("string(./os/cmdline[1])", ctxt); + def->os.root = virXPathString("string(./os/root[1])", ctxt); + def->os.loader = virXPathString("string(./os/loader[1])", ctxt); } if (STREQ(def->os.type, "hvm")) { /* analysis of the boot devices */ - if ((n = virXPathNodeSet(conn, "./os/boot", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./os/boot", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract boot device")); goto error; @@ -3596,7 +3596,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, VIR_FREE(nodes); } - def->emulator = virXPathString(conn, "string(./devices/emulator[1])", ctxt); + def->emulator = virXPathString("string(./devices/emulator[1])", ctxt); if (!def->emulator && virCapabilitiesIsEmulatorRequired(caps)) { def->emulator = virDomainDefDefaultEmulator(conn, def, caps); if (!def->emulator) @@ -3604,7 +3604,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } /* analysis of the disk devices */ - if ((n = virXPathNodeSet(conn, "./devices/disk", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/disk", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract disk devices")); goto error; @@ -3623,7 +3623,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, VIR_FREE(nodes); /* analysis of the controller devices */ - if ((n = virXPathNodeSet(conn, "./devices/controller", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/controller", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract controller devices")); goto error; @@ -3648,7 +3648,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, goto error; /* analysis of the filesystems */ - if ((n = virXPathNodeSet(conn, "./devices/filesystem", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/filesystem", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract filesystem devices")); goto error; @@ -3667,7 +3667,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, VIR_FREE(nodes); /* analysis of the network devices */ - if ((n = virXPathNodeSet(conn, "./devices/interface", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/interface", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract network devices")); goto error; @@ -3688,7 +3688,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* analysis of the character devices */ - if ((n = virXPathNodeSet(conn, "./devices/parallel", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/parallel", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract parallel devices")); goto error; @@ -3708,7 +3708,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } VIR_FREE(nodes); - if ((n = virXPathNodeSet(conn, "./devices/serial", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/serial", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract serial devices")); goto error; @@ -3728,7 +3728,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } VIR_FREE(nodes); - if ((node = virXPathNode(conn, "./devices/console[1]", ctxt)) != NULL) { + if ((node = virXPathNode("./devices/console[1]", ctxt)) != NULL) { virDomainChrDefPtr chr = virDomainChrDefParseXML(conn, node, flags); @@ -3757,7 +3757,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } } - if ((n = virXPathNodeSet(conn, "./devices/channel", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/channel", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract channel devices")); goto error; @@ -3778,7 +3778,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* analysis of the input devices */ - if ((n = virXPathNodeSet(conn, "./devices/input", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/input", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract input devices")); goto error; @@ -3813,7 +3813,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, VIR_FREE(nodes); /* analysis of the graphics devices */ - if ((n = virXPathNodeSet(conn, "./devices/graphics", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/graphics", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract graphics devices")); goto error; @@ -3857,7 +3857,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* analysis of the sound devices */ - if ((n = virXPathNodeSet(conn, "./devices/sound", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/sound", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract sound devices")); goto error; @@ -3876,7 +3876,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, VIR_FREE(nodes); /* analysis of the video devices */ - if ((n = virXPathNodeSet(conn, "./devices/video", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/video", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract video devices")); goto error; @@ -3917,7 +3917,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } /* analysis of the host devices */ - if ((n = virXPathNodeSet(conn, "./devices/hostdev", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/hostdev", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract host devices")); goto error; @@ -3937,7 +3937,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* analysis of the watchdog devices */ def->watchdog = NULL; - if ((n = virXPathNodeSet(conn, "./devices/watchdog", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/watchdog", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract watchdog devices")); goto error; @@ -3961,7 +3961,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, if (virSecurityLabelDefParseXML(conn, def, ctxt, flags) == -1) goto error; - if ((node = virXPathNode(conn, "./cpu[1]", ctxt)) != NULL) { + if ((node = virXPathNode("./cpu[1]", ctxt)) != NULL) { xmlNodePtr oldnode = ctxt->node; ctxt->node = node; def->cpu = virCPUDefParseXML(conn, node, ctxt, VIR_CPU_TYPE_GUEST); @@ -3998,7 +3998,7 @@ static virDomainObjPtr virDomainObjParseXML(virConnectPtr conn, if (!(obj = virDomainObjNew(conn, caps))) return NULL; - if (!(config = virXPathNode(conn, "./domain", ctxt))) { + if (!(config = virXPathNode("./domain", ctxt))) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("no domain config")); goto error; @@ -4012,7 +4012,7 @@ static virDomainObjPtr virDomainObjParseXML(virConnectPtr conn, if (!obj->def) goto error; - if (!(tmp = virXPathString(conn, "string(./@state)", ctxt))) { + if (!(tmp = virXPathString("string(./@state)", ctxt))) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("missing domain state")); goto error; @@ -4025,7 +4025,7 @@ static virDomainObjPtr virDomainObjParseXML(virConnectPtr conn, } VIR_FREE(tmp); - if ((virXPathLong(conn, "string(./@pid)", ctxt, &val)) < 0) { + if ((virXPathLong("string(./@pid)", ctxt, &val)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("invalid pid")); goto error; diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index b4d6243..c111385 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -122,7 +122,7 @@ virInterfaceDefParseName(virConnectPtr conn, virInterfaceDefPtr def, xmlXPathContextPtr ctxt) { char *tmp; - tmp = virXPathString(conn, "string(./@name)", ctxt); + tmp = virXPathString("string(./@name)", ctxt); if (tmp == NULL) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("interface has no name")); @@ -138,7 +138,7 @@ virInterfaceDefParseMtu(virConnectPtr conn, virInterfaceDefPtr def, unsigned long mtu; int ret; - ret = virXPathULong(conn, "string(./mtu/@size)", ctxt, &mtu); + ret = virXPathULong("string(./mtu/@size)", ctxt, &mtu); if ((ret == -2) || ((ret == 0) && (mtu > 100000))) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("interface mtu value is improper")); @@ -154,7 +154,7 @@ virInterfaceDefParseStartMode(virConnectPtr conn, virInterfaceDefPtr def, xmlXPathContextPtr ctxt) { char *tmp; - tmp = virXPathString(conn, "string(./start/@mode)", ctxt); + tmp = virXPathString("string(./start/@mode)", ctxt); if (tmp == NULL) def->startmode = VIR_INTERFACE_START_UNSPECIFIED; else if (STREQ(tmp, "onboot")) @@ -178,7 +178,7 @@ virInterfaceDefParseBondMode(virConnectPtr conn, xmlXPathContextPtr ctxt) { char *tmp; int ret = 0; - tmp = virXPathString(conn, "string(./@mode)", ctxt); + tmp = virXPathString("string(./@mode)", ctxt); if (tmp == NULL) return(VIR_INTERFACE_BOND_NONE); if (STREQ(tmp, "balance-rr")) @@ -209,7 +209,7 @@ virInterfaceDefParseBondMiiCarrier(virConnectPtr conn, xmlXPathContextPtr ctxt) char *tmp; int ret = 0; - tmp = virXPathString(conn, "string(./miimon/@carrier)", ctxt); + tmp = virXPathString("string(./miimon/@carrier)", ctxt); if (tmp == NULL) return(VIR_INTERFACE_BOND_MII_NONE); if (STREQ(tmp, "ioctl")) @@ -230,7 +230,7 @@ virInterfaceDefParseBondArpValid(virConnectPtr conn, xmlXPathContextPtr ctxt) { char *tmp; int ret = 0; - tmp = virXPathString(conn, "string(./arpmon/@validate)", ctxt); + tmp = virXPathString("string(./arpmon/@validate)", ctxt); if (tmp == NULL) return(VIR_INTERFACE_BOND_ARP_NONE); if (STREQ(tmp, "active")) @@ -259,7 +259,7 @@ virInterfaceDefParseDhcp(virConnectPtr conn, virInterfaceProtocolDefPtr def, save = ctxt->node; ctxt->node = dhcp; /* Not much to do in the current version */ - tmp = virXPathString(conn, "string(./@peerdns)", ctxt); + tmp = virXPathString("string(./@peerdns)", ctxt); if (tmp) { if (STREQ(tmp, "yes")) def->peerdns = 1; @@ -285,10 +285,10 @@ virInterfaceDefParseIp(virConnectPtr conn, virInterfaceIpDefPtr def, char *tmp; long l; - tmp = virXPathString(conn, "string(./@address)", ctxt); + tmp = virXPathString("string(./@address)", ctxt); def->address = tmp; if (tmp != NULL) { - ret = virXPathLong(conn, "string(./@prefix)", ctxt, &l); + ret = virXPathLong("string(./@prefix)", ctxt, &l); if (ret == 0) def->prefix = (int) l; else if (ret == -2) { @@ -309,17 +309,17 @@ virInterfaceDefParseProtoIPv4(virConnectPtr conn, virInterfaceProtocolDefPtr def int nIpNodes, ii, ret = -1; char *tmp; - tmp = virXPathString(conn, "string(./route[1]/@gateway)", ctxt); + tmp = virXPathString("string(./route[1]/@gateway)", ctxt); def->gateway = tmp; - dhcp = virXPathNode(conn, "./dhcp", ctxt); + dhcp = virXPathNode("./dhcp", ctxt); if (dhcp != NULL) { ret = virInterfaceDefParseDhcp(conn, def, dhcp, ctxt); if (ret != 0) return(ret); } - nIpNodes = virXPathNodeSet(conn, "./ip", ctxt, &ipNodes); + nIpNodes = virXPathNodeSet("./ip", ctxt, &ipNodes); if (nIpNodes < 0) return -1; if (ipNodes == NULL) @@ -364,21 +364,21 @@ virInterfaceDefParseProtoIPv6(virConnectPtr conn, virInterfaceProtocolDefPtr def int nIpNodes, ii, ret = -1; char *tmp; - tmp = virXPathString(conn, "string(./route[1]/@gateway)", ctxt); + tmp = virXPathString("string(./route[1]/@gateway)", ctxt); def->gateway = tmp; - autoconf = virXPathNode(conn, "./autoconf", ctxt); + autoconf = virXPathNode("./autoconf", ctxt); if (autoconf != NULL) def->autoconf = 1; - dhcp = virXPathNode(conn, "./dhcp", ctxt); + dhcp = virXPathNode("./dhcp", ctxt); if (dhcp != NULL) { ret = virInterfaceDefParseDhcp(conn, def, dhcp, ctxt); if (ret != 0) return(ret); } - nIpNodes = virXPathNodeSet(conn, "./ip", ctxt, &ipNodes); + nIpNodes = virXPathNodeSet("./ip", ctxt, &ipNodes); if (nIpNodes < 0) return -1; if (ipNodes == NULL) @@ -425,7 +425,7 @@ virInterfaceDefParseIfAdressing(virConnectPtr conn, virInterfaceDefPtr def, save = ctxt->node; - nProtoNodes = virXPathNodeSet(conn, "./protocol", ctxt, &protoNodes); + nProtoNodes = virXPathNodeSet("./protocol", ctxt, &protoNodes); if (nProtoNodes <= 0) { /* no protocols is an acceptable outcome */ return 0; @@ -447,7 +447,7 @@ virInterfaceDefParseIfAdressing(virConnectPtr conn, virInterfaceDefPtr def, } ctxt->node = protoNodes[pp]; - tmp = virXPathString(conn, "string(./@family)", ctxt); + tmp = virXPathString("string(./@family)", ctxt); if (tmp == NULL) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("protocol misses the family attribute")); @@ -495,7 +495,7 @@ virInterfaceDefParseBridge(virConnectPtr conn, virInterfaceDefPtr def, int ret = 0; bridge = ctxt->node; - nbItf = virXPathNodeSet(conn, "./interface", ctxt, &interfaces); + nbItf = virXPathNodeSet("./interface", ctxt, &interfaces); if (nbItf < 0) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("bridge interfaces")); @@ -537,7 +537,7 @@ virInterfaceDefParseBondItfs(virConnectPtr conn, virInterfaceDefPtr def, int nbItf, i; int ret = 0; - nbItf = virXPathNodeSet(conn, "./interface", ctxt, &interfaces); + nbItf = virXPathNodeSet("./interface", ctxt, &interfaces); if (nbItf <= 0) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("bond has no interfaces")); @@ -583,11 +583,11 @@ virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def, if (ret != 0) goto error; - node = virXPathNode(conn, "./miimon[1]", ctxt); + node = virXPathNode("./miimon[1]", ctxt); if (node != NULL) { def->data.bond.monit = VIR_INTERFACE_BOND_MONIT_MII; - ret = virXPathULong(conn, "string(./miimon/@freq)", ctxt, &tmp); + ret = virXPathULong("string(./miimon/@freq)", ctxt, &tmp); if ((ret == -2) || (ret == -1)) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("bond interface miimon freq missing or invalid")); @@ -595,7 +595,7 @@ virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def, } def->data.bond.frequency = (int) tmp; - ret = virXPathULong(conn, "string(./miimon/@downdelay)", ctxt, &tmp); + ret = virXPathULong("string(./miimon/@downdelay)", ctxt, &tmp); if (ret == -2) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("bond interface miimon downdelay invalid")); @@ -604,7 +604,7 @@ virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def, def->data.bond.downdelay = (int) tmp; } - ret = virXPathULong(conn, "string(./miimon/@updelay)", ctxt, &tmp); + ret = virXPathULong("string(./miimon/@updelay)", ctxt, &tmp); if (ret == -2) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("bond interface miimon updelay invalid")); @@ -619,11 +619,11 @@ virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def, goto error; } - } else if ((node = virXPathNode(conn, "./arpmon[1]", ctxt)) != NULL) { + } else if ((node = virXPathNode("./arpmon[1]", ctxt)) != NULL) { def->data.bond.monit = VIR_INTERFACE_BOND_MONIT_ARP; - ret = virXPathULong(conn, "string(./arpmon/@interval)", ctxt, &tmp); + ret = virXPathULong("string(./arpmon/@interval)", ctxt, &tmp); if ((ret == -2) || (ret == -1)) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("bond interface arpmon interval missing or invalid")); @@ -632,7 +632,7 @@ virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def, def->data.bond.interval = (int) tmp; def->data.bond.target = - virXPathString(conn, "string(./arpmon/@target)", ctxt); + virXPathString("string(./arpmon/@target)", ctxt); if (def->data.bond.target == NULL) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("bond interface arpmon target missing")); @@ -653,7 +653,7 @@ error: static int virInterfaceDefParseVlan(virConnectPtr conn, virInterfaceDefPtr def, xmlXPathContextPtr ctxt) { - def->data.vlan.tag = virXPathString(conn, "string(./@tag)", ctxt); + def->data.vlan.tag = virXPathString("string(./@tag)", ctxt); if (def->data.vlan.tag == NULL) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("vlan interface misses the tag attribute")); @@ -661,7 +661,7 @@ virInterfaceDefParseVlan(virConnectPtr conn, virInterfaceDefPtr def, } def->data.vlan.devname = - virXPathString(conn, "string(./interface/@name)", ctxt); + virXPathString("string(./interface/@name)", ctxt); if (def->data.vlan.devname == NULL) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("vlan interface misses name attribute")); @@ -679,7 +679,7 @@ virInterfaceDefParseXML(virConnectPtr conn, xmlNodePtr cur = ctxt->node; /* check @type */ - tmp = virXPathString(conn, "string(./@type)", ctxt); + tmp = virXPathString("string(./@type)", ctxt); if (tmp == NULL) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("interface misses the type attribute")); @@ -718,7 +718,7 @@ virInterfaceDefParseXML(virConnectPtr conn, case VIR_INTERFACE_TYPE_ETHERNET: if (virInterfaceDefParseName(conn, def, ctxt) < 0) goto error; - tmp = virXPathString(conn, "string(./mac/@address)", ctxt); + tmp = virXPathString("string(./mac/@address)", ctxt); if (tmp != NULL) def->mac = tmp; if (parentIfType == VIR_INTERFACE_TYPE_LAST) { @@ -743,7 +743,7 @@ virInterfaceDefParseXML(virConnectPtr conn, if (virInterfaceDefParseIfAdressing(conn, def, ctxt) < 0) goto error; - bridge = virXPathNode(conn, "./bridge[1]", ctxt); + bridge = virXPathNode("./bridge[1]", ctxt); if (bridge == NULL) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("bridge interface misses the bridge element")); @@ -785,7 +785,7 @@ virInterfaceDefParseXML(virConnectPtr conn, goto error; } - bond = virXPathNode(conn, "./bond[1]", ctxt); + bond = virXPathNode("./bond[1]", ctxt); if (bond == NULL) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("bond interface misses the bond element")); @@ -799,14 +799,14 @@ virInterfaceDefParseXML(virConnectPtr conn, case VIR_INTERFACE_TYPE_VLAN: { xmlNodePtr vlan; - tmp = virXPathString(conn, "string(./@name)", ctxt); + tmp = virXPathString("string(./@name)", ctxt); if (tmp != NULL) def->name = tmp; if (virInterfaceDefParseStartMode(conn, def, ctxt) < 0) goto error; if (virInterfaceDefParseIfAdressing(conn, def, ctxt) < 0) goto error; - vlan = virXPathNode(conn, "./vlan[1]", ctxt); + vlan = virXPathNode("./vlan[1]", ctxt); if (vlan == NULL) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("vlan interface misses the vlan element")); diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 4e4a58c..6e857f9 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -401,14 +401,14 @@ virNetworkDefParseXML(virConnectPtr conn, } /* Extract network name */ - def->name = virXPathString(conn, "string(./name[1])", ctxt); + def->name = virXPathString("string(./name[1])", ctxt); if (!def->name) { virNetworkReportError(conn, VIR_ERR_NO_NAME, NULL); goto error; } /* Extract network uuid */ - tmp = virXPathString(conn, "string(./uuid[1])", ctxt); + tmp = virXPathString("string(./uuid[1])", ctxt); if (!tmp) { if (virUUIDGenerate(def->uuid)) { virNetworkReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -426,19 +426,19 @@ virNetworkDefParseXML(virConnectPtr conn, } /* Parse network domain information */ - def->domain = virXPathString(conn, "string(./domain[1]/@name)", ctxt); + def->domain = virXPathString("string(./domain[1]/@name)", ctxt); /* Parse bridge information */ - def->bridge = virXPathString(conn, "string(./bridge[1]/@name)", ctxt); - tmp = virXPathString(conn, "string(./bridge[1]/@stp)", ctxt); + def->bridge = virXPathString("string(./bridge[1]/@name)", ctxt); + tmp = virXPathString("string(./bridge[1]/@stp)", ctxt); def->stp = (tmp && STREQ(tmp, "off")) ? 0 : 1; VIR_FREE(tmp); - if (virXPathULong(conn, "string(./bridge[1]/@delay)", ctxt, &def->delay) < 0) + if (virXPathULong("string(./bridge[1]/@delay)", ctxt, &def->delay) < 0) def->delay = 0; - def->ipAddress = virXPathString(conn, "string(./ip[1]/@address)", ctxt); - def->netmask = virXPathString(conn, "string(./ip[1]/@netmask)", ctxt); + def->ipAddress = virXPathString("string(./ip[1]/@address)", ctxt); + def->netmask = virXPathString("string(./ip[1]/@netmask)", ctxt); if (def->ipAddress && def->netmask) { /* XXX someday we want IPv6 too, so inet_aton won't work there */ @@ -467,14 +467,14 @@ virNetworkDefParseXML(virConnectPtr conn, goto error; } - if ((ip = virXPathNode(conn, "./ip[1]", ctxt)) && + if ((ip = virXPathNode("./ip[1]", ctxt)) && virNetworkIPParseXML(conn, def, ip) < 0) goto error; } /* IPv4 forwarding setup */ - if (virXPathBoolean(conn, "count(./forward) > 0", ctxt)) { + if (virXPathBoolean("count(./forward) > 0", ctxt)) { if (!def->ipAddress || !def->netmask) { virNetworkReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -482,7 +482,7 @@ virNetworkDefParseXML(virConnectPtr conn, goto error; } - tmp = virXPathString(conn, "string(./forward[1]/@mode)", ctxt); + tmp = virXPathString("string(./forward[1]/@mode)", ctxt); if (tmp) { if ((def->forwardType = virNetworkForwardTypeFromString(tmp)) < 0) { virNetworkReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -496,7 +496,7 @@ virNetworkDefParseXML(virConnectPtr conn, } - def->forwardDev = virXPathString(conn, "string(./forward[1]/@dev)", ctxt); + def->forwardDev = virXPathString("string(./forward[1]/@dev)", ctxt); } else { def->forwardType = VIR_NETWORK_FORWARD_NONE; } diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 2924ff0..3ca639c 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -69,7 +69,7 @@ virNodeDevCapsDefParseString(virConnectPtr conn, { char *s; - s = virXPathString(conn, xpath, ctxt); + s = virXPathString(xpath, ctxt); if (s == NULL) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, missing_error_fmt, @@ -509,7 +509,7 @@ virNodeDevCapsDefParseULong(virConnectPtr conn, int ret; unsigned long val; - ret = virXPathULong(conn, xpath, ctxt, &val); + ret = virXPathULong(xpath, ctxt, &val); if (ret < 0) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, ret == -1 ? missing_error_fmt : invalid_error_fmt, @@ -533,7 +533,7 @@ virNodeDevCapsDefParseULongLong(virConnectPtr conn, int ret; unsigned long long val; - ret = virXPathULongLong(conn, xpath, ctxt, &val); + ret = virXPathULongLong(xpath, ctxt, &val); if (ret < 0) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, ret == -1 ? missing_error_fmt : invalid_error_fmt, @@ -559,7 +559,7 @@ virNodeDevCapStorageParseXML(virConnectPtr conn, orignode = ctxt->node; ctxt->node = node; - data->storage.block = virXPathString(conn, "string(./block[1])", ctxt); + data->storage.block = virXPathString("string(./block[1])", ctxt); if (!data->storage.block) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, _("no block device path supplied for '%s'"), @@ -567,13 +567,13 @@ virNodeDevCapStorageParseXML(virConnectPtr conn, goto out; } - data->storage.bus = virXPathString(conn, "string(./bus[1])", ctxt); - data->storage.drive_type = virXPathString(conn, "string(./drive_type[1])", ctxt); - data->storage.model = virXPathString(conn, "string(./model[1])", ctxt); - data->storage.vendor = virXPathString(conn, "string(./vendor[1])", ctxt); - data->storage.serial = virXPathString(conn, "string(./serial[1])", ctxt); + data->storage.bus = virXPathString("string(./bus[1])", ctxt); + data->storage.drive_type = virXPathString("string(./drive_type[1])", ctxt); + data->storage.model = virXPathString("string(./model[1])", ctxt); + data->storage.vendor = virXPathString("string(./vendor[1])", ctxt); + data->storage.serial = virXPathString("string(./serial[1])", ctxt); - if ((n = virXPathNodeSet(conn, "./capability", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, _("error parsing storage capabilities for '%s'"), def->name); @@ -600,10 +600,10 @@ virNodeDevCapStorageParseXML(virConnectPtr conn, orignode2 = ctxt->node; ctxt->node = nodes[i]; - if (virXPathBoolean(conn, "count(./media_available[. = '1']) > 0", ctxt)) + if (virXPathBoolean("count(./media_available[. = '1']) > 0", ctxt)) data->storage.flags |= VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE; - data->storage.media_label = virXPathString(conn, "string(./media_label[1])", ctxt); + data->storage.media_label = virXPathString("string(./media_label[1])", ctxt); val = 0; if (virNodeDevCapsDefParseULongLong(conn, "number(./media_size[1])", ctxt, &val, def, @@ -680,7 +680,7 @@ virNodeDevCapScsiParseXML(virConnectPtr conn, _("invalid SCSI LUN ID supplied for '%s'")) < 0) goto out; - data->scsi.type = virXPathString(conn, "string(./type[1])", ctxt); + data->scsi.type = virXPathString("string(./type[1])", ctxt); ret = 0; out: @@ -702,7 +702,7 @@ virNodeDevCapScsiTargetParseXML(virConnectPtr conn, orignode = ctxt->node; ctxt->node = node; - data->scsi_target.name = virXPathString(conn, "string(./name[1])", ctxt); + data->scsi_target.name = virXPathString("string(./name[1])", ctxt); if (!data->scsi_target.name) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, _("no target name supplied for '%s'"), @@ -741,7 +741,7 @@ virNodeDevCapScsiHostParseXML(virConnectPtr conn, goto out; } - if ((n = virXPathNodeSet(conn, "./capability", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, _("error parsing SCSI host capabilities for '%s'"), def->name); @@ -822,7 +822,7 @@ virNodeDevCapNetParseXML(virConnectPtr conn, orignode = ctxt->node; ctxt->node = node; - data->net.ifname = virXPathString(conn, "string(./interface[1])", ctxt); + data->net.ifname = virXPathString("string(./interface[1])", ctxt); if (!data->net.ifname) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, _("no network interface supplied for '%s'"), @@ -830,11 +830,11 @@ virNodeDevCapNetParseXML(virConnectPtr conn, goto out; } - data->net.address = virXPathString(conn, "string(./address[1])", ctxt); + data->net.address = virXPathString("string(./address[1])", ctxt); data->net.subtype = VIR_NODE_DEV_CAP_NET_LAST; - tmp = virXPathString(conn, "string(./capability/@type)", ctxt); + tmp = virXPathString("string(./capability/@type)", ctxt); if (tmp) { int val = virNodeDevNetCapTypeFromString(tmp); VIR_FREE(tmp); @@ -890,7 +890,7 @@ virNodeDevCapUsbInterfaceParseXML(virConnectPtr conn, _("invalid USB interface protocol supplied for '%s'")) < 0) goto out; - data->usb_if.description = virXPathString(conn, "string(./description[1])", ctxt); + data->usb_if.description = virXPathString("string(./description[1])", ctxt); ret = 0; out: @@ -910,7 +910,7 @@ virNodeDevCapsDefParseHexId(virConnectPtr conn, int ret; unsigned long val; - ret = virXPathULongHex(conn, xpath, ctxt, &val); + ret = virXPathULongHex(xpath, ctxt, &val); if (ret < 0) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, ret == -1 ? missing_error_fmt : invalid_error_fmt, @@ -959,8 +959,8 @@ virNodeDevCapUsbDevParseXML(virConnectPtr conn, _("invalid USB product ID supplied for '%s'")) < 0) goto out; - data->usb_dev.vendor_name = virXPathString(conn, "string(./vendor[1])", ctxt); - data->usb_dev.product_name = virXPathString(conn, "string(./product[1])", ctxt); + data->usb_dev.vendor_name = virXPathString("string(./vendor[1])", ctxt); + data->usb_dev.product_name = virXPathString("string(./product[1])", ctxt); ret = 0; out: @@ -1017,8 +1017,8 @@ virNodeDevCapPciDevParseXML(virConnectPtr conn, _("invalid PCI product ID supplied for '%s'")) < 0) goto out; - data->pci_dev.vendor_name = virXPathString(conn, "string(./vendor[1])", ctxt); - data->pci_dev.product_name = virXPathString(conn, "string(./product[1])", ctxt); + data->pci_dev.vendor_name = virXPathString("string(./vendor[1])", ctxt); + data->pci_dev.product_name = virXPathString("string(./product[1])", ctxt); ret = 0; out: @@ -1040,13 +1040,13 @@ virNodeDevCapSystemParseXML(virConnectPtr conn, orignode = ctxt->node; ctxt->node = node; - data->system.product_name = virXPathString(conn, "string(./product[1])", ctxt); + data->system.product_name = virXPathString("string(./product[1])", ctxt); - data->system.hardware.vendor_name = virXPathString(conn, "string(./hardware/vendor[1])", ctxt); - data->system.hardware.version = virXPathString(conn, "string(./hardware/version[1])", ctxt); - data->system.hardware.serial = virXPathString(conn, "string(./hardware/serial[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(conn, "string(./hardware/uuid[1])", ctxt); + tmp = virXPathString("string(./hardware/uuid[1])", ctxt); if (!tmp) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, _("no system UUID supplied for '%s'"), def->name); @@ -1061,9 +1061,9 @@ virNodeDevCapSystemParseXML(virConnectPtr conn, } VIR_FREE(tmp); - data->system.firmware.vendor_name = virXPathString(conn, "string(./firmware/vendor[1])", ctxt); - data->system.firmware.version = virXPathString(conn, "string(./firmware/version[1])", ctxt); - data->system.firmware.release_date = virXPathString(conn, "string(./firmware/release_date[1])", ctxt); + 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: @@ -1163,7 +1163,7 @@ virNodeDeviceDefParseXML(virConnectPtr conn, xmlXPathContextPtr ctxt, int create /* Extract device name */ if (create == EXISTING_DEVICE) { - def->name = virXPathString(conn, "string(./name[1])", ctxt); + def->name = virXPathString("string(./name[1])", ctxt); if (!def->name) { virNodeDeviceReportError(conn, VIR_ERR_NO_NAME, NULL); @@ -1179,11 +1179,11 @@ virNodeDeviceDefParseXML(virConnectPtr conn, xmlXPathContextPtr ctxt, int create } /* Extract device parent, if any */ - def->parent = virXPathString(conn, "string(./parent[1])", ctxt); + def->parent = virXPathString("string(./parent[1])", ctxt); /* Parse device capabilities */ nodes = NULL; - if ((n = virXPathNodeSet(conn, "./capability", ctxt, &nodes)) <= 0) { + if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) <= 0) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, _("no device capabilities for '%s'"), def->name); diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c index 4b0068e..c002a5d 100644 --- a/src/conf/secret_conf.c +++ b/src/conf/secret_conf.c @@ -66,7 +66,7 @@ virSecretDefParseUsage(virConnectPtr conn, xmlXPathContextPtr ctxt, char *type_str; int type; - type_str = virXPathString(conn, "string(./usage/@type)", ctxt); + type_str = virXPathString("string(./usage/@type)", ctxt); if (type_str == NULL) { virSecretReportError(conn, VIR_ERR_XML_ERROR, "%s", _("unknown secret usage type")); @@ -86,8 +86,7 @@ virSecretDefParseUsage(virConnectPtr conn, xmlXPathContextPtr ctxt, break; case VIR_SECRET_USAGE_TYPE_VOLUME: - def->usage.volume = virXPathString(conn, "string(./usage/volume)", - ctxt); + def->usage.volume = virXPathString("string(./usage/volume)", ctxt); if (!def->usage.volume) { virSecretReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("volume usage specified, but volume path is missing")); @@ -130,7 +129,7 @@ secretXMLParseNode(virConnectPtr conn, xmlDocPtr xml, xmlNodePtr root) goto cleanup; } - prop = virXPathString(conn, "string(./@ephemeral)", ctxt); + prop = virXPathString("string(./@ephemeral)", ctxt); if (prop != NULL) { if (STREQ(prop, "yes")) def->ephemeral = 1; @@ -144,7 +143,7 @@ secretXMLParseNode(virConnectPtr conn, xmlDocPtr xml, xmlNodePtr root) VIR_FREE(prop); } - prop = virXPathString(conn, "string(./@private)", ctxt); + prop = virXPathString("string(./@private)", ctxt); if (prop != NULL) { if (STREQ(prop, "yes")) def->private = 1; @@ -158,7 +157,7 @@ secretXMLParseNode(virConnectPtr conn, xmlDocPtr xml, xmlNodePtr root) VIR_FREE(prop); } - uuidstr = virXPathString(conn, "string(./uuid)", ctxt); + uuidstr = virXPathString("string(./uuid)", ctxt); if (!uuidstr) { if (virUUIDGenerate(def->uuid)) { virSecretReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -174,8 +173,8 @@ secretXMLParseNode(virConnectPtr conn, xmlDocPtr xml, xmlNodePtr root) VIR_FREE(uuidstr); } - def->description = virXPathString(conn, "string(./description)", ctxt); - if (virXPathNode(conn, "./usage", ctxt) != NULL + def->description = virXPathString("string(./description)", ctxt); + if (virXPathNode("./usage", ctxt) != NULL && virSecretDefParseUsage(conn, ctxt, def) < 0) goto cleanup; ret = def; diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 9c0981d..b80fef0 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -369,14 +369,14 @@ static int virStoragePoolDefParseAuthChap(virConnectPtr conn, xmlXPathContextPtr ctxt, virStoragePoolAuthChapPtr auth) { - auth->login = virXPathString(conn, "string(./auth/@login)", ctxt); + auth->login = virXPathString("string(./auth/@login)", ctxt); if (auth->login == NULL) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("missing auth host attribute")); return -1; } - auth->passwd = virXPathString(conn, "string(./auth/@passwd)", ctxt); + auth->passwd = virXPathString("string(./auth/@passwd)", ctxt); if (auth->passwd == NULL) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("missing auth passwd attribute")); @@ -405,10 +405,10 @@ virStoragePoolDefParseSource(virConnectPtr conn, goto cleanup; } - source->name = virXPathString(conn, "string(./name)", ctxt); + source->name = virXPathString("string(./name)", ctxt); if (options->formatFromString) { - char *format = virXPathString(conn, "string(./format/@type)", ctxt); + char *format = virXPathString("string(./format/@type)", ctxt); if (format == NULL) source->format = options->defaultFormat; else @@ -423,11 +423,10 @@ virStoragePoolDefParseSource(virConnectPtr conn, VIR_FREE(format); } - source->host.name = virXPathString(conn, "string(./host/@name)", ctxt); - source->initiator.iqn = virXPathString(conn, - "string(./initiator/iqn/@name)", ctxt); + source->host.name = virXPathString("string(./host/@name)", ctxt); + source->initiator.iqn = virXPathString("string(./initiator/iqn/@name)", ctxt); - nsource = virXPathNodeSet(conn, "./device", ctxt, &nodeset); + nsource = virXPathNodeSet("./device", ctxt, &nodeset); if (nsource > 0) { if (VIR_ALLOC_N(source->devices, nsource) < 0) { VIR_FREE(nodeset); @@ -448,10 +447,10 @@ virStoragePoolDefParseSource(virConnectPtr conn, source->ndevice = nsource; } - source->dir = virXPathString(conn, "string(./dir/@path)", ctxt); - source->adapter = virXPathString(conn, "string(./adapter/@name)", ctxt); + source->dir = virXPathString("string(./dir/@path)", ctxt); + source->adapter = virXPathString("string(./adapter/@name)", ctxt); - authType = virXPathString(conn, "string(./auth/@type)", ctxt); + authType = virXPathString("string(./auth/@type)", ctxt); if (authType == NULL) { source->authType = VIR_STORAGE_POOL_AUTH_NONE; } else { @@ -510,7 +509,7 @@ virStoragePoolDefParseSourceString(virConnectPtr conn, goto cleanup; } - node = virXPathNode(conn, "/source", xpath_ctxt); + node = virXPathNode("/source", xpath_ctxt); if (!node) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("root element was not source")); @@ -543,7 +542,7 @@ virStorageDefParsePerms(virConnectPtr conn, xmlNodePtr relnode; xmlNodePtr node; - node = virXPathNode(conn, permxpath, ctxt); + node = virXPathNode(permxpath, ctxt); if (node == NULL) { /* Set default values if there is not <permissions> element */ perms->mode = defaultmode; @@ -556,7 +555,7 @@ virStorageDefParsePerms(virConnectPtr conn, relnode = ctxt->node; ctxt->node = node; - mode = virXPathString(conn, "string(./mode)", ctxt); + mode = virXPathString("string(./mode)", ctxt); if (!mode) { perms->mode = defaultmode; } else { @@ -571,10 +570,10 @@ virStorageDefParsePerms(virConnectPtr conn, VIR_FREE(mode); } - if (virXPathNode(conn, "./owner", ctxt) == NULL) { + if (virXPathNode("./owner", ctxt) == NULL) { perms->uid = getuid(); } else { - if (virXPathLong(conn, "number(./owner)", ctxt, &v) < 0) { + if (virXPathLong("number(./owner)", ctxt, &v) < 0) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("malformed owner element")); goto error; @@ -582,10 +581,10 @@ virStorageDefParsePerms(virConnectPtr conn, perms->uid = (int)v; } - if (virXPathNode(conn, "./group", ctxt) == NULL) { + if (virXPathNode("./group", ctxt) == NULL) { perms->gid = getgid(); } else { - if (virXPathLong(conn, "number(./group)", ctxt, &v) < 0) { + if (virXPathLong("number(./group)", ctxt, &v) < 0) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("malformed group element")); goto error; @@ -594,7 +593,7 @@ virStorageDefParsePerms(virConnectPtr conn, } /* NB, we're ignoring missing labels here - they'll simply inherit */ - perms->label = virXPathString(conn, "string(./label)", ctxt); + perms->label = virXPathString("string(./label)", ctxt); ret = 0; error: @@ -616,7 +615,7 @@ virStoragePoolDefParseXML(virConnectPtr conn, return NULL; } - type = virXPathString(conn, "string(./@type)", ctxt); + type = virXPathString("string(./@type)", ctxt); if ((ret->type = virStoragePoolTypeFromString((const char *)type)) < 0) { virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, _("unknown storage pool type %s"), (const char*)type); @@ -630,14 +629,14 @@ virStoragePoolDefParseXML(virConnectPtr conn, goto cleanup; } - source_node = virXPathNode(conn, "./source", ctxt); + source_node = virXPathNode("./source", ctxt); if (source_node) { if (virStoragePoolDefParseSource(conn, ctxt, &ret->source, ret->type, source_node) < 0) goto cleanup; } - ret->name = virXPathString(conn, "string(./name)", ctxt); + ret->name = virXPathString("string(./name)", ctxt); if (ret->name == NULL && options->flags & VIR_STORAGE_POOL_SOURCE_NAME) ret->name = ret->source.name; @@ -647,7 +646,7 @@ virStoragePoolDefParseXML(virConnectPtr conn, goto cleanup; } - uuid = virXPathString(conn, "string(./uuid)", ctxt); + uuid = virXPathString("string(./uuid)", ctxt); if (uuid == NULL) { if (virUUIDGenerate(ret->uuid) < 0) { virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -698,7 +697,7 @@ virStoragePoolDefParseXML(virConnectPtr conn, } } - if ((ret->target.path = virXPathString(conn, "string(./target/path)", ctxt)) == NULL) { + if ((ret->target.path = virXPathString("string(./target/path)", ctxt)) == NULL) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("missing storage pool target path")); goto cleanup; @@ -1050,7 +1049,7 @@ virStorageVolDefParseXML(virConnectPtr conn, return NULL; } - ret->name = virXPathString(conn, "string(./name)", ctxt); + ret->name = virXPathString("string(./name)", ctxt); if (ret->name == NULL) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("missing volume name element")); @@ -1058,10 +1057,10 @@ virStorageVolDefParseXML(virConnectPtr conn, } /* Auto-generated so deliberately ignore */ - /*ret->key = virXPathString(conn, "string(./key)", ctxt);*/ + /*ret->key = virXPathString("string(./key)", ctxt);*/ - capacity = virXPathString(conn, "string(./capacity)", ctxt); - unit = virXPathString(conn, "string(./capacity/@unit)", ctxt); + capacity = virXPathString("string(./capacity)", ctxt); + unit = virXPathString("string(./capacity/@unit)", ctxt); if (capacity == NULL) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("missing capacity element")); @@ -1072,9 +1071,9 @@ virStorageVolDefParseXML(virConnectPtr conn, VIR_FREE(capacity); VIR_FREE(unit); - allocation = virXPathString(conn, "string(./allocation)", ctxt); + allocation = virXPathString("string(./allocation)", ctxt); if (allocation) { - unit = virXPathString(conn, "string(./allocation/@unit)", ctxt); + unit = virXPathString("string(./allocation/@unit)", ctxt); if (virStorageSize(conn, unit, allocation, &ret->allocation) < 0) goto cleanup; VIR_FREE(allocation); @@ -1083,9 +1082,9 @@ virStorageVolDefParseXML(virConnectPtr conn, ret->allocation = ret->capacity; } - ret->target.path = virXPathString(conn, "string(./target/path)", ctxt); + ret->target.path = virXPathString("string(./target/path)", ctxt); if (options->formatFromString) { - char *format = virXPathString(conn, "string(./target/format/@type)", ctxt); + char *format = virXPathString("string(./target/format/@type)", ctxt); if (format == NULL) ret->target.format = options->defaultFormat; else @@ -1104,7 +1103,7 @@ virStorageVolDefParseXML(virConnectPtr conn, "./target/permissions", 0600) < 0) goto cleanup; - node = virXPathNode(conn, "./target/encryption", ctxt); + node = virXPathNode("./target/encryption", ctxt); if (node != NULL) { ret->target.encryption = virStorageEncryptionParseNode(conn, ctxt->doc, node); @@ -1114,9 +1113,9 @@ virStorageVolDefParseXML(virConnectPtr conn, - ret->backingStore.path = virXPathString(conn, "string(./backingStore/path)", ctxt); + ret->backingStore.path = virXPathString("string(./backingStore/path)", ctxt); if (options->formatFromString) { - char *format = virXPathString(conn, "string(./backingStore/format/@type)", ctxt); + char *format = virXPathString("string(./backingStore/format/@type)", ctxt); if (format == NULL) ret->backingStore.format = options->defaultFormat; else diff --git a/src/conf/storage_encryption_conf.c b/src/conf/storage_encryption_conf.c index eba1f12..f19af88 100644 --- a/src/conf/storage_encryption_conf.c +++ b/src/conf/storage_encryption_conf.c @@ -87,7 +87,7 @@ virStorageEncryptionSecretParse(virConnectPtr conn, xmlXPathContextPtr ctxt, old_node = ctxt->node; ctxt->node = node; - type_str = virXPathString(conn, "string(./@type)", ctxt); + type_str = virXPathString("string(./@type)", ctxt); if (type_str == NULL) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("unknown volume encryption secret type")); @@ -104,7 +104,7 @@ virStorageEncryptionSecretParse(virConnectPtr conn, xmlXPathContextPtr ctxt, VIR_FREE(type_str); ret->type = type; - uuidstr = virXPathString(conn, "string(./@uuid)", ctxt); + uuidstr = virXPathString("string(./@uuid)", ctxt); if (uuidstr) { if (virUUIDParse(uuidstr, ret->uuid) < 0) { virStorageReportError(conn, VIR_ERR_XML_ERROR, @@ -141,7 +141,7 @@ virStorageEncryptionParseXML(virConnectPtr conn, xmlXPathContextPtr ctxt) return NULL; } - format_str = virXPathString(conn, "string(./@format)", ctxt); + format_str = virXPathString("string(./@format)", ctxt); if (format_str == NULL) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("unknown volume encryption format")); @@ -158,7 +158,7 @@ virStorageEncryptionParseXML(virConnectPtr conn, xmlXPathContextPtr ctxt) VIR_FREE(format_str); ret->format = format; - n = virXPathNodeSet(conn, "./secret", ctxt, &nodes); + n = virXPathNodeSet("./secret", ctxt, &nodes); if (n < 0){ virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract volume encryption secrets")); diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c index 9a80c90..b63e2eb 100644 --- a/src/cpu/cpu_map.c +++ b/src/cpu/cpu_map.c @@ -101,7 +101,7 @@ int cpuMapLoad(const char *arch, ctxt->node = xmlDocGetRootElement(xml); - if ((ctxt->node = virXPathNode(NULL, xpath, ctxt)) == NULL) { + if ((ctxt->node = virXPathNode(xpath, ctxt)) == NULL) { virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, _("cannot find CPU map for %s architecture"), arch); goto cleanup; diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 33ce776..93bd675 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -332,7 +332,7 @@ x86FeatureLoad(xmlXPathContextPtr ctxt, if (VIR_ALLOC(feature) < 0) goto no_memory; - feature->name = virXPathString(NULL, "string(@name)", ctxt); + feature->name = virXPathString("string(@name)", ctxt); if (feature->name == NULL) { virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, "%s", _("Missing CPU feature name")); @@ -345,7 +345,7 @@ x86FeatureLoad(xmlXPathContextPtr ctxt, goto ignore; } - n = virXPathNodeSet(NULL, "./cpuid", ctxt, &nodes); + n = virXPathNodeSet("./cpuid", ctxt, &nodes); if (n < 0) goto ignore; @@ -362,11 +362,11 @@ x86FeatureLoad(xmlXPathContextPtr ctxt, ctxt->node = nodes[i]; fun = eax = ebx = ecx = edx = 0; - ret_fun = virXPathULongHex(NULL, "string(@function)", ctxt, &fun); - ret_eax = virXPathULongHex(NULL, "string(@eax)", ctxt, &eax); - ret_ebx = virXPathULongHex(NULL, "string(@ebx)", ctxt, &ebx); - ret_ecx = virXPathULongHex(NULL, "string(@ecx)", ctxt, &ecx); - ret_edx = virXPathULongHex(NULL, "string(@edx)", ctxt, &edx); + ret_fun = virXPathULongHex("string(@function)", ctxt, &fun); + ret_eax = virXPathULongHex("string(@eax)", ctxt, &eax); + ret_ebx = virXPathULongHex("string(@ebx)", ctxt, &ebx); + ret_ecx = virXPathULongHex("string(@ecx)", ctxt, &ecx); + ret_edx = virXPathULongHex("string(@edx)", ctxt, &edx); if (ret_fun < 0 || ret_eax == -2 || ret_ebx == -2 || ret_ecx == -2 || ret_edx == -2) { @@ -645,18 +645,18 @@ x86ModelLoad(xmlXPathContextPtr ctxt, if (VIR_ALLOC(model) < 0) goto no_memory; - model->name = virXPathString(NULL, "string(@name)", ctxt); + model->name = virXPathString("string(@name)", ctxt); if (model->name == NULL) { virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, "%s", _("Missing CPU model name")); goto ignore; } - if (virXPathNode(NULL, "./model", ctxt) != NULL) { + if (virXPathNode("./model", ctxt) != NULL) { const struct x86_model *ancestor; char *name; - name = virXPathString(NULL, "string(./model/@name)", ctxt); + name = virXPathString("string(./model/@name)", ctxt); if (name == NULL) { virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, _("Missing ancestor's name in CPU model %s"), @@ -682,7 +682,7 @@ x86ModelLoad(xmlXPathContextPtr ctxt, sizeof(*model->cpuid) * model->ncpuid); } - n = virXPathNodeSet(NULL, "./feature", ctxt, &nodes); + n = virXPathNodeSet("./feature", ctxt, &nodes); if (n < 0) goto ignore; diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 65c2b09..9edfcb4 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -667,7 +667,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName, if ((*response)->responseCode == 500) { (*response)->node = - virXPathNode(NULL, "/soapenv:Envelope/soapenv:Body/soapenv:Fault", + virXPathNode("/soapenv:Envelope/soapenv:Body/soapenv:Fault", xpathContext); if ((*response)->node == NULL) { @@ -705,7 +705,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName, goto failure; } - responseNode = virXPathNode(NULL, xpathExpression, xpathContext); + responseNode = virXPathNode(xpathExpression, xpathContext); if (responseNode == NULL) { ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, @@ -715,8 +715,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName, } xpathContext->node = responseNode; - (*response)->node = virXPathNode(NULL, "./vim:returnval", - xpathContext); + (*response)->node = virXPathNode("./vim:returnval", xpathContext); switch (occurrence) { case esxVI_Occurrence_RequiredItem: diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 98086f5..149fad3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -217,20 +217,20 @@ static int qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data) } if (!(monitorpath = - virXPathString(NULL, "string(./monitor[1]/@path)", ctxt))) { + virXPathString("string(./monitor[1]/@path)", ctxt))) { qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", _("no monitor path")); goto error; } - tmp = virXPathString(NULL, "string(./monitor[1]/@type)", ctxt); + tmp = virXPathString("string(./monitor[1]/@type)", ctxt); if (tmp) priv->monConfig->type = virDomainChrTypeFromString(tmp); else priv->monConfig->type = VIR_DOMAIN_CHR_TYPE_PTY; VIR_FREE(tmp); - if (virXPathBoolean(NULL, "count(./monitor[@json = '1']) > 0", ctxt)) { + if (virXPathBoolean("count(./monitor[@json = '1']) > 0", ctxt)) { priv->monJSON = 1; } else { priv->monJSON = 0; @@ -251,7 +251,7 @@ static int qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data) goto error; } - n = virXPathNodeSet(NULL, "./vcpus/vcpu", ctxt, &nodes); + n = virXPathNodeSet("./vcpus/vcpu", ctxt, &nodes); if (n < 0) goto error; if (n) { diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 1b0b2cd..3e7481d 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -626,12 +626,12 @@ caps_mockup(vahControl * ctl, const char *xmlStr) } ctxt->node = root; - ctl->hvm = virXPathString(NULL, "string(./os/type[1])", ctxt); + ctl->hvm = virXPathString("string(./os/type[1])", ctxt); if (!ctl->hvm || STRNEQ(ctl->hvm, "hvm")) { vah_error(ctl, 0, "os.type is not 'hvm'"); goto cleanup; } - ctl->arch = virXPathString(NULL, "string(./os/type[1]/@arch)", ctxt); + ctl->arch = virXPathString("string(./os/type[1]/@arch)", ctxt); if (!ctl->arch) { /* The XML we are given should have an arch, but in case it doesn't, * just use the host's arch. diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 14b467b..9df32e8 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -665,7 +665,7 @@ static int testOpenVolumesForPool(virConnectPtr conn, goto error; } - ret = virXPathNodeSet(conn, vol_xpath, ctxt, &vols); + ret = virXPathNodeSet(vol_xpath, ctxt, &vols); VIR_FREE(vol_xpath); if (ret < 0) { testError(NULL, VIR_ERR_XML_ERROR, @@ -805,7 +805,7 @@ static int testOpenFromFile(virConnectPtr conn, memmove(&privconn->nodeInfo, &defaultNodeInfo, sizeof(defaultNodeInfo)); nodeInfo = &privconn->nodeInfo; - ret = virXPathLong(conn, "string(/node/cpu/nodes[1])", ctxt, &l); + ret = virXPathLong("string(/node/cpu/nodes[1])", ctxt, &l); if (ret == 0) { nodeInfo->nodes = l; } else if (ret == -2) { @@ -813,7 +813,7 @@ static int testOpenFromFile(virConnectPtr conn, goto error; } - ret = virXPathLong(conn, "string(/node/cpu/sockets[1])", ctxt, &l); + ret = virXPathLong("string(/node/cpu/sockets[1])", ctxt, &l); if (ret == 0) { nodeInfo->sockets = l; } else if (ret == -2) { @@ -821,7 +821,7 @@ static int testOpenFromFile(virConnectPtr conn, goto error; } - ret = virXPathLong(conn, "string(/node/cpu/cores[1])", ctxt, &l); + ret = virXPathLong("string(/node/cpu/cores[1])", ctxt, &l); if (ret == 0) { nodeInfo->cores = l; } else if (ret == -2) { @@ -829,7 +829,7 @@ static int testOpenFromFile(virConnectPtr conn, goto error; } - ret = virXPathLong(conn, "string(/node/cpu/threads[1])", ctxt, &l); + ret = virXPathLong("string(/node/cpu/threads[1])", ctxt, &l); if (ret == 0) { nodeInfo->threads = l; } else if (ret == -2) { @@ -838,7 +838,7 @@ static int testOpenFromFile(virConnectPtr conn, } nodeInfo->cpus = nodeInfo->cores * nodeInfo->threads * nodeInfo->sockets * nodeInfo->nodes; - ret = virXPathLong(conn, "string(/node/cpu/active[1])", ctxt, &l); + ret = virXPathLong("string(/node/cpu/active[1])", ctxt, &l); if (ret == 0) { if (l < nodeInfo->cpus) { nodeInfo->cpus = l; @@ -847,7 +847,7 @@ static int testOpenFromFile(virConnectPtr conn, testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node active cpu")); goto error; } - ret = virXPathLong(conn, "string(/node/cpu/mhz[1])", ctxt, &l); + ret = virXPathLong("string(/node/cpu/mhz[1])", ctxt, &l); if (ret == 0) { nodeInfo->mhz = l; } else if (ret == -2) { @@ -855,7 +855,7 @@ static int testOpenFromFile(virConnectPtr conn, goto error; } - str = virXPathString(conn, "string(/node/cpu/model[1])", ctxt); + str = virXPathString("string(/node/cpu/model[1])", ctxt); if (str != NULL) { if (virStrcpyStatic(nodeInfo->model, str) == NULL) { testError(NULL, VIR_ERR_INTERNAL_ERROR, @@ -866,7 +866,7 @@ static int testOpenFromFile(virConnectPtr conn, VIR_FREE(str); } - ret = virXPathLong(conn, "string(/node/memory[1])", ctxt, &l); + ret = virXPathLong("string(/node/memory[1])", ctxt, &l); if (ret == 0) { nodeInfo->memory = l; } else if (ret == -2) { @@ -874,7 +874,7 @@ static int testOpenFromFile(virConnectPtr conn, goto error; } - ret = virXPathNodeSet(conn, "/node/domain", ctxt, &domains); + ret = virXPathNodeSet("/node/domain", ctxt, &domains); if (ret < 0) { testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node domain list")); goto error; @@ -918,7 +918,7 @@ static int testOpenFromFile(virConnectPtr conn, } VIR_FREE(domains); - ret = virXPathNodeSet(conn, "/node/network", ctxt, &networks); + ret = virXPathNodeSet("/node/network", ctxt, &networks); if (ret < 0) { testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node network list")); goto error; @@ -954,7 +954,7 @@ static int testOpenFromFile(virConnectPtr conn, VIR_FREE(networks); /* Parse interface definitions */ - ret = virXPathNodeSet(conn, "/node/interface", ctxt, &ifaces); + ret = virXPathNodeSet("/node/interface", ctxt, &ifaces); if (ret < 0) { testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node interface list")); goto error; @@ -990,7 +990,7 @@ static int testOpenFromFile(virConnectPtr conn, VIR_FREE(ifaces); /* Parse Storage Pool list */ - ret = virXPathNodeSet(conn, "/node/pool", ctxt, &pools); + ret = virXPathNodeSet("/node/pool", ctxt, &pools); if (ret < 0) { testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node pool list")); goto error; @@ -1041,7 +1041,7 @@ static int testOpenFromFile(virConnectPtr conn, } VIR_FREE(pools); - ret = virXPathNodeSet(conn, "/node/device", ctxt, &devs); + ret = virXPathNodeSet("/node/device", ctxt, &devs); if (ret < 0) { testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node device list")); goto error; diff --git a/src/util/xml.c b/src/util/xml.c index 0338373..46ea9aa 100644 --- a/src/util/xml.c +++ b/src/util/xml.c @@ -25,9 +25,9 @@ #define VIR_FROM_THIS VIR_FROM_XML -#define virXMLError(conn, code, fmt...) \ - virReportErrorHelper(conn, VIR_FROM_XML, code, __FILE__, \ - __FUNCTION__, __LINE__, fmt) +#define virXMLError(code, fmt...) \ + virReportErrorHelper(NULL, VIR_FROM_XML, code, __FILE__, \ + __FUNCTION__, __LINE__, fmt) /************************************************************************ @@ -47,8 +47,7 @@ * if the evaluation failed. */ char * -virXPathString(virConnectPtr conn, - const char *xpath, +virXPathString(const char *xpath, xmlXPathContextPtr ctxt) { xmlXPathObjectPtr obj; @@ -56,7 +55,7 @@ virXPathString(virConnectPtr conn, char *ret; if ((ctxt == NULL) || (xpath == NULL)) { - virXMLError(conn, VIR_ERR_INTERNAL_ERROR, + virXMLError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid parameter to virXPathString()")); return (NULL); } @@ -89,15 +88,14 @@ virXPathString(virConnectPtr conn, * the evaluation failed. */ char * -virXPathStringLimit(virConnectPtr conn, - const char *xpath, +virXPathStringLimit(const char *xpath, size_t maxlen, xmlXPathContextPtr ctxt) { - char *tmp = virXPathString(conn, xpath, ctxt); + char *tmp = virXPathString(xpath, ctxt); if (tmp != NULL && strlen(tmp) >= maxlen) { - virXMLError(conn, VIR_ERR_INTERNAL_ERROR, + virXMLError(VIR_ERR_INTERNAL_ERROR, _("\'%s\' value longer than %Zd bytes in virXPathStringLimit()"), xpath, maxlen); return NULL; @@ -118,8 +116,7 @@ virXPathStringLimit(virConnectPtr conn, * or -1 if the evaluation failed. */ int -virXPathNumber(virConnectPtr conn, - const char *xpath, +virXPathNumber(const char *xpath, xmlXPathContextPtr ctxt, double *value) { @@ -127,7 +124,7 @@ virXPathNumber(virConnectPtr conn, xmlNodePtr relnode; if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) { - virXMLError(conn, VIR_ERR_INTERNAL_ERROR, + virXMLError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid parameter to virXPathNumber()")); return (-1); } @@ -146,8 +143,7 @@ virXPathNumber(virConnectPtr conn, } static int -virXPathLongBase(virConnectPtr conn, - const char *xpath, +virXPathLongBase(const char *xpath, xmlXPathContextPtr ctxt, int base, long *value) @@ -157,7 +153,7 @@ virXPathLongBase(virConnectPtr conn, int ret = 0; if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) { - virXMLError(conn, VIR_ERR_INTERNAL_ERROR, + virXMLError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid parameter to virXPathLong()")); return (-1); } @@ -202,12 +198,11 @@ virXPathLongBase(virConnectPtr conn, * value doesn't have a long format. */ int -virXPathLong(virConnectPtr conn, - const char *xpath, +virXPathLong(const char *xpath, xmlXPathContextPtr ctxt, long *value) { - return virXPathLongBase(conn, xpath, ctxt, 10, value); + return virXPathLongBase(xpath, ctxt, 10, value); } /** @@ -224,17 +219,15 @@ virXPathLong(virConnectPtr conn, * value doesn't have a long format. */ int -virXPathLongHex(virConnectPtr conn, - const char *xpath, +virXPathLongHex(const char *xpath, xmlXPathContextPtr ctxt, long *value) { - return virXPathLongBase(conn, xpath, ctxt, 16, value); + return virXPathLongBase(xpath, ctxt, 16, value); } static int -virXPathULongBase(virConnectPtr conn, - const char *xpath, +virXPathULongBase(const char *xpath, xmlXPathContextPtr ctxt, int base, unsigned long *value) @@ -244,7 +237,7 @@ virXPathULongBase(virConnectPtr conn, int ret = 0; if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) { - virXMLError(conn, VIR_ERR_INTERNAL_ERROR, + virXMLError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid parameter to virXPathULong()")); return (-1); } @@ -289,12 +282,11 @@ virXPathULongBase(virConnectPtr conn, * value doesn't have a long format. */ int -virXPathULong(virConnectPtr conn, - const char *xpath, +virXPathULong(const char *xpath, xmlXPathContextPtr ctxt, unsigned long *value) { - return virXPathULongBase(conn, xpath, ctxt, 10, value); + return virXPathULongBase(xpath, ctxt, 10, value); } /** @@ -311,12 +303,11 @@ virXPathULong(virConnectPtr conn, * value doesn't have a long format. */ int -virXPathULongHex(virConnectPtr conn, - const char *xpath, +virXPathULongHex(const char *xpath, xmlXPathContextPtr ctxt, unsigned long *value) { - return virXPathULongBase(conn, xpath, ctxt, 16, value); + return virXPathULongBase(xpath, ctxt, 16, value); } /** @@ -332,8 +323,7 @@ virXPathULongHex(virConnectPtr conn, * value doesn't have a long format. */ int -virXPathULongLong(virConnectPtr conn, - const char *xpath, +virXPathULongLong(const char *xpath, xmlXPathContextPtr ctxt, unsigned long long *value) { @@ -342,7 +332,7 @@ virXPathULongLong(virConnectPtr conn, int ret = 0; if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) { - virXMLError(conn, VIR_ERR_INTERNAL_ERROR, + virXMLError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid parameter to virXPathULong()")); return (-1); } @@ -391,8 +381,7 @@ virXMLPropString(xmlNodePtr node, * Returns 0 if false, 1 if true, or -1 if the evaluation failed. */ int -virXPathBoolean(virConnectPtr conn, - const char *xpath, +virXPathBoolean(const char *xpath, xmlXPathContextPtr ctxt) { xmlXPathObjectPtr obj; @@ -400,7 +389,7 @@ virXPathBoolean(virConnectPtr conn, int ret; if ((ctxt == NULL) || (xpath == NULL)) { - virXMLError(conn, VIR_ERR_INTERNAL_ERROR, + virXMLError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid parameter to virXPathBoolean()")); return (-1); } @@ -429,8 +418,7 @@ virXPathBoolean(virConnectPtr conn, * Returns a pointer to the node or NULL if the evaluation failed. */ xmlNodePtr -virXPathNode(virConnectPtr conn, - const char *xpath, +virXPathNode(const char *xpath, xmlXPathContextPtr ctxt) { xmlXPathObjectPtr obj; @@ -438,7 +426,7 @@ virXPathNode(virConnectPtr conn, xmlNodePtr ret; if ((ctxt == NULL) || (xpath == NULL)) { - virXMLError(conn, VIR_ERR_INTERNAL_ERROR, + virXMLError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid parameter to virXPathNode()")); return (NULL); } @@ -469,8 +457,7 @@ virXPathNode(virConnectPtr conn, * must be freed) or -1 if the evaluation failed. */ int -virXPathNodeSet(virConnectPtr conn, - const char *xpath, +virXPathNodeSet(const char *xpath, xmlXPathContextPtr ctxt, xmlNodePtr **list) { @@ -479,7 +466,7 @@ virXPathNodeSet(virConnectPtr conn, int ret; if ((ctxt == NULL) || (xpath == NULL)) { - virXMLError(conn, VIR_ERR_INTERNAL_ERROR, + virXMLError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid parameter to virXPathNodeSet()")); return (-1); } diff --git a/src/util/xml.h b/src/util/xml.h index cddd42b..246672d 100644 --- a/src/util/xml.h +++ b/src/util/xml.h @@ -11,48 +11,36 @@ #include <libxml/tree.h> #include <libxml/xpath.h> -int virXPathBoolean (virConnectPtr conn, - const char *xpath, +int virXPathBoolean(const char *xpath, xmlXPathContextPtr ctxt); -char * virXPathString (virConnectPtr conn, - const char *xpath, +char * virXPathString(const char *xpath, xmlXPathContextPtr ctxt); -char * virXPathStringLimit(virConnectPtr conn, - const char *xpath, - size_t maxlen, - xmlXPathContextPtr ctxt); -int virXPathNumber (virConnectPtr conn, - const char *xpath, +char * virXPathStringLimit(const char *xpath, + size_t maxlen, + xmlXPathContextPtr ctxt); +int virXPathNumber(const char *xpath, xmlXPathContextPtr ctxt, double *value); -int virXPathLong (virConnectPtr conn, - const char *xpath, +int virXPathLong(const char *xpath, xmlXPathContextPtr ctxt, long *value); -int virXPathULong (virConnectPtr conn, - const char *xpath, +int virXPathULong(const char *xpath, xmlXPathContextPtr ctxt, unsigned long *value); -int virXPathULongLong(virConnectPtr conn, - const char *xpath, +int virXPathULongLong(const char *xpath, xmlXPathContextPtr ctxt, unsigned long long *value); -int virXPathLongHex (virConnectPtr conn, - const char *xpath, +int virXPathLongHex(const char *xpath, xmlXPathContextPtr ctxt, long *value); -int virXPathULongHex(virConnectPtr conn, - const char *xpath, +int virXPathULongHex(const char *xpath, xmlXPathContextPtr ctxt, unsigned long *value); -xmlNodePtr virXPathNode (virConnectPtr conn, - const char *xpath, +xmlNodePtr virXPathNode(const char *xpath, xmlXPathContextPtr ctxt); -int virXPathNodeSet (virConnectPtr conn, - const char *xpath, +int virXPathNodeSet(const char *xpath, xmlXPathContextPtr ctxt, xmlNodePtr **list); - char * virXMLPropString(xmlNodePtr node, const char *name); -- 1.6.3.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list