mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
Don't overwrite error message from 'virXPathNodeSet'
'virXPathNodeSet' returns -1 only when 'ctxt' or 'xpath' are NULL or when the 'xpath' string is invalid. Both are programming errors. It doesn't make sense for the code to overwrite the error message for anything supposedly more relevant. The majority of calls to 'virXPathNodeSet' already didn't do this, so this patch fixes the rest to prevent it from spreading again. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
9eda33161f
commit
a9f76d6ab7
@ -17780,11 +17780,8 @@ virDomainResctrlMonDefParse(virDomainDef *def,
|
||||
|
||||
ctxt->node = node;
|
||||
|
||||
if ((n = virXPathNodeSet("./monitor", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Cannot extract monitor nodes"));
|
||||
if ((n = virXPathNodeSet("./monitor", ctxt, &nodes)) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
domresmon = g_new0(virDomainResctrlMonDef, 1);
|
||||
@ -17912,11 +17909,8 @@ virDomainCachetuneDefParse(virDomainDef *def,
|
||||
if (virBitmapIsAllClear(vcpus))
|
||||
return 0;
|
||||
|
||||
if ((n = virXPathNodeSet("./cache", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Cannot extract cache nodes under cachetune"));
|
||||
if ((n = virXPathNodeSet("./cache", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virDomainResctrlVcpuMatch(def, vcpus, &resctrl) < 0)
|
||||
return -1;
|
||||
@ -18182,11 +18176,8 @@ virDomainDefParseMemory(virDomainDef *def,
|
||||
|
||||
if (virXPathNode("./memoryBacking/hugepages", ctxt)) {
|
||||
/* hugepages will be used */
|
||||
if ((n = virXPathNodeSet("./memoryBacking/hugepages/page", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("cannot extract hugepages nodes"));
|
||||
if ((n = virXPathNodeSet("./memoryBacking/hugepages/page", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n) {
|
||||
def->mem.hugepages = g_new0(virDomainHugePage, n);
|
||||
@ -18270,11 +18261,8 @@ virDomainMemorytuneDefParse(virDomainDef *def,
|
||||
if (virBitmapIsAllClear(vcpus))
|
||||
return 0;
|
||||
|
||||
if ((n = virXPathNodeSet("./node", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Cannot extract memory nodes under memorytune"));
|
||||
if ((n = virXPathNodeSet("./node", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virDomainResctrlVcpuMatch(def, vcpus, &resctrl) < 0)
|
||||
return -1;
|
||||
@ -18341,11 +18329,9 @@ virDomainDefTunablesParse(virDomainDef *def,
|
||||
&def->blkio.weight) < 0)
|
||||
def->blkio.weight = 0;
|
||||
|
||||
if ((n = virXPathNodeSet("./blkiotune/device", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("cannot extract blkiotune nodes"));
|
||||
if ((n = virXPathNodeSet("./blkiotune/device", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n)
|
||||
def->blkio.devices = g_new0(virBlkioDevice, n);
|
||||
|
||||
@ -18456,11 +18442,8 @@ virDomainDefTunablesParse(virDomainDef *def,
|
||||
}
|
||||
VIR_FREE(nodes);
|
||||
|
||||
if ((n = virXPathNodeSet("./cputune/emulatorpin", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("cannot extract emulatorpin nodes"));
|
||||
if ((n = virXPathNodeSet("./cputune/emulatorpin", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n) {
|
||||
if (n > 1) {
|
||||
@ -18475,11 +18458,8 @@ virDomainDefTunablesParse(virDomainDef *def,
|
||||
VIR_FREE(nodes);
|
||||
|
||||
|
||||
if ((n = virXPathNodeSet("./cputune/iothreadpin", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("cannot extract iothreadpin nodes"));
|
||||
if ((n = virXPathNodeSet("./cputune/iothreadpin", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (virDomainIOThreadPinDefParseXML(nodes[i], def) < 0)
|
||||
@ -18487,11 +18467,8 @@ virDomainDefTunablesParse(virDomainDef *def,
|
||||
}
|
||||
VIR_FREE(nodes);
|
||||
|
||||
if ((n = virXPathNodeSet("./cputune/vcpusched", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("cannot extract vcpusched nodes"));
|
||||
if ((n = virXPathNodeSet("./cputune/vcpusched", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (virDomainVcpuThreadSchedParse(nodes[i], def) < 0)
|
||||
@ -18499,11 +18476,8 @@ virDomainDefTunablesParse(virDomainDef *def,
|
||||
}
|
||||
VIR_FREE(nodes);
|
||||
|
||||
if ((n = virXPathNodeSet("./cputune/iothreadsched", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("cannot extract iothreadsched nodes"));
|
||||
if ((n = virXPathNodeSet("./cputune/iothreadsched", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (virDomainIOThreadSchedParse(nodes[i], def) < 0)
|
||||
@ -18511,11 +18485,8 @@ virDomainDefTunablesParse(virDomainDef *def,
|
||||
}
|
||||
VIR_FREE(nodes);
|
||||
|
||||
if ((n = virXPathNodeSet("./cputune/emulatorsched", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("cannot extract emulatorsched nodes"));
|
||||
if ((n = virXPathNodeSet("./cputune/emulatorsched", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n) {
|
||||
if (n > 1) {
|
||||
@ -18529,11 +18500,8 @@ virDomainDefTunablesParse(virDomainDef *def,
|
||||
}
|
||||
VIR_FREE(nodes);
|
||||
|
||||
if ((n = virXPathNodeSet("./cputune/cachetune", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("cannot extract cachetune nodes"));
|
||||
if ((n = virXPathNodeSet("./cputune/cachetune", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (virDomainCachetuneDefParse(def, ctxt, nodes[i], flags) < 0)
|
||||
@ -18541,11 +18509,8 @@ virDomainDefTunablesParse(virDomainDef *def,
|
||||
}
|
||||
VIR_FREE(nodes);
|
||||
|
||||
if ((n = virXPathNodeSet("./cputune/memorytune", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("cannot extract memorytune nodes"));
|
||||
if ((n = virXPathNodeSet("./cputune/memorytune", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (virDomainMemorytuneDefParse(def, ctxt, nodes[i], flags) < 0)
|
||||
@ -18849,11 +18814,8 @@ virDomainDefParseXML(xmlXPathContextPtr ctxt,
|
||||
!virDomainIOThreadIDArrayHasPin(def))
|
||||
def->placement_mode = VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO;
|
||||
|
||||
if ((n = virXPathNodeSet("./resource", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("cannot extract resource nodes"));
|
||||
if ((n = virXPathNodeSet("./resource", ctxt, &nodes)) < 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (n > 1) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
@ -18901,11 +18863,9 @@ virDomainDefParseXML(xmlXPathContextPtr ctxt,
|
||||
return NULL;
|
||||
|
||||
/* analysis of the resource leases */
|
||||
if ((n = virXPathNodeSet("./devices/lease", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("cannot extract device leases"));
|
||||
if ((n = virXPathNodeSet("./devices/lease", ctxt, &nodes)) < 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (n)
|
||||
def->leases = g_new0(virDomainLeaseDef *, n);
|
||||
for (i = 0; i < n; i++) {
|
||||
@ -19024,11 +18984,9 @@ virDomainDefParseXML(xmlXPathContextPtr ctxt,
|
||||
}
|
||||
VIR_FREE(nodes);
|
||||
|
||||
if ((n = virXPathNodeSet("./devices/console", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("cannot extract console devices"));
|
||||
if ((n = virXPathNodeSet("./devices/console", ctxt, &nodes)) < 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (n)
|
||||
def->consoles = g_new0(virDomainChrDef *, n);
|
||||
|
||||
|
@ -892,13 +892,9 @@ virNetworkDNSDefParseXML(const char *networkName,
|
||||
&def->forwardPlainNames) < 0)
|
||||
return -1;
|
||||
|
||||
nfwds = virXPathNodeSet("./forwarder", ctxt, &fwdNodes);
|
||||
if (nfwds < 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("invalid <forwarder> element found in <dns> of network %1$s"),
|
||||
networkName);
|
||||
if ((nfwds = virXPathNodeSet("./forwarder", ctxt, &fwdNodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nfwds > 0) {
|
||||
def->forwarders = g_new0(virNetworkDNSForwarder, nfwds);
|
||||
|
||||
@ -922,13 +918,9 @@ virNetworkDNSDefParseXML(const char *networkName,
|
||||
}
|
||||
}
|
||||
|
||||
nhosts = virXPathNodeSet("./host", ctxt, &hostNodes);
|
||||
if (nhosts < 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("invalid <host> element found in <dns> of network %1$s"),
|
||||
networkName);
|
||||
if ((nhosts = virXPathNodeSet("./host", ctxt, &hostNodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nhosts > 0) {
|
||||
def->hosts = g_new0(virNetworkDNSHostDef, nhosts);
|
||||
|
||||
@ -941,13 +933,9 @@ virNetworkDNSDefParseXML(const char *networkName,
|
||||
}
|
||||
}
|
||||
|
||||
nsrvs = virXPathNodeSet("./srv", ctxt, &srvNodes);
|
||||
if (nsrvs < 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("invalid <srv> element found in <dns> of network %1$s"),
|
||||
networkName);
|
||||
if ((nsrvs = virXPathNodeSet("./srv", ctxt, &srvNodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nsrvs > 0) {
|
||||
def->srvs = g_new0(virNetworkDNSSrvDef, nsrvs);
|
||||
|
||||
@ -960,13 +948,9 @@ virNetworkDNSDefParseXML(const char *networkName,
|
||||
}
|
||||
}
|
||||
|
||||
ntxts = virXPathNodeSet("./txt", ctxt, &txtNodes);
|
||||
if (ntxts < 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("invalid <txt> element found in <dns> of network %1$s"),
|
||||
networkName);
|
||||
if ((ntxts = virXPathNodeSet("./txt", ctxt, &txtNodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ntxts > 0) {
|
||||
def->txts = g_new0(virNetworkDNSTxtDef, ntxts);
|
||||
|
||||
@ -1222,13 +1206,10 @@ virNetworkForwardNatDefParseXML(const char *networkName,
|
||||
return -1;
|
||||
|
||||
/* addresses for SNAT */
|
||||
nNatAddrs = virXPathNodeSet("./address", ctxt, &natAddrNodes);
|
||||
if (nNatAddrs < 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("invalid <address> element found in <forward> of network %1$s"),
|
||||
networkName);
|
||||
if ((nNatAddrs = virXPathNodeSet("./address", ctxt, &natAddrNodes)) < 0)
|
||||
return -1;
|
||||
} else if (nNatAddrs > 1) {
|
||||
|
||||
if (nNatAddrs > 1) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("Only one <address> element is allowed in <nat> in <forward> in network %1$s"),
|
||||
networkName);
|
||||
@ -1284,13 +1265,10 @@ virNetworkForwardNatDefParseXML(const char *networkName,
|
||||
}
|
||||
|
||||
/* ports for SNAT and MASQUERADE */
|
||||
nNatPorts = virXPathNodeSet("./port", ctxt, &natPortNodes);
|
||||
if (nNatPorts < 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("invalid <port> element found in <forward> of network %1$s"),
|
||||
networkName);
|
||||
if ((nNatPorts = virXPathNodeSet("./port", ctxt, &natPortNodes)) < 0)
|
||||
return -1;
|
||||
} else if (nNatPorts > 1) {
|
||||
|
||||
if (nNatPorts > 1) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("Only one <port> element is allowed in <nat> in <forward> in network %1$s"),
|
||||
networkName);
|
||||
@ -1358,37 +1336,19 @@ virNetworkForwardDefParseXML(const char *networkName,
|
||||
}
|
||||
|
||||
/* bridge and hostdev modes can use a pool of physical interfaces */
|
||||
nForwardIfs = virXPathNodeSet("./interface", ctxt, &forwardIfNodes);
|
||||
if (nForwardIfs < 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("invalid <interface> element found in <forward> of network %1$s"),
|
||||
networkName);
|
||||
if ((nForwardIfs = virXPathNodeSet("./interface", ctxt, &forwardIfNodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
nForwardAddrs = virXPathNodeSet("./address", ctxt, &forwardAddrNodes);
|
||||
if (nForwardAddrs < 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("invalid <address> element found in <forward> of network %1$s"),
|
||||
networkName);
|
||||
if ((nForwardAddrs = virXPathNodeSet("./address", ctxt, &forwardAddrNodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
nForwardPfs = virXPathNodeSet("./pf", ctxt, &forwardPfNodes);
|
||||
if (nForwardPfs < 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("invalid <pf> element found in <forward> of network %1$s"),
|
||||
networkName);
|
||||
if ((nForwardPfs = virXPathNodeSet("./pf", ctxt, &forwardPfNodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
nForwardNats = virXPathNodeSet("./nat", ctxt, &forwardNatNodes);
|
||||
if (nForwardNats < 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("invalid <nat> element found in <forward> of network %1$s"),
|
||||
networkName);
|
||||
if ((nForwardNats = virXPathNodeSet("./nat", ctxt, &forwardNatNodes)) < 0)
|
||||
return -1;
|
||||
} else if (nForwardNats > 1) {
|
||||
|
||||
if (nForwardNats > 1) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("Only one <nat> element is allowed in <forward> of network %1$s"),
|
||||
networkName);
|
||||
|
@ -960,11 +960,9 @@ virNodeDeviceCapVPDParseCustomFields(xmlXPathContextPtr ctxt, virPCIVPDResource
|
||||
g_autofree xmlNodePtr *nodes = NULL;
|
||||
size_t i = 0;
|
||||
|
||||
if ((nfields = virXPathNodeSet("./vendor_field[@index]", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("failed to evaluate <vendor_field> elements"));
|
||||
if ((nfields = virXPathNodeSet("./vendor_field[@index]", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < nfields; i++) {
|
||||
g_autofree char *value = NULL;
|
||||
g_autofree char *index = NULL;
|
||||
@ -989,11 +987,9 @@ virNodeDeviceCapVPDParseCustomFields(xmlXPathContextPtr ctxt, virPCIVPDResource
|
||||
VIR_FREE(nodes);
|
||||
|
||||
if (!readOnly) {
|
||||
if ((nfields = virXPathNodeSet("./system_field[@index]", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("failed to evaluate <system_field> elements"));
|
||||
if ((nfields = virXPathNodeSet("./system_field[@index]", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < nfields; i++) {
|
||||
g_autofree char *value = NULL;
|
||||
g_autofree char *index = NULL;
|
||||
@ -1074,11 +1070,8 @@ virNodeDeviceCapVPDParseXML(xmlXPathContextPtr ctxt, virPCIVPDResource **res)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((nfields = virXPathNodeSet("./fields[@access]", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("no VPD <fields> elements with an access type attribute found"));
|
||||
if ((nfields = virXPathNodeSet("./fields[@access]", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < nfields; i++) {
|
||||
g_autofree char *access = NULL;
|
||||
|
@ -135,11 +135,8 @@ virDomainNumatuneNodeParseXML(virDomainNuma *numa,
|
||||
size_t i = 0;
|
||||
g_autofree xmlNodePtr *nodes = NULL;
|
||||
|
||||
if ((n = virXPathNodeSet("./numatune/memnode", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Cannot extract memnode nodes"));
|
||||
if ((n = virXPathNodeSet("./numatune/memnode", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!n)
|
||||
return 0;
|
||||
@ -700,7 +697,10 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNuma *def,
|
||||
if (!virXPathNode("./distances[1]", ctxt))
|
||||
return 0;
|
||||
|
||||
if ((sibling = virXPathNodeSet("./distances[1]/sibling", ctxt, &nodes)) <= 0) {
|
||||
if ((sibling = virXPathNodeSet("./distances[1]/sibling", ctxt, &nodes)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (sibling == 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("NUMA distances defined without siblings"));
|
||||
goto cleanup;
|
||||
@ -852,7 +852,10 @@ virDomainNumaDefParseXML(virDomainNuma *def,
|
||||
if (!virXPathNode("./cpu/numa[1]", ctxt))
|
||||
return 0;
|
||||
|
||||
if ((n = virXPathNodeSet("./cpu/numa[1]/cell", ctxt, &cell)) <= 0) {
|
||||
if ((n = virXPathNodeSet("./cpu/numa[1]/cell", ctxt, &cell)) < 0)
|
||||
return -1;
|
||||
|
||||
if (n == 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("NUMA topology defined without NUMA cells"));
|
||||
return -1;
|
||||
|
@ -334,7 +334,10 @@ ppc64ModelParse(xmlXPathContextPtr ctxt,
|
||||
}
|
||||
}
|
||||
|
||||
if ((n = virXPathNodeSet("./pvr", ctxt, &nodes)) <= 0) {
|
||||
if ((n = virXPathNodeSet("./pvr", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
|
||||
if (n == 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Missing PVR information for CPU model %1$s"),
|
||||
model->name);
|
||||
|
@ -3986,11 +3986,8 @@ virQEMUCapsLoadCPUModels(virArch arch,
|
||||
int n;
|
||||
xmlNodePtr node;
|
||||
|
||||
if ((n = virXPathNodeSet(xpath, ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("failed to parse qemu capabilities cpus"));
|
||||
if ((n = virXPathNodeSet(xpath, ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n == 0)
|
||||
return 0;
|
||||
@ -4028,11 +4025,8 @@ virQEMUCapsLoadCPUModels(virArch arch,
|
||||
nblockers = virXPathNodeSet("./blocker", ctxt, &blockerNodes);
|
||||
ctxt->node = node;
|
||||
|
||||
if (nblockers < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("failed to parse CPU blockers in QEMU capabilities"));
|
||||
if (nblockers < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nblockers > 0) {
|
||||
size_t j;
|
||||
@ -4071,11 +4065,8 @@ virQEMUCapsLoadMachines(virQEMUCapsAccel *caps,
|
||||
size_t i;
|
||||
int n;
|
||||
|
||||
if ((n = virXPathNodeSet(xpath, ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("failed to parse qemu capabilities machines"));
|
||||
if ((n = virXPathNodeSet(xpath, ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n == 0)
|
||||
return 0;
|
||||
@ -4288,11 +4279,8 @@ virQEMUCapsParseSGXInfo(virQEMUCaps *qemuCaps,
|
||||
ctxt->node = sgxSections;
|
||||
nSgxSections = virXPathNodeSet("./section", ctxt, §ionNodes);
|
||||
|
||||
if (nSgxSections < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("failed to parse SGX sections in QEMU capabilities cache"));
|
||||
if (nSgxSections < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
sgx->nSgxSections = nSgxSections;
|
||||
sgx->sgxSections = g_new0(virSGXSection, nSgxSections);
|
||||
@ -4375,11 +4363,8 @@ virQEMUCapsParseFlags(virQEMUCaps *qemuCaps, xmlXPathContextPtr ctxt)
|
||||
size_t i;
|
||||
int n;
|
||||
|
||||
if ((n = virXPathNodeSet("./flag", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("failed to parse qemu capabilities flags"));
|
||||
if ((n = virXPathNodeSet("./flag", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
VIR_DEBUG("Got flags %d", n);
|
||||
for (i = 0; i < n; i++) {
|
||||
@ -4413,11 +4398,8 @@ virQEMUCapsParseGIC(virQEMUCaps *qemuCaps, xmlXPathContextPtr ctxt)
|
||||
size_t i;
|
||||
int n;
|
||||
|
||||
if ((n = virXPathNodeSet("./gic", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("failed to parse qemu capabilities gic"));
|
||||
if ((n = virXPathNodeSet("./gic", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n > 0) {
|
||||
unsigned int uintValue;
|
||||
|
@ -3155,11 +3155,8 @@ qemuDomainObjPrivateXMLParseSlirpFeatures(xmlNodePtr featuresNode,
|
||||
|
||||
ctxt->node = featuresNode;
|
||||
|
||||
if ((n = virXPathNodeSet("./feature", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("failed to parse slirp-helper features"));
|
||||
if ((n = virXPathNodeSet("./feature", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
g_autofree char *str = virXMLPropString(nodes[i], "name");
|
||||
@ -3273,11 +3270,9 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
|
||||
}
|
||||
VIR_FREE(nodes);
|
||||
|
||||
if ((n = virXPathNodeSet("./qemuCaps/flag", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("failed to parse qemu capabilities flags"));
|
||||
if ((n = virXPathNodeSet("./qemuCaps/flag", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n > 0) {
|
||||
qemuCaps = virQEMUCapsNew();
|
||||
|
||||
@ -3305,11 +3300,9 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
|
||||
|
||||
priv->fakeReboot = virXPathBoolean("boolean(./fakereboot)", ctxt) == 1;
|
||||
|
||||
if ((n = virXPathNodeSet("./devices/device", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("failed to parse qemu device list"));
|
||||
if ((n = virXPathNodeSet("./devices/device", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n > 0) {
|
||||
/* NULL-terminated list */
|
||||
priv->qemuDevices = g_new0(char *, n + 1);
|
||||
@ -3325,11 +3318,9 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
|
||||
}
|
||||
VIR_FREE(nodes);
|
||||
|
||||
if ((n = virXPathNodeSet("./slirp/helper", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("failed to parse slirp helper list"));
|
||||
if ((n = virXPathNodeSet("./slirp/helper", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
g_autofree char *alias = virXMLPropString(nodes[i], "alias");
|
||||
g_autofree char *pid = virXMLPropString(nodes[i], "pid");
|
||||
|
@ -947,11 +947,8 @@ qemuMigrationCookieNetworkXMLParse(xmlXPathContextPtr ctxt)
|
||||
g_autofree xmlNodePtr *interfaces = NULL;
|
||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||
|
||||
if ((n = virXPathNodeSet("./network/interface", ctxt, &interfaces)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("missing interface information"));
|
||||
if ((n = virXPathNodeSet("./network/interface", ctxt, &interfaces)) < 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
optr->nnets = n;
|
||||
optr->net = g_new0(qemuMigrationCookieNetData, optr->nnets);
|
||||
|
@ -400,11 +400,8 @@ qemuNbdkitCapsParseFlags(qemuNbdkitCaps *nbdkitCaps,
|
||||
size_t i;
|
||||
int n;
|
||||
|
||||
if ((n = virXPathNodeSet("./flag", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("failed to parse qemu capabilities flags"));
|
||||
if ((n = virXPathNodeSet("./flag", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
VIR_DEBUG("Got flags %d", n);
|
||||
for (i = 0; i < n; i++) {
|
||||
|
@ -4612,11 +4612,8 @@ prlsdkParseSnapshotTree(const char *treexml)
|
||||
"ParallelsSavedStates", &ctxt, NULL, false)))
|
||||
goto cleanup;
|
||||
|
||||
if ((n = virXPathNodeSet("//SavedStateItem", ctxt, &nodes)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("cannot extract snapshot nodes"));
|
||||
if ((n = virXPathNodeSet("//SavedStateItem", ctxt, &nodes)) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (nodes[i]->parent == xmlDocGetRootElement(xml))
|
||||
|
Loading…
x
Reference in New Issue
Block a user