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:
Peter Krempa 2024-01-29 15:50:27 +01:00
parent 9eda33161f
commit a9f76d6ab7
10 changed files with 72 additions and 191 deletions

View File

@ -17780,11 +17780,8 @@ virDomainResctrlMonDefParse(virDomainDef *def,
ctxt->node = node; ctxt->node = node;
if ((n = virXPathNodeSet("./monitor", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./monitor", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot extract monitor nodes"));
goto cleanup; goto cleanup;
}
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
domresmon = g_new0(virDomainResctrlMonDef, 1); domresmon = g_new0(virDomainResctrlMonDef, 1);
@ -17912,11 +17909,8 @@ virDomainCachetuneDefParse(virDomainDef *def,
if (virBitmapIsAllClear(vcpus)) if (virBitmapIsAllClear(vcpus))
return 0; return 0;
if ((n = virXPathNodeSet("./cache", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./cache", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot extract cache nodes under cachetune"));
return -1; return -1;
}
if (virDomainResctrlVcpuMatch(def, vcpus, &resctrl) < 0) if (virDomainResctrlVcpuMatch(def, vcpus, &resctrl) < 0)
return -1; return -1;
@ -18182,11 +18176,8 @@ virDomainDefParseMemory(virDomainDef *def,
if (virXPathNode("./memoryBacking/hugepages", ctxt)) { if (virXPathNode("./memoryBacking/hugepages", ctxt)) {
/* hugepages will be used */ /* hugepages will be used */
if ((n = virXPathNodeSet("./memoryBacking/hugepages/page", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./memoryBacking/hugepages/page", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract hugepages nodes"));
return -1; return -1;
}
if (n) { if (n) {
def->mem.hugepages = g_new0(virDomainHugePage, n); def->mem.hugepages = g_new0(virDomainHugePage, n);
@ -18270,11 +18261,8 @@ virDomainMemorytuneDefParse(virDomainDef *def,
if (virBitmapIsAllClear(vcpus)) if (virBitmapIsAllClear(vcpus))
return 0; return 0;
if ((n = virXPathNodeSet("./node", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./node", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot extract memory nodes under memorytune"));
return -1; return -1;
}
if (virDomainResctrlVcpuMatch(def, vcpus, &resctrl) < 0) if (virDomainResctrlVcpuMatch(def, vcpus, &resctrl) < 0)
return -1; return -1;
@ -18341,11 +18329,9 @@ virDomainDefTunablesParse(virDomainDef *def,
&def->blkio.weight) < 0) &def->blkio.weight) < 0)
def->blkio.weight = 0; def->blkio.weight = 0;
if ((n = virXPathNodeSet("./blkiotune/device", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./blkiotune/device", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot extract blkiotune nodes"));
return -1; return -1;
}
if (n) if (n)
def->blkio.devices = g_new0(virBlkioDevice, n); def->blkio.devices = g_new0(virBlkioDevice, n);
@ -18456,11 +18442,8 @@ virDomainDefTunablesParse(virDomainDef *def,
} }
VIR_FREE(nodes); VIR_FREE(nodes);
if ((n = virXPathNodeSet("./cputune/emulatorpin", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./cputune/emulatorpin", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract emulatorpin nodes"));
return -1; return -1;
}
if (n) { if (n) {
if (n > 1) { if (n > 1) {
@ -18475,11 +18458,8 @@ virDomainDefTunablesParse(virDomainDef *def,
VIR_FREE(nodes); VIR_FREE(nodes);
if ((n = virXPathNodeSet("./cputune/iothreadpin", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./cputune/iothreadpin", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract iothreadpin nodes"));
return -1; return -1;
}
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (virDomainIOThreadPinDefParseXML(nodes[i], def) < 0) if (virDomainIOThreadPinDefParseXML(nodes[i], def) < 0)
@ -18487,11 +18467,8 @@ virDomainDefTunablesParse(virDomainDef *def,
} }
VIR_FREE(nodes); VIR_FREE(nodes);
if ((n = virXPathNodeSet("./cputune/vcpusched", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./cputune/vcpusched", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract vcpusched nodes"));
return -1; return -1;
}
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (virDomainVcpuThreadSchedParse(nodes[i], def) < 0) if (virDomainVcpuThreadSchedParse(nodes[i], def) < 0)
@ -18499,11 +18476,8 @@ virDomainDefTunablesParse(virDomainDef *def,
} }
VIR_FREE(nodes); VIR_FREE(nodes);
if ((n = virXPathNodeSet("./cputune/iothreadsched", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./cputune/iothreadsched", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract iothreadsched nodes"));
return -1; return -1;
}
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (virDomainIOThreadSchedParse(nodes[i], def) < 0) if (virDomainIOThreadSchedParse(nodes[i], def) < 0)
@ -18511,11 +18485,8 @@ virDomainDefTunablesParse(virDomainDef *def,
} }
VIR_FREE(nodes); VIR_FREE(nodes);
if ((n = virXPathNodeSet("./cputune/emulatorsched", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./cputune/emulatorsched", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract emulatorsched nodes"));
return -1; return -1;
}
if (n) { if (n) {
if (n > 1) { if (n > 1) {
@ -18529,11 +18500,8 @@ virDomainDefTunablesParse(virDomainDef *def,
} }
VIR_FREE(nodes); VIR_FREE(nodes);
if ((n = virXPathNodeSet("./cputune/cachetune", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./cputune/cachetune", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract cachetune nodes"));
return -1; return -1;
}
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (virDomainCachetuneDefParse(def, ctxt, nodes[i], flags) < 0) if (virDomainCachetuneDefParse(def, ctxt, nodes[i], flags) < 0)
@ -18541,11 +18509,8 @@ virDomainDefTunablesParse(virDomainDef *def,
} }
VIR_FREE(nodes); VIR_FREE(nodes);
if ((n = virXPathNodeSet("./cputune/memorytune", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./cputune/memorytune", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract memorytune nodes"));
return -1; return -1;
}
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (virDomainMemorytuneDefParse(def, ctxt, nodes[i], flags) < 0) if (virDomainMemorytuneDefParse(def, ctxt, nodes[i], flags) < 0)
@ -18849,11 +18814,8 @@ virDomainDefParseXML(xmlXPathContextPtr ctxt,
!virDomainIOThreadIDArrayHasPin(def)) !virDomainIOThreadIDArrayHasPin(def))
def->placement_mode = VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO; def->placement_mode = VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO;
if ((n = virXPathNodeSet("./resource", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./resource", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot extract resource nodes"));
return NULL; return NULL;
}
if (n > 1) { if (n > 1) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
@ -18901,11 +18863,9 @@ virDomainDefParseXML(xmlXPathContextPtr ctxt,
return NULL; return NULL;
/* analysis of the resource leases */ /* analysis of the resource leases */
if ((n = virXPathNodeSet("./devices/lease", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./devices/lease", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot extract device leases"));
return NULL; return NULL;
}
if (n) if (n)
def->leases = g_new0(virDomainLeaseDef *, n); def->leases = g_new0(virDomainLeaseDef *, n);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
@ -19024,11 +18984,9 @@ virDomainDefParseXML(xmlXPathContextPtr ctxt,
} }
VIR_FREE(nodes); VIR_FREE(nodes);
if ((n = virXPathNodeSet("./devices/console", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./devices/console", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot extract console devices"));
return NULL; return NULL;
}
if (n) if (n)
def->consoles = g_new0(virDomainChrDef *, n); def->consoles = g_new0(virDomainChrDef *, n);

View File

@ -892,13 +892,9 @@ virNetworkDNSDefParseXML(const char *networkName,
&def->forwardPlainNames) < 0) &def->forwardPlainNames) < 0)
return -1; return -1;
nfwds = virXPathNodeSet("./forwarder", ctxt, &fwdNodes); if ((nfwds = virXPathNodeSet("./forwarder", ctxt, &fwdNodes)) < 0)
if (nfwds < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid <forwarder> element found in <dns> of network %1$s"),
networkName);
return -1; return -1;
}
if (nfwds > 0) { if (nfwds > 0) {
def->forwarders = g_new0(virNetworkDNSForwarder, nfwds); def->forwarders = g_new0(virNetworkDNSForwarder, nfwds);
@ -922,13 +918,9 @@ virNetworkDNSDefParseXML(const char *networkName,
} }
} }
nhosts = virXPathNodeSet("./host", ctxt, &hostNodes); if ((nhosts = virXPathNodeSet("./host", ctxt, &hostNodes)) < 0)
if (nhosts < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid <host> element found in <dns> of network %1$s"),
networkName);
return -1; return -1;
}
if (nhosts > 0) { if (nhosts > 0) {
def->hosts = g_new0(virNetworkDNSHostDef, nhosts); def->hosts = g_new0(virNetworkDNSHostDef, nhosts);
@ -941,13 +933,9 @@ virNetworkDNSDefParseXML(const char *networkName,
} }
} }
nsrvs = virXPathNodeSet("./srv", ctxt, &srvNodes); if ((nsrvs = virXPathNodeSet("./srv", ctxt, &srvNodes)) < 0)
if (nsrvs < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid <srv> element found in <dns> of network %1$s"),
networkName);
return -1; return -1;
}
if (nsrvs > 0) { if (nsrvs > 0) {
def->srvs = g_new0(virNetworkDNSSrvDef, nsrvs); def->srvs = g_new0(virNetworkDNSSrvDef, nsrvs);
@ -960,13 +948,9 @@ virNetworkDNSDefParseXML(const char *networkName,
} }
} }
ntxts = virXPathNodeSet("./txt", ctxt, &txtNodes); if ((ntxts = virXPathNodeSet("./txt", ctxt, &txtNodes)) < 0)
if (ntxts < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid <txt> element found in <dns> of network %1$s"),
networkName);
return -1; return -1;
}
if (ntxts > 0) { if (ntxts > 0) {
def->txts = g_new0(virNetworkDNSTxtDef, ntxts); def->txts = g_new0(virNetworkDNSTxtDef, ntxts);
@ -1222,13 +1206,10 @@ virNetworkForwardNatDefParseXML(const char *networkName,
return -1; return -1;
/* addresses for SNAT */ /* addresses for SNAT */
nNatAddrs = virXPathNodeSet("./address", ctxt, &natAddrNodes); if ((nNatAddrs = virXPathNodeSet("./address", ctxt, &natAddrNodes)) < 0)
if (nNatAddrs < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid <address> element found in <forward> of network %1$s"),
networkName);
return -1; return -1;
} else if (nNatAddrs > 1) {
if (nNatAddrs > 1) {
virReportError(VIR_ERR_XML_ERROR, virReportError(VIR_ERR_XML_ERROR,
_("Only one <address> element is allowed in <nat> in <forward> in network %1$s"), _("Only one <address> element is allowed in <nat> in <forward> in network %1$s"),
networkName); networkName);
@ -1284,13 +1265,10 @@ virNetworkForwardNatDefParseXML(const char *networkName,
} }
/* ports for SNAT and MASQUERADE */ /* ports for SNAT and MASQUERADE */
nNatPorts = virXPathNodeSet("./port", ctxt, &natPortNodes); if ((nNatPorts = virXPathNodeSet("./port", ctxt, &natPortNodes)) < 0)
if (nNatPorts < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid <port> element found in <forward> of network %1$s"),
networkName);
return -1; return -1;
} else if (nNatPorts > 1) {
if (nNatPorts > 1) {
virReportError(VIR_ERR_XML_ERROR, virReportError(VIR_ERR_XML_ERROR,
_("Only one <port> element is allowed in <nat> in <forward> in network %1$s"), _("Only one <port> element is allowed in <nat> in <forward> in network %1$s"),
networkName); networkName);
@ -1358,37 +1336,19 @@ virNetworkForwardDefParseXML(const char *networkName,
} }
/* bridge and hostdev modes can use a pool of physical interfaces */ /* bridge and hostdev modes can use a pool of physical interfaces */
nForwardIfs = virXPathNodeSet("./interface", ctxt, &forwardIfNodes); if ((nForwardIfs = virXPathNodeSet("./interface", ctxt, &forwardIfNodes)) < 0)
if (nForwardIfs < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid <interface> element found in <forward> of network %1$s"),
networkName);
return -1; return -1;
}
nForwardAddrs = virXPathNodeSet("./address", ctxt, &forwardAddrNodes); if ((nForwardAddrs = virXPathNodeSet("./address", ctxt, &forwardAddrNodes)) < 0)
if (nForwardAddrs < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid <address> element found in <forward> of network %1$s"),
networkName);
return -1; return -1;
}
nForwardPfs = virXPathNodeSet("./pf", ctxt, &forwardPfNodes); if ((nForwardPfs = virXPathNodeSet("./pf", ctxt, &forwardPfNodes)) < 0)
if (nForwardPfs < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid <pf> element found in <forward> of network %1$s"),
networkName);
return -1; return -1;
}
nForwardNats = virXPathNodeSet("./nat", ctxt, &forwardNatNodes); if ((nForwardNats = virXPathNodeSet("./nat", ctxt, &forwardNatNodes)) < 0)
if (nForwardNats < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid <nat> element found in <forward> of network %1$s"),
networkName);
return -1; return -1;
} else if (nForwardNats > 1) {
if (nForwardNats > 1) {
virReportError(VIR_ERR_XML_ERROR, virReportError(VIR_ERR_XML_ERROR,
_("Only one <nat> element is allowed in <forward> of network %1$s"), _("Only one <nat> element is allowed in <forward> of network %1$s"),
networkName); networkName);

View File

@ -960,11 +960,9 @@ virNodeDeviceCapVPDParseCustomFields(xmlXPathContextPtr ctxt, virPCIVPDResource
g_autofree xmlNodePtr *nodes = NULL; g_autofree xmlNodePtr *nodes = NULL;
size_t i = 0; size_t i = 0;
if ((nfields = virXPathNodeSet("./vendor_field[@index]", ctxt, &nodes)) < 0) { if ((nfields = virXPathNodeSet("./vendor_field[@index]", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_XML_ERROR, "%s",
_("failed to evaluate <vendor_field> elements"));
return -1; return -1;
}
for (i = 0; i < nfields; i++) { for (i = 0; i < nfields; i++) {
g_autofree char *value = NULL; g_autofree char *value = NULL;
g_autofree char *index = NULL; g_autofree char *index = NULL;
@ -989,11 +987,9 @@ virNodeDeviceCapVPDParseCustomFields(xmlXPathContextPtr ctxt, virPCIVPDResource
VIR_FREE(nodes); VIR_FREE(nodes);
if (!readOnly) { if (!readOnly) {
if ((nfields = virXPathNodeSet("./system_field[@index]", ctxt, &nodes)) < 0) { if ((nfields = virXPathNodeSet("./system_field[@index]", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_XML_ERROR, "%s",
_("failed to evaluate <system_field> elements"));
return -1; return -1;
}
for (i = 0; i < nfields; i++) { for (i = 0; i < nfields; i++) {
g_autofree char *value = NULL; g_autofree char *value = NULL;
g_autofree char *index = NULL; g_autofree char *index = NULL;
@ -1074,11 +1070,8 @@ virNodeDeviceCapVPDParseXML(xmlXPathContextPtr ctxt, virPCIVPDResource **res)
return -1; return -1;
} }
if ((nfields = virXPathNodeSet("./fields[@access]", ctxt, &nodes)) < 0) { if ((nfields = virXPathNodeSet("./fields[@access]", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_XML_ERROR, "%s",
_("no VPD <fields> elements with an access type attribute found"));
return -1; return -1;
}
for (i = 0; i < nfields; i++) { for (i = 0; i < nfields; i++) {
g_autofree char *access = NULL; g_autofree char *access = NULL;

View File

@ -135,11 +135,8 @@ virDomainNumatuneNodeParseXML(virDomainNuma *numa,
size_t i = 0; size_t i = 0;
g_autofree xmlNodePtr *nodes = NULL; g_autofree xmlNodePtr *nodes = NULL;
if ((n = virXPathNodeSet("./numatune/memnode", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./numatune/memnode", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot extract memnode nodes"));
return -1; return -1;
}
if (!n) if (!n)
return 0; return 0;
@ -700,7 +697,10 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNuma *def,
if (!virXPathNode("./distances[1]", ctxt)) if (!virXPathNode("./distances[1]", ctxt))
return 0; 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", virReportError(VIR_ERR_XML_ERROR, "%s",
_("NUMA distances defined without siblings")); _("NUMA distances defined without siblings"));
goto cleanup; goto cleanup;
@ -852,7 +852,10 @@ virDomainNumaDefParseXML(virDomainNuma *def,
if (!virXPathNode("./cpu/numa[1]", ctxt)) if (!virXPathNode("./cpu/numa[1]", ctxt))
return 0; 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", virReportError(VIR_ERR_XML_ERROR, "%s",
_("NUMA topology defined without NUMA cells")); _("NUMA topology defined without NUMA cells"));
return -1; return -1;

View File

@ -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, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing PVR information for CPU model %1$s"), _("Missing PVR information for CPU model %1$s"),
model->name); model->name);

View File

@ -3986,11 +3986,8 @@ virQEMUCapsLoadCPUModels(virArch arch,
int n; int n;
xmlNodePtr node; xmlNodePtr node;
if ((n = virXPathNodeSet(xpath, ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet(xpath, ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to parse qemu capabilities cpus"));
return -1; return -1;
}
if (n == 0) if (n == 0)
return 0; return 0;
@ -4028,11 +4025,8 @@ virQEMUCapsLoadCPUModels(virArch arch,
nblockers = virXPathNodeSet("./blocker", ctxt, &blockerNodes); nblockers = virXPathNodeSet("./blocker", ctxt, &blockerNodes);
ctxt->node = node; ctxt->node = node;
if (nblockers < 0) { if (nblockers < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to parse CPU blockers in QEMU capabilities"));
return -1; return -1;
}
if (nblockers > 0) { if (nblockers > 0) {
size_t j; size_t j;
@ -4071,11 +4065,8 @@ virQEMUCapsLoadMachines(virQEMUCapsAccel *caps,
size_t i; size_t i;
int n; int n;
if ((n = virXPathNodeSet(xpath, ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet(xpath, ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to parse qemu capabilities machines"));
return -1; return -1;
}
if (n == 0) if (n == 0)
return 0; return 0;
@ -4288,11 +4279,8 @@ virQEMUCapsParseSGXInfo(virQEMUCaps *qemuCaps,
ctxt->node = sgxSections; ctxt->node = sgxSections;
nSgxSections = virXPathNodeSet("./section", ctxt, &sectionNodes); nSgxSections = virXPathNodeSet("./section", ctxt, &sectionNodes);
if (nSgxSections < 0) { if (nSgxSections < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to parse SGX sections in QEMU capabilities cache"));
return -1; return -1;
}
sgx->nSgxSections = nSgxSections; sgx->nSgxSections = nSgxSections;
sgx->sgxSections = g_new0(virSGXSection, nSgxSections); sgx->sgxSections = g_new0(virSGXSection, nSgxSections);
@ -4375,11 +4363,8 @@ virQEMUCapsParseFlags(virQEMUCaps *qemuCaps, xmlXPathContextPtr ctxt)
size_t i; size_t i;
int n; int n;
if ((n = virXPathNodeSet("./flag", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./flag", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to parse qemu capabilities flags"));
return -1; return -1;
}
VIR_DEBUG("Got flags %d", n); VIR_DEBUG("Got flags %d", n);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
@ -4413,11 +4398,8 @@ virQEMUCapsParseGIC(virQEMUCaps *qemuCaps, xmlXPathContextPtr ctxt)
size_t i; size_t i;
int n; int n;
if ((n = virXPathNodeSet("./gic", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./gic", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to parse qemu capabilities gic"));
return -1; return -1;
}
if (n > 0) { if (n > 0) {
unsigned int uintValue; unsigned int uintValue;

View File

@ -3155,11 +3155,8 @@ qemuDomainObjPrivateXMLParseSlirpFeatures(xmlNodePtr featuresNode,
ctxt->node = featuresNode; ctxt->node = featuresNode;
if ((n = virXPathNodeSet("./feature", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./feature", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("failed to parse slirp-helper features"));
return -1; return -1;
}
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
g_autofree char *str = virXMLPropString(nodes[i], "name"); g_autofree char *str = virXMLPropString(nodes[i], "name");
@ -3273,11 +3270,9 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
} }
VIR_FREE(nodes); VIR_FREE(nodes);
if ((n = virXPathNodeSet("./qemuCaps/flag", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./qemuCaps/flag", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("failed to parse qemu capabilities flags"));
return -1; return -1;
}
if (n > 0) { if (n > 0) {
qemuCaps = virQEMUCapsNew(); qemuCaps = virQEMUCapsNew();
@ -3305,11 +3300,9 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
priv->fakeReboot = virXPathBoolean("boolean(./fakereboot)", ctxt) == 1; priv->fakeReboot = virXPathBoolean("boolean(./fakereboot)", ctxt) == 1;
if ((n = virXPathNodeSet("./devices/device", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./devices/device", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to parse qemu device list"));
return -1; return -1;
}
if (n > 0) { if (n > 0) {
/* NULL-terminated list */ /* NULL-terminated list */
priv->qemuDevices = g_new0(char *, n + 1); priv->qemuDevices = g_new0(char *, n + 1);
@ -3325,11 +3318,9 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
} }
VIR_FREE(nodes); VIR_FREE(nodes);
if ((n = virXPathNodeSet("./slirp/helper", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./slirp/helper", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to parse slirp helper list"));
return -1; return -1;
}
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
g_autofree char *alias = virXMLPropString(nodes[i], "alias"); g_autofree char *alias = virXMLPropString(nodes[i], "alias");
g_autofree char *pid = virXMLPropString(nodes[i], "pid"); g_autofree char *pid = virXMLPropString(nodes[i], "pid");

View File

@ -947,11 +947,8 @@ qemuMigrationCookieNetworkXMLParse(xmlXPathContextPtr ctxt)
g_autofree xmlNodePtr *interfaces = NULL; g_autofree xmlNodePtr *interfaces = NULL;
VIR_XPATH_NODE_AUTORESTORE(ctxt) VIR_XPATH_NODE_AUTORESTORE(ctxt)
if ((n = virXPathNodeSet("./network/interface", ctxt, &interfaces)) < 0) { if ((n = virXPathNodeSet("./network/interface", ctxt, &interfaces)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("missing interface information"));
return NULL; return NULL;
}
optr->nnets = n; optr->nnets = n;
optr->net = g_new0(qemuMigrationCookieNetData, optr->nnets); optr->net = g_new0(qemuMigrationCookieNetData, optr->nnets);

View File

@ -400,11 +400,8 @@ qemuNbdkitCapsParseFlags(qemuNbdkitCaps *nbdkitCaps,
size_t i; size_t i;
int n; int n;
if ((n = virXPathNodeSet("./flag", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./flag", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to parse qemu capabilities flags"));
return -1; return -1;
}
VIR_DEBUG("Got flags %d", n); VIR_DEBUG("Got flags %d", n);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {

View File

@ -4612,11 +4612,8 @@ prlsdkParseSnapshotTree(const char *treexml)
"ParallelsSavedStates", &ctxt, NULL, false))) "ParallelsSavedStates", &ctxt, NULL, false)))
goto cleanup; goto cleanup;
if ((n = virXPathNodeSet("//SavedStateItem", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("//SavedStateItem", ctxt, &nodes)) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract snapshot nodes"));
goto cleanup; goto cleanup;
}
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (nodes[i]->parent == xmlDocGetRootElement(xml)) if (nodes[i]->parent == xmlDocGetRootElement(xml))