1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

domain_conf.c: remove 'error' label in virDomainDefTunablesParse()

The 'error' label is just doing a 'return -1'.

There's also a couple of 'VIR_FREE(nodes)' calls that are happening
right before exiting on error, but 'nodes' is already set for
autocleanup. These calls can also be removed.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Daniel Henrique Barboza 2020-11-23 10:06:55 -03:00
parent 7e5f031ff9
commit 6048610c7e

View File

@ -21350,7 +21350,7 @@ virDomainDefTunablesParse(virDomainDefPtr def,
if ((n = virXPathNodeSet("./blkiotune/device", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./blkiotune/device", ctxt, &nodes)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot extract blkiotune nodes")); "%s", _("cannot extract blkiotune nodes"));
goto error; return -1;
} }
if (n) if (n)
def->blkio.devices = g_new0(virBlkioDevice, n); def->blkio.devices = g_new0(virBlkioDevice, n);
@ -21358,7 +21358,7 @@ virDomainDefTunablesParse(virDomainDefPtr def,
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (virDomainBlkioDeviceParseXML(nodes[i], if (virDomainBlkioDeviceParseXML(nodes[i],
&def->blkio.devices[i]) < 0) &def->blkio.devices[i]) < 0)
goto error; return -1;
def->blkio.ndevices++; def->blkio.ndevices++;
for (j = 0; j < i; j++) { for (j = 0; j < i; j++) {
if (STREQ(def->blkio.devices[j].path, if (STREQ(def->blkio.devices[j].path,
@ -21366,7 +21366,7 @@ virDomainDefTunablesParse(virDomainDefPtr def,
virReportError(VIR_ERR_XML_ERROR, virReportError(VIR_ERR_XML_ERROR,
_("duplicate blkio device path '%s'"), _("duplicate blkio device path '%s'"),
def->blkio.devices[i].path); def->blkio.devices[i].path);
goto error; return -1;
} }
} }
} }
@ -21375,32 +21375,32 @@ virDomainDefTunablesParse(virDomainDefPtr def,
/* Extract other memory tunables */ /* Extract other memory tunables */
if (virDomainParseMemoryLimit("./memtune/hard_limit[1]", NULL, ctxt, if (virDomainParseMemoryLimit("./memtune/hard_limit[1]", NULL, ctxt,
&def->mem.hard_limit) < 0) &def->mem.hard_limit) < 0)
goto error; return -1;
if (virDomainParseMemoryLimit("./memtune/soft_limit[1]", NULL, ctxt, if (virDomainParseMemoryLimit("./memtune/soft_limit[1]", NULL, ctxt,
&def->mem.soft_limit) < 0) &def->mem.soft_limit) < 0)
goto error; return -1;
if (virDomainParseMemory("./memtune/min_guarantee[1]", NULL, ctxt, if (virDomainParseMemory("./memtune/min_guarantee[1]", NULL, ctxt,
&def->mem.min_guarantee, false, false) < 0) &def->mem.min_guarantee, false, false) < 0)
goto error; return -1;
if (virDomainParseMemoryLimit("./memtune/swap_hard_limit[1]", NULL, ctxt, if (virDomainParseMemoryLimit("./memtune/swap_hard_limit[1]", NULL, ctxt,
&def->mem.swap_hard_limit) < 0) &def->mem.swap_hard_limit) < 0)
goto error; return -1;
if (virDomainVcpuParse(def, ctxt, xmlopt) < 0) if (virDomainVcpuParse(def, ctxt, xmlopt) < 0)
goto error; return -1;
if (virDomainDefParseIOThreads(def, ctxt) < 0) if (virDomainDefParseIOThreads(def, ctxt) < 0)
goto error; return -1;
/* Extract cpu tunables. */ /* Extract cpu tunables. */
if ((n = virXPathULongLong("string(./cputune/shares[1])", ctxt, if ((n = virXPathULongLong("string(./cputune/shares[1])", ctxt,
&def->cputune.shares)) < -1) { &def->cputune.shares)) < -1) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("can't parse cputune shares value")); _("can't parse cputune shares value"));
goto error; return -1;
} else if (n == 0) { } else if (n == 0) {
def->cputune.sharesSpecified = true; def->cputune.sharesSpecified = true;
} }
@ -21409,42 +21409,42 @@ virDomainDefTunablesParse(virDomainDefPtr def,
&def->cputune.period) < -1) { &def->cputune.period) < -1) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("can't parse cputune period value")); _("can't parse cputune period value"));
goto error; return -1;
} }
if (virXPathLongLong("string(./cputune/quota[1])", ctxt, if (virXPathLongLong("string(./cputune/quota[1])", ctxt,
&def->cputune.quota) < -1) { &def->cputune.quota) < -1) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("can't parse cputune quota value")); _("can't parse cputune quota value"));
goto error; return -1;
} }
if (virXPathULongLong("string(./cputune/global_period[1])", ctxt, if (virXPathULongLong("string(./cputune/global_period[1])", ctxt,
&def->cputune.global_period) < -1) { &def->cputune.global_period) < -1) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("can't parse cputune global period value")); _("can't parse cputune global period value"));
goto error; return -1;
} }
if (virXPathLongLong("string(./cputune/global_quota[1])", ctxt, if (virXPathLongLong("string(./cputune/global_quota[1])", ctxt,
&def->cputune.global_quota) < -1) { &def->cputune.global_quota) < -1) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("can't parse cputune global quota value")); _("can't parse cputune global quota value"));
goto error; return -1;
} }
if (virXPathULongLong("string(./cputune/emulator_period[1])", ctxt, if (virXPathULongLong("string(./cputune/emulator_period[1])", ctxt,
&def->cputune.emulator_period) < -1) { &def->cputune.emulator_period) < -1) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("can't parse cputune emulator period value")); _("can't parse cputune emulator period value"));
goto error; return -1;
} }
if (virXPathLongLong("string(./cputune/emulator_quota[1])", ctxt, if (virXPathLongLong("string(./cputune/emulator_quota[1])", ctxt,
&def->cputune.emulator_quota) < -1) { &def->cputune.emulator_quota) < -1) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("can't parse cputune emulator quota value")); _("can't parse cputune emulator quota value"));
goto error; return -1;
} }
@ -21452,41 +21452,40 @@ virDomainDefTunablesParse(virDomainDefPtr def,
&def->cputune.iothread_period) < -1) { &def->cputune.iothread_period) < -1) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("can't parse cputune iothread period value")); _("can't parse cputune iothread period value"));
goto error; return -1;
} }
if (virXPathLongLong("string(./cputune/iothread_quota[1])", ctxt, if (virXPathLongLong("string(./cputune/iothread_quota[1])", ctxt,
&def->cputune.iothread_quota) < -1) { &def->cputune.iothread_quota) < -1) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("can't parse cputune iothread quota value")); _("can't parse cputune iothread quota value"));
goto error; return -1;
} }
if ((n = virXPathNodeSet("./cputune/vcpupin", ctxt, &nodes)) < 0) if ((n = virXPathNodeSet("./cputune/vcpupin", ctxt, &nodes)) < 0)
goto error; return -1;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (virDomainVcpuPinDefParseXML(def, nodes[i])) if (virDomainVcpuPinDefParseXML(def, nodes[i]))
goto error; return -1;
} }
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", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract emulatorpin nodes")); _("cannot extract emulatorpin nodes"));
goto error; return -1;
} }
if (n) { if (n) {
if (n > 1) { if (n > 1) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("only one emulatorpin is supported")); _("only one emulatorpin is supported"));
VIR_FREE(nodes); return -1;
goto error;
} }
if (!(def->cputune.emulatorpin = virDomainEmulatorPinDefParseXML(nodes[0]))) if (!(def->cputune.emulatorpin = virDomainEmulatorPinDefParseXML(nodes[0])))
goto error; return -1;
} }
VIR_FREE(nodes); VIR_FREE(nodes);
@ -21494,86 +21493,82 @@ virDomainDefTunablesParse(virDomainDefPtr def,
if ((n = virXPathNodeSet("./cputune/iothreadpin", ctxt, &nodes)) < 0) { if ((n = virXPathNodeSet("./cputune/iothreadpin", ctxt, &nodes)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract iothreadpin nodes")); _("cannot extract iothreadpin nodes"));
goto error; 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)
goto error; return -1;
} }
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", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract vcpusched nodes")); _("cannot extract vcpusched nodes"));
goto error; 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)
goto error; return -1;
} }
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", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract iothreadsched nodes")); _("cannot extract iothreadsched nodes"));
goto error; 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)
goto error; return -1;
} }
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", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract emulatorsched nodes")); _("cannot extract emulatorsched nodes"));
goto error; return -1;
} }
if (n) { if (n) {
if (n > 1) { if (n > 1) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("only one emulatorsched is supported")); _("only one emulatorsched is supported"));
VIR_FREE(nodes); return -1;
goto error;
} }
if (virDomainEmulatorSchedParse(nodes[0], def) < 0) if (virDomainEmulatorSchedParse(nodes[0], def) < 0)
goto error; return -1;
} }
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", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract cachetune nodes")); _("cannot extract cachetune nodes"));
goto error; 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)
goto error; return -1;
} }
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", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract memorytune nodes")); _("cannot extract memorytune nodes"));
goto error; 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)
goto error; return -1;
} }
VIR_FREE(nodes); VIR_FREE(nodes);
return 0; return 0;
error:
return -1;
} }