mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 18:45:16 +00:00
maint: simplify lots of libxml2 clients
Repetitive patterns should be factored. The sign of a good factorization is a change that kills 5x more lines than it adds :) * src/conf/domain_conf.c (virDomainDeviceDefParse) (virDomainSnapshotDefParseString): Use new convenience macros. * src/conf/storage_conf.c (virStoragePoolDefParseSourceString): Likewise. * src/cpu/cpu.c (cpuCompareXML, cpuBaselineXML): Likewise. * src/esx/esx_vi.c (esxVI_Context_Execute): Likewise. * src/qemu/qemu_migration.c (qemuMigrationCookieXMLParseStr): Likewise. * src/security/virt-aa-helper.c (caps_mockup): Likewise. * src/test/test_driver.c (testOpenFromFile): Likewise. * tests/cputest.c (cpuTestLoadXML, cpuTestLoadMultiXML): Likewise. * tools/virsh.c (cmdFreecell, makeCloneXML, cmdVNCDisplay) (cmdTTYConsole, cmdDetachInterface, cmdDetachDisk) (cmdSnapshotCreate, cmdSnapshotCreateAs, cmdSnapshotCurrent) (cmdSnapshotList, cmdSnapshotParent): Likewise.
This commit is contained in:
parent
751304e367
commit
d89dd42d51
@ -5385,17 +5385,10 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
|
|||||||
xmlXPathContextPtr ctxt = NULL;
|
xmlXPathContextPtr ctxt = NULL;
|
||||||
virDomainDeviceDefPtr dev = NULL;
|
virDomainDeviceDefPtr dev = NULL;
|
||||||
|
|
||||||
if (!(xml = virXMLParseString(xmlStr, "device.xml"))) {
|
if (!(xml = virXMLParseStringCtxt(xmlStr, "device.xml", &ctxt))) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
node = xmlDocGetRootElement(xml);
|
node = ctxt->node;
|
||||||
|
|
||||||
ctxt = xmlXPathNewContext(xml);
|
|
||||||
if (ctxt == NULL) {
|
|
||||||
virReportOOMError();
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
ctxt->node = xmlDocGetRootElement(xml);
|
|
||||||
|
|
||||||
if (VIR_ALLOC(dev) < 0) {
|
if (VIR_ALLOC(dev) < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
@ -10968,23 +10961,16 @@ virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr,
|
|||||||
char *creation = NULL, *state = NULL;
|
char *creation = NULL, *state = NULL;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
xml = virXMLParse(NULL, xmlStr, "domainsnapshot.xml");
|
xml = virXMLParseCtxt(NULL, xmlStr, "domainsnapshot.xml", &ctxt);
|
||||||
if (!xml) {
|
if (!xml) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctxt = xmlXPathNewContext(xml);
|
|
||||||
if (ctxt == NULL) {
|
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0) {
|
if (VIR_ALLOC(def) < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctxt->node = xmlDocGetRootElement(xml);
|
|
||||||
if (!xmlStrEqual(ctxt->node->name, BAD_CAST "domainsnapshot")) {
|
if (!xmlStrEqual(ctxt->node->name, BAD_CAST "domainsnapshot")) {
|
||||||
virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("domainsnapshot"));
|
virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("domainsnapshot"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -505,13 +505,7 @@ virStoragePoolDefParseSourceString(const char *srcSpec,
|
|||||||
xmlXPathContextPtr xpath_ctxt = NULL;
|
xmlXPathContextPtr xpath_ctxt = NULL;
|
||||||
virStoragePoolSourcePtr def = NULL, ret = NULL;
|
virStoragePoolSourcePtr def = NULL, ret = NULL;
|
||||||
|
|
||||||
if (!(doc = virXMLParseString(srcSpec, "srcSpec.xml"))) {
|
if (!(doc = virXMLParseStringCtxt(srcSpec, "srcSpec.xml", &xpath_ctxt))) {
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
xpath_ctxt = xmlXPathNewContext(doc);
|
|
||||||
if (xpath_ctxt == NULL) {
|
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* cpu.c: internal functions for CPU manipulation
|
* cpu.c: internal functions for CPU manipulation
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009--2010 Red Hat, Inc.
|
* Copyright (C) 2009-2011 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -76,16 +76,9 @@ cpuCompareXML(virCPUDefPtr host,
|
|||||||
|
|
||||||
VIR_DEBUG("host=%p, xml=%s", host, NULLSTR(xml));
|
VIR_DEBUG("host=%p, xml=%s", host, NULLSTR(xml));
|
||||||
|
|
||||||
if (!(doc = virXMLParseString(xml, "cpu.xml")))
|
if (!(doc = virXMLParseStringCtxt(xml, "cpu.xml", &ctxt)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((ctxt = xmlXPathNewContext(doc)) == NULL) {
|
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctxt->node = xmlDocGetRootElement(doc);
|
|
||||||
|
|
||||||
cpu = virCPUDefParseXML(ctxt->node, ctxt, VIR_CPU_TYPE_AUTO);
|
cpu = virCPUDefParseXML(ctxt->node, ctxt, VIR_CPU_TYPE_AUTO);
|
||||||
if (cpu == NULL)
|
if (cpu == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -311,14 +304,9 @@ cpuBaselineXML(const char **xmlCPUs,
|
|||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
for (i = 0; i < ncpus; i++) {
|
for (i = 0; i < ncpus; i++) {
|
||||||
if (!(doc = virXMLParseString(xmlCPUs[i], "cpu.xml")))
|
if (!(doc = virXMLParseStringCtxt(xmlCPUs[i], "cpu.xml", &ctxt)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if ((ctxt = xmlXPathNewContext(doc)) == NULL)
|
|
||||||
goto no_memory;
|
|
||||||
|
|
||||||
ctxt->node = xmlDocGetRootElement(doc);
|
|
||||||
|
|
||||||
cpus[i] = virCPUDefParseXML(ctxt->node, ctxt, VIR_CPU_TYPE_HOST);
|
cpus[i] = virCPUDefParseXML(ctxt->node, ctxt, VIR_CPU_TYPE_HOST);
|
||||||
if (cpus[i] == NULL)
|
if (cpus[i] == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -910,21 +910,14 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
|
|||||||
(*response)->content = virBufferContentAndReset(&buffer);
|
(*response)->content = virBufferContentAndReset(&buffer);
|
||||||
|
|
||||||
if ((*response)->responseCode == 500 || (*response)->responseCode == 200) {
|
if ((*response)->responseCode == 500 || (*response)->responseCode == 200) {
|
||||||
(*response)->document = virXMLParseString((*response)->content,
|
(*response)->document = virXMLParseStringCtxt((*response)->content,
|
||||||
"esx.xml");
|
"esx.xml",
|
||||||
|
&xpathContext);
|
||||||
|
|
||||||
if ((*response)->document == NULL) {
|
if ((*response)->document == NULL) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
xpathContext = xmlXPathNewContext((*response)->document);
|
|
||||||
|
|
||||||
if (xpathContext == NULL) {
|
|
||||||
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("Could not create XPath context"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
xmlXPathRegisterNs(xpathContext, BAD_CAST "soapenv",
|
xmlXPathRegisterNs(xpathContext, BAD_CAST "soapenv",
|
||||||
BAD_CAST "http://schemas.xmlsoap.org/soap/envelope/");
|
BAD_CAST "http://schemas.xmlsoap.org/soap/envelope/");
|
||||||
xmlXPathRegisterNs(xpathContext, BAD_CAST "vim", BAD_CAST "urn:vim25");
|
xmlXPathRegisterNs(xpathContext, BAD_CAST "vim", BAD_CAST "urn:vim25");
|
||||||
|
@ -602,16 +602,9 @@ qemuMigrationCookieXMLParseStr(qemuMigrationCookiePtr mig,
|
|||||||
|
|
||||||
VIR_DEBUG("xml=%s", NULLSTR(xml));
|
VIR_DEBUG("xml=%s", NULLSTR(xml));
|
||||||
|
|
||||||
if (!(doc = virXMLParseString(xml, "qemumigration.xml")))
|
if (!(doc = virXMLParseStringCtxt(xml, "qemumigration.xml", &ctxt)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((ctxt = xmlXPathNewContext(doc)) == NULL) {
|
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctxt->node = xmlDocGetRootElement(doc);
|
|
||||||
|
|
||||||
ret = qemuMigrationCookieXMLParse(mig, ctxt, flags);
|
ret = qemuMigrationCookieXMLParse(mig, ctxt, flags);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -640,24 +640,16 @@ caps_mockup(vahControl * ctl, const char *xmlStr)
|
|||||||
int rc = -1;
|
int rc = -1;
|
||||||
xmlDocPtr xml = NULL;
|
xmlDocPtr xml = NULL;
|
||||||
xmlXPathContextPtr ctxt = NULL;
|
xmlXPathContextPtr ctxt = NULL;
|
||||||
xmlNodePtr root;
|
|
||||||
|
|
||||||
if (!(xml = virXMLParseString(xmlStr, "domain.xml"))) {
|
if (!(xml = virXMLParseStringCtxt(xmlStr, "domain.xml", &ctxt))) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
root = xmlDocGetRootElement(xml);
|
if (!xmlStrEqual(ctxt->node->name, BAD_CAST "domain")) {
|
||||||
if (!xmlStrEqual(root->name, BAD_CAST "domain")) {
|
|
||||||
vah_error(NULL, 0, _("incorrect root element"));
|
vah_error(NULL, 0, _("incorrect root element"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ctxt = xmlXPathNewContext(xml)) == NULL) {
|
|
||||||
vah_error(ctl, 0, _("could not allocate memory"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
ctxt->node = root;
|
|
||||||
|
|
||||||
/* Quick sanity check for some required elements */
|
/* Quick sanity check for some required elements */
|
||||||
if (verify_xpath_context(ctxt) != 0)
|
if (verify_xpath_context(ctxt) != 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -742,7 +742,6 @@ static int testOpenFromFile(virConnectPtr conn,
|
|||||||
long l;
|
long l;
|
||||||
char *str;
|
char *str;
|
||||||
xmlDocPtr xml = NULL;
|
xmlDocPtr xml = NULL;
|
||||||
xmlNodePtr root = NULL;
|
|
||||||
xmlNodePtr *domains = NULL, *networks = NULL, *ifaces = NULL,
|
xmlNodePtr *domains = NULL, *networks = NULL, *ifaces = NULL,
|
||||||
*pools = NULL, *devs = NULL;
|
*pools = NULL, *devs = NULL;
|
||||||
xmlXPathContextPtr ctxt = NULL;
|
xmlXPathContextPtr ctxt = NULL;
|
||||||
@ -771,24 +770,16 @@ static int testOpenFromFile(virConnectPtr conn,
|
|||||||
if (!(privconn->caps = testBuildCapabilities(conn)))
|
if (!(privconn->caps = testBuildCapabilities(conn)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (!(xml = virXMLParseFile(file))) {
|
if (!(xml = virXMLParseFileCtxt(file, &ctxt))) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
root = xmlDocGetRootElement(xml);
|
if (!xmlStrEqual(ctxt->node->name, BAD_CAST "node")) {
|
||||||
if ((root == NULL) || (!xmlStrEqual(root->name, BAD_CAST "node"))) {
|
|
||||||
testError(VIR_ERR_XML_ERROR, "%s",
|
testError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("Root element is not 'node'"));
|
_("Root element is not 'node'"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctxt = xmlXPathNewContext(xml);
|
|
||||||
if (ctxt == NULL) {
|
|
||||||
testError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("creating xpath context"));
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
privconn->nextDomID = 1;
|
privconn->nextDomID = 1;
|
||||||
privconn->numCells = 0;
|
privconn->numCells = 0;
|
||||||
if ((privconn->path = strdup(file)) == NULL) {
|
if ((privconn->path = strdup(file)) == NULL) {
|
||||||
|
@ -96,11 +96,9 @@ cpuTestLoadXML(const char *arch, const char *name)
|
|||||||
if (virAsprintf(&xml, "%s/cputestdata/%s-%s.xml", abs_srcdir, arch, name) < 0)
|
if (virAsprintf(&xml, "%s/cputestdata/%s-%s.xml", abs_srcdir, arch, name) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(doc = virXMLParseFile(xml)) ||
|
if (!(doc = virXMLParseFileCtxt(xml, &ctxt)))
|
||||||
!(ctxt = xmlXPathNewContext(doc)))
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ctxt->node = xmlDocGetRootElement(doc);
|
|
||||||
cpu = virCPUDefParseXML(ctxt->node, ctxt, VIR_CPU_TYPE_AUTO);
|
cpu = virCPUDefParseXML(ctxt->node, ctxt, VIR_CPU_TYPE_AUTO);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -127,12 +125,9 @@ cpuTestLoadMultiXML(const char *arch,
|
|||||||
if (virAsprintf(&xml, "%s/cputestdata/%s-%s.xml", abs_srcdir, arch, name) < 0)
|
if (virAsprintf(&xml, "%s/cputestdata/%s-%s.xml", abs_srcdir, arch, name) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(doc = virXMLParseFile(xml)) ||
|
if (!(doc = virXMLParseFileCtxt(xml, &ctxt)))
|
||||||
!(ctxt = xmlXPathNewContext(doc)))
|
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
ctxt->node = xmlDocGetRootElement(doc);
|
|
||||||
|
|
||||||
n = virXPathNodeSet("/cpuTest/cpu", ctxt, &nodes);
|
n = virXPathNodeSet("/cpuTest/cpu", ctxt, &nodes);
|
||||||
if (n <= 0 || !(cpus = calloc(n, sizeof(virCPUDefPtr))))
|
if (n <= 0 || !(cpus = calloc(n, sizeof(virCPUDefPtr))))
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -67,6 +67,8 @@ static char *progname;
|
|||||||
#define VSH_PROMPT_RW "virsh # "
|
#define VSH_PROMPT_RW "virsh # "
|
||||||
#define VSH_PROMPT_RO "virsh > "
|
#define VSH_PROMPT_RO "virsh > "
|
||||||
|
|
||||||
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||||
|
|
||||||
#define GETTIMEOFDAY(T) gettimeofday(T, NULL)
|
#define GETTIMEOFDAY(T) gettimeofday(T, NULL)
|
||||||
#define DIFF_MSEC(T, U) \
|
#define DIFF_MSEC(T, U) \
|
||||||
((((int) ((T)->tv_sec - (U)->tv_sec)) * 1000000.0 + \
|
((((int) ((T)->tv_sec - (U)->tv_sec)) * 1000000.0 + \
|
||||||
@ -2901,16 +2903,11 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
xml = xmlReadDoc((const xmlChar *) cap_xml, "node.xml", NULL,
|
xml = virXMLParseStringCtxt(cap_xml, "node.xml", &ctxt);
|
||||||
XML_PARSE_NOENT | XML_PARSE_NONET |
|
|
||||||
XML_PARSE_NOWARNING);
|
|
||||||
|
|
||||||
if (!xml) {
|
if (!xml) {
|
||||||
vshError(ctl, "%s", _("unable to get node capabilities"));
|
vshError(ctl, "%s", _("unable to get node capabilities"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctxt = xmlXPathNewContext(xml);
|
|
||||||
nodes_cnt = virXPathNodeSet("/capabilities/host/topology/cells/cell",
|
nodes_cnt = virXPathNodeSet("/capabilities/host/topology/cells/cell",
|
||||||
ctxt, &nodes);
|
ctxt, &nodes);
|
||||||
|
|
||||||
@ -8404,13 +8401,9 @@ makeCloneXML(const char *origxml, const char *newname) {
|
|||||||
xmlChar *newxml = NULL;
|
xmlChar *newxml = NULL;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
doc = xmlReadDoc((const xmlChar *) origxml, "domain.xml", NULL,
|
doc = virXMLParseStringCtxt(origxml, "domain.xml", &ctxt);
|
||||||
XML_PARSE_NOENT | XML_PARSE_NONET | XML_PARSE_NOWARNING);
|
|
||||||
if (!doc)
|
if (!doc)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
ctxt = xmlXPathNewContext(doc);
|
|
||||||
if (!ctxt)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
obj = xmlXPathEval(BAD_CAST "/volume/name", ctxt);
|
obj = xmlXPathEval(BAD_CAST "/volume/name", ctxt);
|
||||||
if ((obj == NULL) || (obj->nodesetval == NULL) ||
|
if ((obj == NULL) || (obj->nodesetval == NULL) ||
|
||||||
@ -10199,15 +10192,10 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!doc)
|
if (!doc)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
xml = xmlReadDoc((const xmlChar *) doc, "domain.xml", NULL,
|
xml = virXMLParseStringCtxt(doc, "domain.xml", &ctxt);
|
||||||
XML_PARSE_NOENT | XML_PARSE_NONET |
|
|
||||||
XML_PARSE_NOWARNING);
|
|
||||||
VIR_FREE(doc);
|
VIR_FREE(doc);
|
||||||
if (!xml)
|
if (!xml)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
ctxt = xmlXPathNewContext(xml);
|
|
||||||
if (!ctxt)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
obj = xmlXPathEval(BAD_CAST "string(/domain/devices/graphics[@type='vnc']/@port)", ctxt);
|
obj = xmlXPathEval(BAD_CAST "string(/domain/devices/graphics[@type='vnc']/@port)", ctxt);
|
||||||
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
|
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
|
||||||
@ -10272,15 +10260,10 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!doc)
|
if (!doc)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
xml = xmlReadDoc((const xmlChar *) doc, "domain.xml", NULL,
|
xml = virXMLParseStringCtxt(doc, "domain.xml", &ctxt);
|
||||||
XML_PARSE_NOENT | XML_PARSE_NONET |
|
|
||||||
XML_PARSE_NOWARNING);
|
|
||||||
VIR_FREE(doc);
|
VIR_FREE(doc);
|
||||||
if (!xml)
|
if (!xml)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
ctxt = xmlXPathNewContext(xml);
|
|
||||||
if (!ctxt)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
obj = xmlXPathEval(BAD_CAST "string(/domain/devices/console/@tty)", ctxt);
|
obj = xmlXPathEval(BAD_CAST "string(/domain/devices/console/@tty)", ctxt);
|
||||||
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
|
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
|
||||||
@ -10664,19 +10647,12 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!doc)
|
if (!doc)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
xml = xmlReadDoc((const xmlChar *) doc, "domain.xml", NULL,
|
xml = virXMLParseStringCtxt(doc, "domain.xml", &ctxt);
|
||||||
XML_PARSE_NOENT | XML_PARSE_NONET |
|
|
||||||
XML_PARSE_NOWARNING);
|
|
||||||
VIR_FREE(doc);
|
VIR_FREE(doc);
|
||||||
if (!xml) {
|
if (!xml) {
|
||||||
vshError(ctl, "%s", _("Failed to get interface information"));
|
vshError(ctl, "%s", _("Failed to get interface information"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
ctxt = xmlXPathNewContext(xml);
|
|
||||||
if (!ctxt) {
|
|
||||||
vshError(ctl, "%s", _("Failed to get interface information"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "/domain/devices/interface[@type='%s']", type);
|
snprintf(buf, sizeof(buf), "/domain/devices/interface[@type='%s']", type);
|
||||||
obj = xmlXPathEval(BAD_CAST buf, ctxt);
|
obj = xmlXPathEval(BAD_CAST buf, ctxt);
|
||||||
@ -11138,19 +11114,12 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!doc)
|
if (!doc)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
xml = xmlReadDoc((const xmlChar *) doc, "domain.xml", NULL,
|
xml = virXMLParseStringCtxt(doc, "domain.xml", &ctxt);
|
||||||
XML_PARSE_NOENT | XML_PARSE_NONET |
|
|
||||||
XML_PARSE_NOWARNING);
|
|
||||||
VIR_FREE(doc);
|
VIR_FREE(doc);
|
||||||
if (!xml) {
|
if (!xml) {
|
||||||
vshError(ctl, "%s", _("Failed to get disk information"));
|
vshError(ctl, "%s", _("Failed to get disk information"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
ctxt = xmlXPathNewContext(xml);
|
|
||||||
if (!ctxt) {
|
|
||||||
vshError(ctl, "%s", _("Failed to get disk information"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
obj = xmlXPathEval(BAD_CAST "/domain/devices/disk", ctxt);
|
obj = xmlXPathEval(BAD_CAST "/domain/devices/disk", ctxt);
|
||||||
if ((obj == NULL) || (obj->type != XPATH_NODESET) ||
|
if ((obj == NULL) || (obj->type != XPATH_NODESET) ||
|
||||||
@ -11865,14 +11834,9 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!doc)
|
if (!doc)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
xml = xmlReadDoc((const xmlChar *) doc, "domainsnapshot.xml", NULL,
|
xml = virXMLParseStringCtxt(doc, "domainsnapshot.xml", &ctxt);
|
||||||
XML_PARSE_NOENT | XML_PARSE_NONET |
|
|
||||||
XML_PARSE_NOWARNING);
|
|
||||||
if (!xml)
|
if (!xml)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
ctxt = xmlXPathNewContext(xml);
|
|
||||||
if (!ctxt)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
name = virXPathString("string(/domainsnapshot/name)", ctxt);
|
name = virXPathString("string(/domainsnapshot/name)", ctxt);
|
||||||
if (!name) {
|
if (!name) {
|
||||||
@ -11974,14 +11938,9 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!doc)
|
if (!doc)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
xml = xmlReadDoc((const xmlChar *) doc, "domainsnapshot.xml", NULL,
|
xml = virXMLParseStringCtxt(doc, "domainsnapshot.xml", &ctxt);
|
||||||
XML_PARSE_NOENT | XML_PARSE_NONET |
|
|
||||||
XML_PARSE_NOWARNING);
|
|
||||||
if (!xml)
|
if (!xml)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
ctxt = xmlXPathNewContext(xml);
|
|
||||||
if (!ctxt)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
parsed_name = virXPathString("string(/domainsnapshot/name)", ctxt);
|
parsed_name = virXPathString("string(/domainsnapshot/name)", ctxt);
|
||||||
if (!parsed_name) {
|
if (!parsed_name) {
|
||||||
@ -12056,16 +12015,9 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
|
|||||||
xmlDocPtr xmldoc = NULL;
|
xmlDocPtr xmldoc = NULL;
|
||||||
xmlXPathContextPtr ctxt = NULL;
|
xmlXPathContextPtr ctxt = NULL;
|
||||||
|
|
||||||
xmldoc = xmlReadDoc((const xmlChar *) xml, "domainsnapshot.xml",
|
xmldoc = virXMLParseStringCtxt(xml, "domainsnapshot.xml", &ctxt);
|
||||||
NULL, XML_PARSE_NOENT | XML_PARSE_NONET |
|
|
||||||
XML_PARSE_NOWARNING);
|
|
||||||
if (!xmldoc)
|
if (!xmldoc)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
ctxt = xmlXPathNewContext(xmldoc);
|
|
||||||
if (!ctxt) {
|
|
||||||
xmlFreeDoc(xmldoc);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
name = virXPathString("string(/domainsnapshot/name)", ctxt);
|
name = virXPathString("string(/domainsnapshot/name)", ctxt);
|
||||||
xmlXPathFreeContext(ctxt);
|
xmlXPathFreeContext(ctxt);
|
||||||
@ -12165,14 +12117,9 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!doc)
|
if (!doc)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
xml = xmlReadDoc((const xmlChar *) doc, "domainsnapshot.xml", NULL,
|
xml = virXMLParseStringCtxt(doc, "domainsnapshot.xml", &ctxt);
|
||||||
XML_PARSE_NOENT | XML_PARSE_NONET |
|
|
||||||
XML_PARSE_NOWARNING);
|
|
||||||
if (!xml)
|
if (!xml)
|
||||||
continue;
|
continue;
|
||||||
ctxt = xmlXPathNewContext(xml);
|
|
||||||
if (!ctxt)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
state = virXPathString("string(/domainsnapshot/state)", ctxt);
|
state = virXPathString("string(/domainsnapshot/state)", ctxt);
|
||||||
if (state == NULL)
|
if (state == NULL)
|
||||||
@ -12312,14 +12259,9 @@ cmdSnapshotParent(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!xml)
|
if (!xml)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
xmldoc = xmlReadDoc((const xmlChar *) xml, "domainsnapshot.xml", NULL,
|
xmldoc = virXMLParseStringCtxt(xml, "domainsnapshot.xml", &ctxt);
|
||||||
XML_PARSE_NOENT | XML_PARSE_NONET |
|
|
||||||
XML_PARSE_NOWARNING);
|
|
||||||
if (!xmldoc)
|
if (!xmldoc)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
ctxt = xmlXPathNewContext(xmldoc);
|
|
||||||
if (!ctxt)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
parent = virXPathString("string(/domainsnapshot/parent/name)", ctxt);
|
parent = virXPathString("string(/domainsnapshot/parent/name)", ctxt);
|
||||||
if (!parent)
|
if (!parent)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user