[libvirt] [PATCH v1 0/8] domain_addr and qemu_domain cleanups

Hi, These are a few cleanups in some files that I'll end up messing with in a future series (which isn't Glibfied ATM). Figured it's best to clean them up now instead of adding more non-Glibfied code on top. Patches 7 and 8 are stuff that I noted some time ago and figured it might be worth sending as well. Daniel Henrique Barboza (8): conf/domain_addr.c: use g_autofree in strings conf/domain_addr.c: remove unneeded 'cleanup' labels qemu_domain.c: remove redundant virObjectUnref() qemu_domain.c: use g_autofree when possible qemu_domain.c: use g_autoptr when possible qemu_domain.c: removing unneeded cleanup labels qemu_domain.c: turn qemuDomainChrDefDropDefaultPath to void qemu_domain_address.c: turn qemuDomainFillDeviceIsolationGroup to void src/conf/domain_addr.c | 124 +++----- src/qemu/qemu_domain.c | 511 +++++++++++---------------------- src/qemu/qemu_domain_address.c | 20 +- src/qemu/qemu_domain_address.h | 2 +- src/qemu/qemu_hotplug.c | 6 +- 5 files changed, 227 insertions(+), 436 deletions(-) -- 2.24.1

Use g_autofree in strings when possible to spare a VIR_FREE() call. Unneeded 'cleanup' labels will be taken care of in the next patch. The 'str' string in virDomainVirtioSerialAddrReserve() was never used by the logic, only being used in cleanup by VIR_FREE(). Let's remove it. Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> --- src/conf/domain_addr.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index ef7ee80e6a..ee4dcf1d3b 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -830,7 +830,7 @@ virDomainPCIAddressReserveAddrInternal(virDomainPCIAddressSetPtr addrs, bool fromConfig) { int ret = -1; - char *addrStr = NULL; + g_autofree char *addrStr = NULL; virDomainPCIAddressBusPtr bus; virErrorNumber errType = (fromConfig ? VIR_ERR_XML_ERROR : VIR_ERR_INTERNAL_ERROR); @@ -891,7 +891,6 @@ virDomainPCIAddressReserveAddrInternal(virDomainPCIAddressSetPtr addrs, ret = 0; cleanup: - VIR_FREE(addrStr); return ret; } @@ -912,7 +911,7 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs, virDomainPCIConnectFlags flags) { int ret = -1; - char *addrStr = NULL; + g_autofree char *addrStr = NULL; /* if flags is 0, the particular model of this device on this * machinetype doesn't need a PCI address, so we're done. @@ -955,7 +954,6 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs, ret = 0; cleanup: - VIR_FREE(addrStr); return ret; } @@ -1105,7 +1103,7 @@ virDomainPCIAddressFindUnusedFunctionOnBus(virDomainPCIAddressBusPtr bus, bool *found) { int ret = -1; - char *addrStr = NULL; + g_autofree char *addrStr = NULL; *found = false; @@ -1159,7 +1157,6 @@ virDomainPCIAddressFindUnusedFunctionOnBus(virDomainPCIAddressBusPtr bus, ret = 0; cleanup: - VIR_FREE(addrStr); return ret; } @@ -1414,7 +1411,7 @@ virDomainCCWAddressAssign(virDomainDeviceInfoPtr dev, bool autoassign) { int ret = -1; - char *addr = NULL; + g_autofree char *addr = NULL; if (dev->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) return 0; @@ -1457,7 +1454,6 @@ virDomainCCWAddressAssign(virDomainDeviceInfoPtr dev, ret = 0; cleanup: - VIR_FREE(addr); return ret; } @@ -1687,7 +1683,6 @@ virDomainVirtioSerialAddrReserve(virDomainDefPtr def G_GNUC_UNUSED, void *data) { virDomainVirtioSerialAddrSetPtr addrs = data; - char *str = NULL; int ret = -1; virBitmapPtr map = NULL; bool b; @@ -1729,7 +1724,6 @@ virDomainVirtioSerialAddrReserve(virDomainDefPtr def G_GNUC_UNUSED, ret = 0; cleanup: - VIR_FREE(str); return ret; } @@ -2208,7 +2202,7 @@ virDomainUSBAddressSetAddHub(virDomainUSBAddressSetPtr addrs, virDomainUSBAddressHubPtr targetHub = NULL, newHub = NULL; int ret = -1; int targetPort; - char *portStr = NULL; + g_autofree char *portStr = NULL; if (hub->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -2242,7 +2236,6 @@ virDomainUSBAddressSetAddHub(virDomainUSBAddressSetPtr addrs, ret = 0; cleanup: virDomainUSBAddressHubFree(newHub); - VIR_FREE(portStr); return ret; } @@ -2349,7 +2342,7 @@ virDomainUSBAddressAssignFromBus(virDomainUSBAddressSetPtr addrs, { unsigned int portpath[VIR_DOMAIN_DEVICE_USB_MAX_PORT_DEPTH] = { 0 }; virDomainUSBAddressHubPtr hub = addrs->buses[bus]; - char *portStr = NULL; + g_autofree char *portStr = NULL; int ret = -1; if (!hub) @@ -2372,7 +2365,6 @@ virDomainUSBAddressAssignFromBus(virDomainUSBAddressSetPtr addrs, ret = 0; cleanup: - VIR_FREE(portStr); return ret; } @@ -2428,7 +2420,7 @@ virDomainUSBAddressReserve(virDomainDeviceInfoPtr info, { virDomainUSBAddressSetPtr addrs = data; virDomainUSBAddressHubPtr targetHub = NULL; - char *portStr = NULL; + g_autofree char *portStr = NULL; int ret = -1; int targetPort; @@ -2459,7 +2451,6 @@ virDomainUSBAddressReserve(virDomainDeviceInfoPtr info, ret = 0; cleanup: - VIR_FREE(portStr); return ret; } @@ -2490,7 +2481,7 @@ virDomainUSBAddressRelease(virDomainUSBAddressSetPtr addrs, virDomainDeviceInfoPtr info) { virDomainUSBAddressHubPtr targetHub = NULL; - char *portStr = NULL; + g_autofree char *portStr = NULL; int targetPort; int ret = -1; @@ -2510,6 +2501,5 @@ virDomainUSBAddressRelease(virDomainUSBAddressSetPtr addrs, ret = 0; cleanup: - VIR_FREE(portStr); return ret; } -- 2.24.1

Previous patch used 'g_autofree' to eliminate instances of VIR_FREE(), making some cleanup labels obsolete. This patch removes them. Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> --- src/conf/domain_addr.c | 98 +++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 64 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index ee4dcf1d3b..0dd4b15225 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -829,30 +829,29 @@ virDomainPCIAddressReserveAddrInternal(virDomainPCIAddressSetPtr addrs, unsigned int isolationGroup, bool fromConfig) { - int ret = -1; g_autofree char *addrStr = NULL; virDomainPCIAddressBusPtr bus; virErrorNumber errType = (fromConfig ? VIR_ERR_XML_ERROR : VIR_ERR_INTERNAL_ERROR); if (!(addrStr = virPCIDeviceAddressAsString(addr))) - goto cleanup; + return -1; /* Add an extra bus if necessary */ if (addrs->dryRun && virDomainPCIAddressSetGrow(addrs, addr, flags) < 0) - goto cleanup; + return -1; /* Check that the requested bus exists, is the correct type, and we * are asking for a valid slot */ if (!virDomainPCIAddressValidate(addrs, addr, addrStr, flags, fromConfig)) - goto cleanup; + return -1; bus = &addrs->buses[addr->bus]; if (bus->slot[addr->slot].functions & (1 << addr->function)) { virReportError(errType, _("Attempted double use of PCI Address %s"), addrStr); - goto cleanup; + return -1; } /* if this is the first function to be reserved on this slot, and @@ -889,9 +888,7 @@ virDomainPCIAddressReserveAddrInternal(virDomainPCIAddressSetPtr addrs, VIR_DEBUG("Reserving PCI address %s (aggregate='%s')", addrStr, bus->slot[addr->slot].aggregate ? "true" : "false"); - ret = 0; - cleanup: - return ret; + return 0; } @@ -910,7 +907,6 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs, virDomainDeviceInfoPtr dev, virDomainPCIConnectFlags flags) { - int ret = -1; g_autofree char *addrStr = NULL; /* if flags is 0, the particular model of this device on this @@ -920,7 +916,7 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs, return 0; if (!(addrStr = virPCIDeviceAddressAsString(&dev->addr.pci))) - goto cleanup; + return -1; if (virDeviceInfoPCIAddressIsPresent(dev)) { /* We do not support hotplug multi-function PCI device now, so we should @@ -930,31 +926,28 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Only PCI device addresses with function=0" " are supported")); - goto cleanup; + return -1; } if (!virDomainPCIAddressValidate(addrs, &dev->addr.pci, addrStr, flags, true)) - goto cleanup; + return -1; if (virDomainPCIAddressReserveAddrInternal(addrs, &dev->addr.pci, flags, dev->isolationGroup, true) < 0) { - goto cleanup; + return -1; } } else { if (virDomainPCIAddressReserveNextAddr(addrs, dev, flags, -1) < 0) - goto cleanup; + return -1; } dev->addr.pci.extFlags = dev->pciAddrExtFlags; if (virDomainPCIAddressExtensionEnsureAddr(addrs, &dev->addr.pci) < 0) - goto cleanup; - - ret = 0; + return -1; - cleanup: - return ret; + return 0; } @@ -1102,13 +1095,12 @@ virDomainPCIAddressFindUnusedFunctionOnBus(virDomainPCIAddressBusPtr bus, virDomainPCIConnectFlags flags, bool *found) { - int ret = -1; g_autofree char *addrStr = NULL; *found = false; if (!(addrStr = virPCIDeviceAddressAsString(searchAddr))) - goto cleanup; + return -1; if (!virDomainPCIAddressFlagsCompatible(searchAddr, addrStr, bus->flags, flags, false, false)) { @@ -1154,10 +1146,7 @@ virDomainPCIAddressFindUnusedFunctionOnBus(virDomainPCIAddressBusPtr bus, } } - ret = 0; - - cleanup: - return ret; + return 0; } @@ -1410,7 +1399,6 @@ virDomainCCWAddressAssign(virDomainDeviceInfoPtr dev, virDomainCCWAddressSetPtr addrs, bool autoassign) { - int ret = -1; g_autofree char *addr = NULL; if (dev->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) @@ -1418,27 +1406,27 @@ virDomainCCWAddressAssign(virDomainDeviceInfoPtr dev, if (!autoassign && dev->addr.ccw.assigned) { if (!(addr = virDomainCCWAddressAsString(&dev->addr.ccw))) - goto cleanup; + return -1; if (virHashLookup(addrs->defined, addr)) { virReportError(VIR_ERR_XML_ERROR, _("The CCW devno '%s' is in use already "), addr); - goto cleanup; + return -1; } } else if (autoassign && !dev->addr.ccw.assigned) { if (!(addr = virDomainCCWAddressAsString(&addrs->next))) - goto cleanup; + return -1; while (virHashLookup(addrs->defined, addr)) { if (virDomainCCWAddressIncrement(&addrs->next) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("There are no more free CCW devnos.")); - goto cleanup; + return -1; } VIR_FREE(addr); if (!(addr = virDomainCCWAddressAsString(&addrs->next))) - goto cleanup; + return -1; } dev->addr.ccw = addrs->next; dev->addr.ccw.assigned = true; @@ -1447,14 +1435,11 @@ virDomainCCWAddressAssign(virDomainDeviceInfoPtr dev, } if (virHashAddEntry(addrs->defined, addr, addr) < 0) - goto cleanup; + return -1; else addr = NULL; /* memory will be freed by hash table */ - ret = 0; - - cleanup: - return ret; + return 0; } static int ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4) @@ -1683,7 +1668,6 @@ virDomainVirtioSerialAddrReserve(virDomainDefPtr def G_GNUC_UNUSED, void *data) { virDomainVirtioSerialAddrSetPtr addrs = data; - int ret = -1; virBitmapPtr map = NULL; bool b; ssize_t i; @@ -1699,7 +1683,7 @@ virDomainVirtioSerialAddrReserve(virDomainDefPtr def G_GNUC_UNUSED, virReportError(VIR_ERR_XML_ERROR, _("virtio serial controller %u is missing"), info->addr.vioserial.controller); - goto cleanup; + return -1; } map = addrs->controllers[i]->ports; @@ -1708,7 +1692,7 @@ virDomainVirtioSerialAddrReserve(virDomainDefPtr def G_GNUC_UNUSED, _("virtio serial controller %u does not have port %u"), info->addr.vioserial.controller, info->addr.vioserial.port); - goto cleanup; + return -1; } if (b) { @@ -1716,15 +1700,12 @@ virDomainVirtioSerialAddrReserve(virDomainDefPtr def G_GNUC_UNUSED, _("virtio serial port %u on controller %u is already occupied"), info->addr.vioserial.port, info->addr.vioserial.controller); - goto cleanup; + return -1; } ignore_value(virBitmapSetBit(map, info->addr.vioserial.port)); - ret = 0; - - cleanup: - return ret; + return 0; } /* virDomainVirtioSerialAddrSetCreateFromDomain @@ -2343,7 +2324,6 @@ virDomainUSBAddressAssignFromBus(virDomainUSBAddressSetPtr addrs, unsigned int portpath[VIR_DOMAIN_DEVICE_USB_MAX_PORT_DEPTH] = { 0 }; virDomainUSBAddressHubPtr hub = addrs->buses[bus]; g_autofree char *portStr = NULL; - int ret = -1; if (!hub) return -2; @@ -2353,7 +2333,7 @@ virDomainUSBAddressAssignFromBus(virDomainUSBAddressSetPtr addrs, /* we found a free port */ if (!(portStr = virDomainUSBAddressPortFormat(portpath))) - goto cleanup; + return -1; info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB; info->addr.usb.bus = bus; @@ -2361,11 +2341,9 @@ virDomainUSBAddressAssignFromBus(virDomainUSBAddressSetPtr addrs, VIR_DEBUG("Assigning USB addr bus=%u port=%s", info->addr.usb.bus, portStr); if (virDomainUSBAddressReserve(info, addrs) < 0) - goto cleanup; + return -1; - ret = 0; - cleanup: - return ret; + return 0; } @@ -2421,7 +2399,6 @@ virDomainUSBAddressReserve(virDomainDeviceInfoPtr info, virDomainUSBAddressSetPtr addrs = data; virDomainUSBAddressHubPtr targetHub = NULL; g_autofree char *portStr = NULL; - int ret = -1; int targetPort; if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) @@ -2432,26 +2409,23 @@ virDomainUSBAddressReserve(virDomainDeviceInfoPtr info, portStr = virDomainUSBAddressPortFormat(info->addr.usb.port); if (!portStr) - goto cleanup; + return -1; VIR_DEBUG("Reserving USB address bus=%u port=%s", info->addr.usb.bus, portStr); if (!(targetHub = virDomainUSBAddressFindPort(addrs, info, &targetPort, portStr))) - goto cleanup; + return -1; if (virBitmapIsBitSet(targetHub->portmap, targetPort)) { virReportError(VIR_ERR_XML_ERROR, _("Duplicate USB address bus %u port %s"), info->addr.usb.bus, portStr); - goto cleanup; + return -1; } ignore_value(virBitmapSetBit(targetHub->portmap, targetPort)); - ret = 0; - - cleanup: - return ret; + return 0; } @@ -2483,7 +2457,6 @@ virDomainUSBAddressRelease(virDomainUSBAddressSetPtr addrs, virDomainUSBAddressHubPtr targetHub = NULL; g_autofree char *portStr = NULL; int targetPort; - int ret = -1; if (!addrs || info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB || !virDomainUSBAddressPortIsValid(info->addr.usb.port)) @@ -2494,12 +2467,9 @@ virDomainUSBAddressRelease(virDomainUSBAddressSetPtr addrs, if (!(targetHub = virDomainUSBAddressFindPort(addrs, info, &targetPort, portStr))) - goto cleanup; + return -1; ignore_value(virBitmapClearBit(targetHub->portmap, targetPort)); - ret = 0; - - cleanup: - return ret; + return 0; } -- 2.24.1

The 'caps' variable in qemuDomainObjPrivateXMLParseAutomaticPlacement() is set to auto clean via g_autoptr(), but a 'virObjectUnref(caps)' is being executed in the 'cleanup' label. Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> --- src/qemu/qemu_domain.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 24e84a5966..999e0db49e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3106,7 +3106,6 @@ qemuDomainObjPrivateXMLParseAutomaticPlacement(xmlXPathContextPtr ctxt, ret = 0; cleanup: - virObjectUnref(caps); VIR_FREE(nodeset); VIR_FREE(cpuset); -- 2.24.1

Use g_autofree to remove VIR_FREE() calls used for cleanups. Labels that became deprecated will be removed in a later patch. In qemuDomainSetupDisk(), the 'dst' variable is not used at all and could be removed. Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> --- src/qemu/qemu_domain.c | 139 +++++++++++++---------------------------- 1 file changed, 44 insertions(+), 95 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 999e0db49e..d76c6e0c0e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -877,7 +877,7 @@ int qemuDomainWriteMasterKeyFile(virQEMUDriverPtr driver, virDomainObjPtr vm) { - char *path; + g_autofree char *path = NULL; int fd = -1; int ret = -1; qemuDomainObjPrivatePtr priv = vm->privateData; @@ -908,7 +908,6 @@ qemuDomainWriteMasterKeyFile(virQEMUDriverPtr driver, cleanup: VIR_FORCE_CLOSE(fd); - VIR_FREE(path); return ret; } @@ -944,7 +943,7 @@ qemuDomainMasterKeyFree(qemuDomainObjPrivatePtr priv) int qemuDomainMasterKeyReadFile(qemuDomainObjPrivatePtr priv) { - char *path; + g_autofree char *path = NULL; int fd = -1; uint8_t *masterKey = NULL; ssize_t masterKeyLen = 0; @@ -990,7 +989,6 @@ qemuDomainMasterKeyReadFile(qemuDomainObjPrivatePtr priv) priv->masterKeyLen = masterKeyLen; VIR_FORCE_CLOSE(fd); - VIR_FREE(path); return 0; @@ -1000,7 +998,6 @@ qemuDomainMasterKeyReadFile(qemuDomainObjPrivatePtr priv) VIR_FREE(masterKey); VIR_FORCE_CLOSE(fd); - VIR_FREE(path); return -1; } @@ -1015,7 +1012,7 @@ qemuDomainMasterKeyReadFile(qemuDomainObjPrivatePtr priv) void qemuDomainMasterKeyRemove(qemuDomainObjPrivatePtr priv) { - char *path = NULL; + g_autofree char *path = NULL; if (!priv->masterKey) return; @@ -1026,8 +1023,6 @@ qemuDomainMasterKeyRemove(qemuDomainObjPrivatePtr priv) /* Delete the master key file */ path = qemuDomainGetMasterKeyFilePath(priv->libDir); unlink(path); - - VIR_FREE(path); } @@ -1909,7 +1904,7 @@ qemuDomainSecretChardevPrepare(virQEMUDriverConfigPtr cfg, const char *chrAlias, virDomainChrSourceDefPtr dev) { - char *charAlias = NULL; + g_autofree char *charAlias = NULL; if (dev->type != VIR_DOMAIN_CHR_TYPE_TCP) return 0; @@ -1925,7 +1920,6 @@ qemuDomainSecretChardevPrepare(virQEMUDriverConfigPtr cfg, chrSourcePriv->secinfo = qemuDomainSecretInfoTLSNew(priv, charAlias, cfg->chardevTLSx509secretUUID); - VIR_FREE(charAlias); if (!chrSourcePriv->secinfo) return -1; @@ -2143,7 +2137,7 @@ qemuDomainSetPrivatePaths(virQEMUDriverPtr driver, { virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); qemuDomainObjPrivatePtr priv = vm->privateData; - char *domname = virDomainDefGetShortName(vm->def); + g_autofree char *domname = virDomainDefGetShortName(vm->def); int ret = -1; if (!domname) @@ -2159,7 +2153,6 @@ qemuDomainSetPrivatePaths(virQEMUDriverPtr driver, ret = 0; cleanup: virObjectUnref(cfg); - VIR_FREE(domname); return ret; } @@ -2340,8 +2333,8 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt, virStorageSourcePtr src) { qemuDomainStorageSourcePrivatePtr priv; - char *authalias = NULL; - char *encalias = NULL; + g_autofree char *authalias = NULL; + g_autofree char *encalias = NULL; int ret = -1; src->nodestorage = virXPathString("string(./nodenames/nodename[@type='storage']/@name)", ctxt); @@ -2374,8 +2367,6 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt, ret = 0; cleanup: - VIR_FREE(authalias); - VIR_FREE(encalias); return ret; } @@ -2497,8 +2488,8 @@ static int qemuDomainObjPrivateXMLFormatAutomaticPlacement(virBufferPtr buf, qemuDomainObjPrivatePtr priv) { - char *nodeset = NULL; - char *cpuset = NULL; + g_autofree char *nodeset = NULL; + g_autofree char *cpuset = NULL; int ret = -1; if (!priv->autoNodeset && !priv->autoCpuset) @@ -2520,8 +2511,6 @@ qemuDomainObjPrivateXMLFormatAutomaticPlacement(virBufferPtr buf, ret = 0; cleanup: - VIR_FREE(nodeset); - VIR_FREE(cpuset); return ret; } @@ -3022,8 +3011,8 @@ qemuDomainObjPrivateXMLParseVcpu(xmlNodePtr node, virDomainDefPtr def) { virDomainVcpuDefPtr vcpu; - char *idstr; - char *pidstr; + g_autofree char *idstr = NULL; + g_autofree char *pidstr = NULL; unsigned int tmp; int ret = -1; @@ -3052,8 +3041,6 @@ qemuDomainObjPrivateXMLParseVcpu(xmlNodePtr node, ret = 0; cleanup: - VIR_FREE(idstr); - VIR_FREE(pidstr); return ret; } @@ -3064,8 +3051,8 @@ qemuDomainObjPrivateXMLParseAutomaticPlacement(xmlXPathContextPtr ctxt, virQEMUDriverPtr driver) { g_autoptr(virCapsHostNUMA) caps = NULL; - char *nodeset; - char *cpuset; + g_autofree char *nodeset = NULL; + g_autofree char *cpuset = NULL; int nodesetSize = 0; size_t i; int ret = -1; @@ -3106,8 +3093,6 @@ qemuDomainObjPrivateXMLParseAutomaticPlacement(xmlXPathContextPtr ctxt, ret = 0; cleanup: - VIR_FREE(nodeset); - VIR_FREE(cpuset); return ret; } @@ -3428,7 +3413,7 @@ qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt, { int ret = -1; int val; - char *valStr; + g_autofree char *valStr = NULL; if ((valStr = virXPathString("string(./allowReboot/@value)", ctxt))) { if ((val = virTristateBoolTypeFromString(valStr)) < 0) { @@ -3442,7 +3427,6 @@ qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt, ret = 0; cleanup: - VIR_FREE(valStr); return ret; } @@ -3507,8 +3491,7 @@ qemuDomainObjPrivateXMLParseJobNBD(virDomainObjPtr vm, qemuDomainObjPrivatePtr priv, xmlXPathContextPtr ctxt) { - xmlNodePtr *nodes = NULL; - char *dst = NULL; + g_autofree xmlNodePtr *nodes = NULL; size_t i; int n; int ret = -1; @@ -3524,6 +3507,7 @@ qemuDomainObjPrivateXMLParseJobNBD(virDomainObjPtr vm, } for (i = 0; i < n; i++) { virDomainDiskDefPtr disk; + g_autofree char *dst = NULL; if ((dst = virXMLPropString(nodes[i], "dev")) && (disk = virDomainDiskByTarget(vm->def, dst))) { @@ -3534,16 +3518,12 @@ qemuDomainObjPrivateXMLParseJobNBD(virDomainObjPtr vm, priv->driver->xmlopt) < 0) goto cleanup; } - - VIR_FREE(dst); } } ret = 0; cleanup: - VIR_FREE(nodes); - VIR_FREE(dst); return ret; } @@ -3554,7 +3534,7 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, xmlXPathContextPtr ctxt) { VIR_XPATH_NODE_AUTORESTORE(ctxt); - char *tmp = NULL; + g_autofree char *tmp = NULL; int ret = -1; if (!(ctxt->node = virXPathNode("./job[1]", ctxt))) { @@ -3610,7 +3590,6 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, ret = 0; cleanup: - VIR_FREE(tmp); return ret; } @@ -3662,10 +3641,10 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, qemuDomainObjPrivatePtr priv = vm->privateData; virQEMUDriverPtr driver = config->priv; char *monitorpath; - char *tmp = NULL; + g_autofree char *tmp = NULL; int n; size_t i; - xmlNodePtr *nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; xmlNodePtr node = NULL; virQEMUCapsPtr qemuCaps = NULL; @@ -3752,16 +3731,14 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, goto error; for (i = 0; i < n; i++) { - char *str = virXMLPropString(nodes[i], "name"); + g_autofree char *str = virXMLPropString(nodes[i], "name"); if (str) { int flag = virQEMUCapsTypeFromString(str); if (flag < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown qemu capabilities flag %s"), str); - VIR_FREE(str); goto error; } - VIR_FREE(str); virQEMUCapsSet(qemuCaps, flag); } } @@ -3867,8 +3844,6 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, return 0; error: - VIR_FREE(nodes); - VIR_FREE(tmp); virBitmapFree(priv->namespaces); priv->namespaces = NULL; virObjectUnref(priv->monConfig); @@ -8553,7 +8528,7 @@ qemuDomainChrDefDropDefaultPath(virDomainChrDefPtr chr, { virQEMUDriverConfigPtr cfg; virBuffer buf = VIR_BUFFER_INITIALIZER; - char *regexp = NULL; + g_autofree char *regexp = NULL; int ret = -1; if (chr->deviceType != VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL || @@ -8575,7 +8550,6 @@ qemuDomainChrDefDropDefaultPath(virDomainChrDefPtr chr, VIR_FREE(chr->source->data.nix.path); ret = 0; - VIR_FREE(regexp); virObjectUnref(cfg); return ret; } @@ -8871,8 +8845,8 @@ qemuDomainDeviceDiskDefPostParseRestoreSecAlias(virDomainDiskDefPtr disk, qemuDomainStorageSourcePrivatePtr priv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src); bool restoreAuthSecret = false; bool restoreEncSecret = false; - char *authalias = NULL; - char *encalias = NULL; + g_autofree char *authalias = NULL; + g_autofree char *encalias = NULL; int ret = -1; if (!(parseFlags & VIR_DOMAIN_DEF_PARSE_STATUS) || @@ -8930,8 +8904,6 @@ qemuDomainDeviceDiskDefPostParseRestoreSecAlias(virDomainDiskDefPtr disk, ret = 0; cleanup: - VIR_FREE(authalias); - VIR_FREE(encalias); return ret; } @@ -10042,14 +10014,13 @@ qemuDomainDefCopy(virQEMUDriverPtr driver, unsigned int flags) { virDomainDefPtr ret = NULL; - char *xml; + g_autofree char *xml = NULL; if (!(xml = qemuDomainDefFormatXML(driver, qemuCaps, src, flags))) return NULL; ret = qemuDomainDefFromXML(driver, qemuCaps, xml); - VIR_FREE(xml); return ret; } @@ -10348,7 +10319,7 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver, qemuDomainLogContextPtr logCtxt) { virErrorPtr orig_err = NULL; - char *timestamp = NULL; + g_autofree char *timestamp = NULL; char uuidstr[VIR_UUID_STRING_BUFLEN]; int rc; @@ -10389,7 +10360,6 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver, virResetLastError(); cleanup: - VIR_FREE(timestamp); virErrorRestore(&orig_err); } @@ -10586,7 +10556,7 @@ int qemuDomainLogContextWrite(qemuDomainLogContextPtr ctxt, const char *fmt, ...) { va_list argptr; - char *message = NULL; + g_autofree char *message = NULL; int ret = -1; va_start(argptr, fmt); @@ -10608,7 +10578,6 @@ int qemuDomainLogContextWrite(qemuDomainLogContextPtr ctxt, cleanup: va_end(argptr); - VIR_FREE(message); return ret; } @@ -10677,9 +10646,9 @@ qemuDomainLogAppendMessage(virQEMUDriverPtr driver, virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); virLogManagerPtr manager = NULL; va_list ap; - char *path = NULL; + g_autofree char *path = NULL; int writefd = -1; - char *message = NULL; + g_autofree char *message = NULL; int ret = -1; va_start(ap, fmt); @@ -10713,11 +10682,9 @@ qemuDomainLogAppendMessage(virQEMUDriverPtr driver, cleanup: va_end(ap); - VIR_FREE(message); VIR_FORCE_CLOSE(writefd); virLogManagerFree(manager); virObjectUnref(cfg); - VIR_FREE(path); return ret; } @@ -10765,10 +10732,10 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm, virDomainXMLOptionPtr xmlopt, const char *snapshotDir) { - char *newxml = NULL; + g_autofree char *newxml = NULL; int ret = -1; - char *snapDir = NULL; - char *snapFile = NULL; + g_autofree char *snapDir = NULL; + g_autofree char *snapFile = NULL; char uuidstr[VIR_UUID_STRING_BUFLEN]; unsigned int flags = VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE | VIR_DOMAIN_SNAPSHOT_FORMAT_INTERNAL; @@ -10793,9 +10760,6 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm, ret = virXMLSaveFile(snapFile, NULL, "snapshot-edit", newxml); cleanup: - VIR_FREE(snapFile); - VIR_FREE(snapDir); - VIR_FREE(newxml); return ret; } @@ -10900,7 +10864,7 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver, bool update_parent, bool metadata_only) { - char *snapFile = NULL; + g_autofree char *snapFile = NULL; int ret = -1; qemuDomainObjPrivatePtr priv; virDomainMomentObjPtr parentsnap = NULL; @@ -10954,7 +10918,6 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver, ret = 0; cleanup: - VIR_FREE(snapFile); virObjectUnref(cfg); return ret; } @@ -12282,7 +12245,7 @@ qemuDomainCheckABIStability(virQEMUDriverPtr driver, qemuDomainObjPrivatePtr priv = vm->privateData; virDomainDefPtr migratableSrc = NULL; virDomainDefPtr migratableDst = NULL; - char *xml = NULL; + g_autofree char *xml = NULL; bool ret = false; if (!(xml = qemuDomainFormatXML(driver, vm, COPY_FLAGS)) || @@ -12295,7 +12258,6 @@ qemuDomainCheckABIStability(virQEMUDriverPtr driver, dst, migratableDst); cleanup: - VIR_FREE(xml); virDomainDefFree(migratableSrc); virDomainDefFree(migratableDst); return ret; @@ -14127,7 +14089,7 @@ qemuDomainGetPreservedMountPath(virQEMUDriverConfigPtr cfg, char *path = NULL; char *tmp; const char *suffix = mountpoint + strlen(QEMU_DEVPREFIX); - char *domname = virDomainDefGetShortName(vm->def); + g_autofree char *domname = virDomainDefGetShortName(vm->def); size_t off; if (!domname) @@ -14152,7 +14114,6 @@ qemuDomainGetPreservedMountPath(virQEMUDriverConfigPtr cfg, tmp++; } - VIR_FREE(domname); return path; } @@ -14254,8 +14215,8 @@ qemuDomainCreateDeviceRecursive(const char *device, bool allow_noent, unsigned int ttl) { - char *devicePath = NULL; - char *target = NULL; + g_autofree char *devicePath = NULL; + g_autofree char *target = NULL; GStatBuf sb; int ret = -1; bool isLink = false; @@ -14365,15 +14326,13 @@ qemuDomainCreateDeviceRecursive(const char *device, * /dev/stdout -> /proc/self/fd/1 (no change needed) */ if (!g_path_is_absolute(target)) { - char *c = NULL, *tmp = NULL, *devTmp = NULL; - - devTmp = g_strdup(device); + g_autofree char *devTmp = g_strdup(device); + char *c = NULL, *tmp = NULL; if ((c = strrchr(devTmp, '/'))) *(c + 1) = '\0'; tmp = g_strdup_printf("%s%s", devTmp, target); - VIR_FREE(devTmp); VIR_FREE(target); target = g_steal_pointer(&tmp); } @@ -14468,8 +14427,6 @@ qemuDomainCreateDeviceRecursive(const char *device, ret = 0; cleanup: - VIR_FREE(target); - VIR_FREE(devicePath); #ifdef WITH_SELINUX freecon(tcon); #endif @@ -14515,8 +14472,8 @@ qemuDomainSetupDev(virQEMUDriverConfigPtr cfg, virDomainObjPtr vm, const struct qemuDomainCreateDeviceData *data) { - char *mount_options = NULL; - char *opts = NULL; + g_autofree char *mount_options = NULL; + g_autofree char *opts = NULL; int ret = -1; VIR_DEBUG("Setting up /dev/ for domain %s", vm->def->name); @@ -14540,8 +14497,6 @@ qemuDomainSetupDev(virQEMUDriverConfigPtr cfg, ret = 0; cleanup: - VIR_FREE(opts); - VIR_FREE(mount_options); return ret; } @@ -14552,7 +14507,6 @@ qemuDomainSetupDisk(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED, const struct qemuDomainCreateDeviceData *data) { virStorageSourcePtr next; - char *dst = NULL; bool hasNVMe = false; int ret = -1; @@ -14589,7 +14543,6 @@ qemuDomainSetupDisk(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED, ret = 0; cleanup: - VIR_FREE(dst); return ret; } @@ -15290,7 +15243,7 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver, virQEMUDriverConfigPtr cfg = NULL; struct qemuDomainAttachDeviceMknodData data; int ret = -1; - char *target = NULL; + g_autofree char *target = NULL; bool isLink; bool isReg; bool isDir; @@ -15337,15 +15290,13 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver, } if (!g_path_is_absolute(target)) { - char *c = NULL, *tmp = NULL, *fileTmp = NULL; - - fileTmp = g_strdup(file); + g_autofree char *fileTmp = g_strdup(file); + char *c = NULL, *tmp = NULL; if ((c = strrchr(fileTmp, '/'))) *(c + 1) = '\0'; tmp = g_strdup_printf("%s%s", fileTmp, target); - VIR_FREE(fileTmp); VIR_FREE(target); target = g_steal_pointer(&tmp); } @@ -15412,7 +15363,6 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver, virFileFreeACLs(&data.acl); if (isReg && target) umount(target); - VIR_FREE(target); virObjectUnref(cfg); return ret; } @@ -15946,7 +15896,7 @@ qemuDomainGetStorageSourceByDevstr(const char *devstr, { virDomainDiskDefPtr disk = NULL; virStorageSourcePtr src = NULL; - char *target = NULL; + g_autofree char *target = NULL; unsigned int idx; size_t i; @@ -15975,7 +15925,6 @@ qemuDomainGetStorageSourceByDevstr(const char *devstr, src = virStorageFileChainLookup(disk->src, NULL, NULL, idx, NULL); cleanup: - VIR_FREE(target); return src; } -- 2.24.1

Avoid some of the virObjectUnref() calls by using g_autoptr. Aside from the 'cleanup' label in qemuDomainSetFakeReboot(), all other now deprecated cleanup labels will be removed in the next patch. Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> --- src/qemu/qemu_domain.c | 87 ++++++++++++------------------------------ 1 file changed, 25 insertions(+), 62 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d76c6e0c0e..6bf704a6f5 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1497,10 +1497,9 @@ qemuDomainSecretPlainSetup(qemuDomainSecretInfoPtr secinfo, const char *username, virSecretLookupTypeDefPtr seclookupdef) { - virConnectPtr conn; + g_autoptr(virConnect) conn = virGetConnectSecret(); int ret = -1; - conn = virGetConnectSecret(); if (!conn) return -1; @@ -1511,7 +1510,6 @@ qemuDomainSecretPlainSetup(qemuDomainSecretInfoPtr secinfo, &secinfo->s.plain.secret, &secinfo->s.plain.secretlen); - virObjectUnref(conn); return ret; } @@ -1538,7 +1536,7 @@ qemuDomainSecretAESSetup(qemuDomainObjPrivatePtr priv, virSecretLookupTypeDefPtr seclookupdef, bool isLuks) { - virConnectPtr conn; + g_autoptr(virConnect) conn = virGetConnectSecret(); int ret = -1; uint8_t *raw_iv = NULL; size_t ivlen = QEMU_DOMAIN_AES_IV_LEN; @@ -1547,7 +1545,6 @@ qemuDomainSecretAESSetup(qemuDomainObjPrivatePtr priv, uint8_t *ciphertext = NULL; size_t ciphertextlen = 0; - conn = virGetConnectSecret(); if (!conn) return -1; @@ -1591,7 +1588,6 @@ qemuDomainSecretAESSetup(qemuDomainObjPrivatePtr priv, VIR_DISPOSE_N(raw_iv, ivlen); VIR_DISPOSE_N(secret, secretlen); VIR_DISPOSE_N(ciphertext, ciphertextlen); - virObjectUnref(conn); return ret; } @@ -2036,7 +2032,7 @@ qemuDomainSecretPrepare(virQEMUDriverPtr driver, virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv = vm->privateData; - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); size_t i; int ret = -1; @@ -2107,7 +2103,6 @@ qemuDomainSecretPrepare(virQEMUDriverPtr driver, ret = 0; cleanup: - virObjectUnref(cfg); return ret; } @@ -2118,7 +2113,7 @@ qemuDomainSetPrivatePathsOld(virQEMUDriverPtr driver, virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv = vm->privateData; - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); if (!priv->libDir) priv->libDir = g_strdup_printf("%s/domain-%s", cfg->libDir, vm->def->name); @@ -2126,8 +2121,6 @@ qemuDomainSetPrivatePathsOld(virQEMUDriverPtr driver, if (!priv->channelTargetDir) priv->channelTargetDir = g_strdup_printf("%s/domain-%s", cfg->channelTargetDir, vm->def->name); - - virObjectUnref(cfg); } @@ -2135,7 +2128,7 @@ int qemuDomainSetPrivatePaths(virQEMUDriverPtr driver, virDomainObjPtr vm) { - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); qemuDomainObjPrivatePtr priv = vm->privateData; g_autofree char *domname = virDomainDefGetShortName(vm->def); int ret = -1; @@ -2152,7 +2145,6 @@ qemuDomainSetPrivatePaths(virQEMUDriverPtr driver, ret = 0; cleanup: - virObjectUnref(cfg); return ret; } @@ -3646,7 +3638,7 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, size_t i; g_autofree xmlNodePtr *nodes = NULL; xmlNodePtr node = NULL; - virQEMUCapsPtr qemuCaps = NULL; + g_autoptr(virQEMUCaps) qemuCaps = NULL; if (!(priv->monConfig = virDomainChrSourceDefNew(NULL))) goto error; @@ -3850,7 +3842,6 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, priv->monConfig = NULL; virStringListFree(priv->qemuDevices); priv->qemuDevices = NULL; - virObjectUnref(qemuCaps); return -1; } @@ -5671,8 +5662,8 @@ qemuDomainDefValidate(const virDomainDef *def, void *opaque) { virQEMUDriverPtr driver = opaque; - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); - virQEMUCapsPtr qemuCaps = NULL; + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUCaps) qemuCaps = NULL; int ret = -1; size_t i; @@ -5878,8 +5869,6 @@ qemuDomainDefValidate(const virDomainDef *def, ret = 0; cleanup: - virObjectUnref(qemuCaps); - virObjectUnref(cfg); return ret; } @@ -8526,7 +8515,7 @@ static int qemuDomainChrDefDropDefaultPath(virDomainChrDefPtr chr, virQEMUDriverPtr driver) { - virQEMUDriverConfigPtr cfg; + g_autoptr(virQEMUDriverConfig) cfg = NULL; virBuffer buf = VIR_BUFFER_INITIALIZER; g_autofree char *regexp = NULL; int ret = -1; @@ -8550,7 +8539,6 @@ qemuDomainChrDefDropDefaultPath(virDomainChrDefPtr chr, VIR_FREE(chr->source->data.nix.path); ret = 0; - virObjectUnref(cfg); return ret; } @@ -9207,14 +9195,12 @@ static void qemuDomainObjSaveStatus(virQEMUDriverPtr driver, virDomainObjPtr obj) { - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); if (virDomainObjIsActive(obj)) { if (virDomainObjSave(obj, driver->xmlopt, cfg->stateDir) < 0) VIR_WARN("Failed to save status on vm %s", obj->def->name); } - - virObjectUnref(cfg); } @@ -9375,7 +9361,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, unsigned long long then; bool nested = job == QEMU_JOB_ASYNC_NESTED; bool async = job == QEMU_JOB_ASYNC; - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); const char *blocker = NULL; const char *agentBlocker = NULL; int ret = -1; @@ -9393,10 +9379,8 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, qemuDomainAgentJobTypeToString(priv->job.agentActive), qemuDomainAsyncJobTypeToString(priv->job.asyncJob)); - if (virTimeMillisNow(&now) < 0) { - virObjectUnref(cfg); + if (virTimeMillisNow(&now) < 0) return -1; - } priv->jobs_queued++; then = now + QEMU_JOB_WAIT_TIME; @@ -9478,7 +9462,6 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, if (qemuDomainTrackJob(job)) qemuDomainObjSaveStatus(driver, obj); - virObjectUnref(cfg); return 0; error: @@ -9570,7 +9553,6 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, cleanup: priv->jobs_queued--; - virObjectUnref(cfg); return ret; } @@ -10369,7 +10351,7 @@ void qemuDomainObjCheckTaint(virQEMUDriverPtr driver, qemuDomainLogContextPtr logCtxt) { size_t i; - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); qemuDomainObjPrivatePtr priv = obj->privateData; bool custom_hypervisor_feat = false; @@ -10410,8 +10392,6 @@ void qemuDomainObjCheckTaint(virQEMUDriverPtr driver, if (obj->def->os.dtb) qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_CUSTOM_DTB, logCtxt); - - virObjectUnref(cfg); } @@ -10420,7 +10400,7 @@ void qemuDomainObjCheckDiskTaint(virQEMUDriverPtr driver, virDomainDiskDefPtr disk, qemuDomainLogContextPtr logCtxt) { - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); if (disk->rawio == VIR_TRISTATE_BOOL_YES) qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_HIGH_PRIVILEGES, @@ -10431,8 +10411,6 @@ void qemuDomainObjCheckDiskTaint(virQEMUDriverPtr driver, disk->src->path && virFileIsCDROM(disk->src->path) == 1) qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_CDROM_PASSTHROUGH, logCtxt); - - virObjectUnref(cfg); } @@ -10468,7 +10446,7 @@ qemuDomainLogContextPtr qemuDomainLogContextNew(virQEMUDriverPtr driver, virDomainObjPtr vm, qemuDomainLogContextMode mode) { - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); qemuDomainLogContextPtr ctxt = NULL; if (qemuDomainInitialize() < 0) @@ -10542,7 +10520,6 @@ qemuDomainLogContextPtr qemuDomainLogContextNew(virQEMUDriverPtr driver, } cleanup: - virObjectUnref(cfg); return ctxt; error: @@ -10643,7 +10620,7 @@ qemuDomainLogAppendMessage(virQEMUDriverPtr driver, const char *fmt, ...) { - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); virLogManagerPtr manager = NULL; va_list ap; g_autofree char *path = NULL; @@ -10684,7 +10661,6 @@ qemuDomainLogAppendMessage(virQEMUDriverPtr driver, va_end(ap); VIR_FORCE_CLOSE(writefd); virLogManagerFree(manager); - virObjectUnref(cfg); return ret; } @@ -10868,7 +10844,7 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver, int ret = -1; qemuDomainObjPrivatePtr priv; virDomainMomentObjPtr parentsnap = NULL; - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); if (!metadata_only) { if (!virDomainObjIsActive(vm)) { @@ -10918,7 +10894,6 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver, ret = 0; cleanup: - virObjectUnref(cfg); return ret; } @@ -10962,12 +10937,10 @@ static void qemuDomainRemoveInactiveCommon(virQEMUDriverPtr driver, virDomainObjPtr vm) { - virQEMUDriverConfigPtr cfg; + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); g_autofree char *snapDir = NULL; g_autofree char *chkDir = NULL; - cfg = virQEMUDriverGetConfig(driver); - /* Remove any snapshot metadata prior to removing the domain */ if (qemuDomainSnapshotDiscardAllMetadata(driver, vm) < 0) { VIR_WARN("unable to remove all snapshots for domain %s", @@ -10989,8 +10962,6 @@ qemuDomainRemoveInactiveCommon(virQEMUDriverPtr driver, VIR_WARN("unable to remove checkpoint directory %s", chkDir); } qemuExtDevicesCleanupHost(driver, vm->def); - - virObjectUnref(cfg); } @@ -11086,18 +11057,15 @@ qemuDomainSetFakeReboot(virQEMUDriverPtr driver, bool value) { qemuDomainObjPrivatePtr priv = vm->privateData; - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); if (priv->fakeReboot == value) - goto cleanup; + return; priv->fakeReboot = value; if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) VIR_WARN("Failed to save status on vm %s", vm->def->name); - - cleanup: - virObjectUnref(cfg); } static void @@ -11304,7 +11272,7 @@ qemuDomainStorageFileInit(virQEMUDriverPtr driver, virStorageSourcePtr src, virStorageSourcePtr parent) { - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); uid_t uid; gid_t gid; int ret = -1; @@ -11317,7 +11285,6 @@ qemuDomainStorageFileInit(virQEMUDriverPtr driver, ret = 0; cleanup: - virObjectUnref(cfg); return ret; } @@ -15026,7 +14993,7 @@ int qemuDomainCreateNamespace(virQEMUDriverPtr driver, virDomainObjPtr vm) { - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); int ret = -1; if (virBitmapIsBitSet(cfg->namespaces, QEMU_DOMAIN_NS_MOUNT) && @@ -15035,7 +15002,6 @@ qemuDomainCreateNamespace(virQEMUDriverPtr driver, ret = 0; cleanup: - virObjectUnref(cfg); return ret; } @@ -15240,7 +15206,7 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver, size_t ndevMountsPath, unsigned int ttl) { - virQEMUDriverConfigPtr cfg = NULL; + g_autoptr(virQEMUDriverConfig) cfg = NULL; struct qemuDomainAttachDeviceMknodData data; int ret = -1; g_autofree char *target = NULL; @@ -15363,7 +15329,6 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver, virFileFreeACLs(&data.acl); if (isReg && target) umount(target); - virObjectUnref(cfg); return ret; } @@ -15456,7 +15421,7 @@ qemuDomainNamespaceMknodPaths(virDomainObjPtr vm, { qemuDomainObjPrivatePtr priv = vm->privateData; virQEMUDriverPtr driver = priv->driver; - virQEMUDriverConfigPtr cfg; + g_autoptr(virQEMUDriverConfig) cfg = NULL; char **devMountsPath = NULL; size_t ndevMountsPath = 0; int ret = -1; @@ -15483,7 +15448,6 @@ qemuDomainNamespaceMknodPaths(virDomainObjPtr vm, ret = 0; cleanup: virStringListFreeCount(devMountsPath, ndevMountsPath); - virObjectUnref(cfg); return ret; } @@ -15505,7 +15469,7 @@ qemuDomainNamespaceUnlinkPaths(virDomainObjPtr vm, { qemuDomainObjPrivatePtr priv = vm->privateData; virQEMUDriverPtr driver = priv->driver; - virQEMUDriverConfigPtr cfg; + g_autoptr(virQEMUDriverConfig) cfg = NULL; char **devMountsPath = NULL; size_t ndevMountsPath = 0; size_t i; @@ -15531,7 +15495,6 @@ qemuDomainNamespaceUnlinkPaths(virDomainObjPtr vm, ret = 0; cleanup: virStringListFreeCount(devMountsPath, ndevMountsPath); - virObjectUnref(cfg); return ret; } -- 2.24.1

Previous patches deprecated some 'cleanup' labels. Let's remove them. Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> --- src/qemu/qemu_domain.c | 267 +++++++++++++++-------------------------- 1 file changed, 98 insertions(+), 169 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6bf704a6f5..931554eeb6 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2034,42 +2034,41 @@ qemuDomainSecretPrepare(virQEMUDriverPtr driver, qemuDomainObjPrivatePtr priv = vm->privateData; g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); size_t i; - int ret = -1; /* disk secrets are prepared when preparing disks */ for (i = 0; i < vm->def->nhostdevs; i++) { if (qemuDomainSecretHostdevPrepare(priv, vm->def->hostdevs[i]) < 0) - goto cleanup; + return -1; } for (i = 0; i < vm->def->nserials; i++) { if (qemuDomainSecretChardevPrepare(cfg, priv, vm->def->serials[i]->info.alias, vm->def->serials[i]->source) < 0) - goto cleanup; + return -1; } for (i = 0; i < vm->def->nparallels; i++) { if (qemuDomainSecretChardevPrepare(cfg, priv, vm->def->parallels[i]->info.alias, vm->def->parallels[i]->source) < 0) - goto cleanup; + return -1; } for (i = 0; i < vm->def->nchannels; i++) { if (qemuDomainSecretChardevPrepare(cfg, priv, vm->def->channels[i]->info.alias, vm->def->channels[i]->source) < 0) - goto cleanup; + return -1; } for (i = 0; i < vm->def->nconsoles; i++) { if (qemuDomainSecretChardevPrepare(cfg, priv, vm->def->consoles[i]->info.alias, vm->def->consoles[i]->source) < 0) - goto cleanup; + return -1; } for (i = 0; i < vm->def->nsmartcards; i++) @@ -2078,32 +2077,29 @@ qemuDomainSecretPrepare(virQEMUDriverPtr driver, qemuDomainSecretChardevPrepare(cfg, priv, vm->def->smartcards[i]->info.alias, vm->def->smartcards[i]->data.passthru) < 0) - goto cleanup; + return -1; for (i = 0; i < vm->def->nrngs; i++) { if (vm->def->rngs[i]->backend == VIR_DOMAIN_RNG_BACKEND_EGD && qemuDomainSecretChardevPrepare(cfg, priv, vm->def->rngs[i]->info.alias, vm->def->rngs[i]->source.chardev) < 0) - goto cleanup; + return -1; } for (i = 0; i < vm->def->nredirdevs; i++) { if (qemuDomainSecretChardevPrepare(cfg, priv, vm->def->redirdevs[i]->info.alias, vm->def->redirdevs[i]->source) < 0) - goto cleanup; + return -1; } for (i = 0; i < vm->def->ngraphics; i++) { if (qemuDomainSecretGraphicsPrepare(cfg, priv, vm->def->graphics[i]) < 0) - goto cleanup; + return -1; } - ret = 0; - - cleanup: - return ret; + return 0; } @@ -2131,10 +2127,9 @@ qemuDomainSetPrivatePaths(virQEMUDriverPtr driver, g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); qemuDomainObjPrivatePtr priv = vm->privateData; g_autofree char *domname = virDomainDefGetShortName(vm->def); - int ret = -1; if (!domname) - goto cleanup; + return -1; if (!priv->libDir) priv->libDir = g_strdup_printf("%s/domain-%s", cfg->libDir, domname); @@ -2143,9 +2138,7 @@ qemuDomainSetPrivatePaths(virQEMUDriverPtr driver, priv->channelTargetDir = g_strdup_printf("%s/domain-%s", cfg->channelTargetDir, domname); - ret = 0; - cleanup: - return ret; + return 0; } @@ -2327,7 +2320,6 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt, qemuDomainStorageSourcePrivatePtr priv; g_autofree char *authalias = NULL; g_autofree char *encalias = NULL; - int ret = -1; src->nodestorage = virXPathString("string(./nodenames/nodename[@type='storage']/@name)", ctxt); src->nodeformat = virXPathString("string(./nodenames/nodename[@type='format']/@name)", ctxt); @@ -2342,25 +2334,21 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt, if (authalias || encalias) { if (!src->privateData && !(src->privateData = qemuDomainStorageSourcePrivateNew())) - goto cleanup; + return -1; priv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src); if (qemuStorageSourcePrivateDataAssignSecinfo(&priv->secinfo, &authalias) < 0) - goto cleanup; + return -1; if (qemuStorageSourcePrivateDataAssignSecinfo(&priv->encinfo, &encalias) < 0) - goto cleanup; + return -1; } if (virStorageSourcePrivateDataParseRelPath(ctxt, src) < 0) - goto cleanup; - - ret = 0; - - cleanup: + return -1; - return ret; + return 0; } @@ -2482,28 +2470,24 @@ qemuDomainObjPrivateXMLFormatAutomaticPlacement(virBufferPtr buf, { g_autofree char *nodeset = NULL; g_autofree char *cpuset = NULL; - int ret = -1; if (!priv->autoNodeset && !priv->autoCpuset) return 0; if (priv->autoNodeset && !((nodeset = virBitmapFormat(priv->autoNodeset)))) - goto cleanup; + return -1; if (priv->autoCpuset && !((cpuset = virBitmapFormat(priv->autoCpuset)))) - goto cleanup; + return -1; virBufferAddLit(buf, "<numad"); virBufferEscapeString(buf, " nodeset='%s'", nodeset); virBufferEscapeString(buf, " cpuset='%s'", cpuset); virBufferAddLit(buf, "/>\n"); - ret = 0; - - cleanup: - return ret; + return 0; } @@ -3006,7 +2990,6 @@ qemuDomainObjPrivateXMLParseVcpu(xmlNodePtr node, g_autofree char *idstr = NULL; g_autofree char *pidstr = NULL; unsigned int tmp; - int ret = -1; idstr = virXMLPropString(node, "id"); @@ -3014,26 +2997,23 @@ qemuDomainObjPrivateXMLParseVcpu(xmlNodePtr node, (virStrToLong_uip(idstr, NULL, 10, &idx) < 0)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse vcpu index '%s'"), idstr); - goto cleanup; + return -1; } if (!(vcpu = virDomainDefGetVcpu(def, idx))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid vcpu index '%u'"), idx); - goto cleanup; + return -1; } if (!(pidstr = virXMLPropString(node, "pid"))) - goto cleanup; + return -1; if (virStrToLong_uip(pidstr, NULL, 10, &tmp) < 0) - goto cleanup; + return -1; QEMU_DOMAIN_VCPU_PRIVATE(vcpu)->tid = tmp; - ret = 0; - - cleanup: - return ret; + return 0; } @@ -3047,7 +3027,6 @@ qemuDomainObjPrivateXMLParseAutomaticPlacement(xmlXPathContextPtr ctxt, g_autofree char *cpuset = NULL; int nodesetSize = 0; size_t i; - int ret = -1; nodeset = virXPathString("string(./numad/@nodeset)", ctxt); cpuset = virXPathString("string(./numad/@cpuset)", ctxt); @@ -3056,7 +3035,7 @@ qemuDomainObjPrivateXMLParseAutomaticPlacement(xmlXPathContextPtr ctxt, return 0; if (!(caps = virQEMUDriverGetHostNUMACaps(driver))) - goto cleanup; + return -1; /* Figure out how big the nodeset bitmap needs to be. * This is necessary because NUMA node IDs are not guaranteed to @@ -3069,24 +3048,20 @@ qemuDomainObjPrivateXMLParseAutomaticPlacement(xmlXPathContextPtr ctxt, if (nodeset && virBitmapParse(nodeset, &priv->autoNodeset, nodesetSize) < 0) - goto cleanup; + return -1; if (cpuset) { if (virBitmapParse(cpuset, &priv->autoCpuset, VIR_DOMAIN_CPUMASK_LEN) < 0) - goto cleanup; + return -1; } else { /* autoNodeset is present in this case, since otherwise we wouldn't * reach this code */ if (!(priv->autoCpuset = virCapabilitiesHostNUMAGetCpus(caps, priv->autoNodeset))) - goto cleanup; + return -1; } - ret = 0; - - cleanup: - - return ret; + return 0; } @@ -3403,7 +3378,6 @@ int qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt, virTristateBool *allowReboot) { - int ret = -1; int val; g_autofree char *valStr = NULL; @@ -3411,15 +3385,12 @@ qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt, if ((val = virTristateBoolTypeFromString(valStr)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid allowReboot value '%s'"), valStr); - goto cleanup; + return -1; } *allowReboot = val; } - ret = 0; - - cleanup: - return ret; + return 0; } @@ -3486,10 +3457,9 @@ qemuDomainObjPrivateXMLParseJobNBD(virDomainObjPtr vm, g_autofree xmlNodePtr *nodes = NULL; size_t i; int n; - int ret = -1; if ((n = virXPathNodeSet("./disk[@migrating='yes']", ctxt, &nodes)) < 0) - goto cleanup; + return -1; if (n > 0) { if (priv->job.asyncJob != QEMU_ASYNC_JOB_MIGRATION_OUT) { @@ -3508,15 +3478,12 @@ qemuDomainObjPrivateXMLParseJobNBD(virDomainObjPtr vm, if (qemuDomainObjPrivateXMLParseJobNBDSource(nodes[i], ctxt, disk, priv->driver->xmlopt) < 0) - goto cleanup; + return -1; } } } - ret = 0; - - cleanup: - return ret; + return 0; } @@ -3527,12 +3494,9 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, { VIR_XPATH_NODE_AUTORESTORE(ctxt); g_autofree char *tmp = NULL; - int ret = -1; - if (!(ctxt->node = virXPathNode("./job[1]", ctxt))) { - ret = 0; - goto cleanup; - } + if (!(ctxt->node = virXPathNode("./job[1]", ctxt))) + return 0; if ((tmp = virXPathString("string(@type)", ctxt))) { int type; @@ -3540,7 +3504,7 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, if ((type = qemuDomainJobTypeFromString(tmp)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown job type %s"), tmp); - goto cleanup; + return -1; } VIR_FREE(tmp); priv->job.active = type; @@ -3552,7 +3516,7 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, if ((async = qemuDomainAsyncJobTypeFromString(tmp)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown async job type %s"), tmp); - goto cleanup; + return -1; } VIR_FREE(tmp); priv->job.asyncJob = async; @@ -3562,7 +3526,7 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, if (priv->job.phase < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown job phase %s"), tmp); - goto cleanup; + return -1; } VIR_FREE(tmp); } @@ -3570,19 +3534,16 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, if (virXPathULongHex("string(@flags)", ctxt, &priv->job.apiFlags) == -2) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid job flags")); - goto cleanup; + return -1; } if (qemuDomainObjPrivateXMLParseJobNBD(vm, priv, ctxt) < 0) - goto cleanup; + return -1; if (qemuMigrationParamsParse(ctxt, &priv->job.migParams) < 0) - goto cleanup; - - ret = 0; + return -1; - cleanup: - return ret; + return 0; } @@ -5664,38 +5625,37 @@ qemuDomainDefValidate(const virDomainDef *def, virQEMUDriverPtr driver = opaque; g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); g_autoptr(virQEMUCaps) qemuCaps = NULL; - int ret = -1; size_t i; if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator))) - goto cleanup; + return -1; if (def->os.type != VIR_DOMAIN_OSTYPE_HVM) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Emulator '%s' does not support os type '%s'"), def->emulator, virDomainOSTypeToString(def->os.type)); - goto cleanup; + return -1; } if (!virQEMUCapsIsArchSupported(qemuCaps, def->os.arch)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Emulator '%s' does not support arch '%s'"), def->emulator, virArchToString(def->os.arch)); - goto cleanup; + return -1; } if (!virQEMUCapsIsVirtTypeSupported(qemuCaps, def->virtType)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Emulator '%s' does not support virt type '%s'"), def->emulator, virDomainVirtTypeToString(def->virtType)); - goto cleanup; + return -1; } if (def->mem.min_guarantee) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Parameter 'min_guarantee' not supported by QEMU.")); - goto cleanup; + return -1; } /* On x86, UEFI requires ACPI */ @@ -5705,7 +5665,7 @@ qemuDomainDefValidate(const virDomainDef *def, def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_TRISTATE_SWITCH_ON) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("UEFI requires ACPI on this architecture")); - goto cleanup; + return -1; } /* On aarch64, ACPI requires UEFI */ @@ -5715,7 +5675,7 @@ qemuDomainDefValidate(const virDomainDef *def, !virDomainDefHasOldStyleUEFI(def))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("ACPI requires UEFI on this architecture")); - goto cleanup; + return -1; } if (def->os.loader && @@ -5726,7 +5686,7 @@ qemuDomainDefValidate(const virDomainDef *def, if (!qemuDomainIsQ35(def)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Secure boot is supported with q35 machine types only")); - goto cleanup; + return -1; } /* Now, technically it is possible to have secure boot on @@ -5735,7 +5695,7 @@ qemuDomainDefValidate(const virDomainDef *def, if (def->os.arch != VIR_ARCH_X86_64) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Secure boot is supported for x86_64 architecture only")); - goto cleanup; + return -1; } /* SMM will be enabled by qemuFirmwareFillDomain() if needed. */ @@ -5743,7 +5703,7 @@ qemuDomainDefValidate(const virDomainDef *def, def->features[VIR_DOMAIN_FEATURE_SMM] != VIR_TRISTATE_SWITCH_ON) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Secure boot requires SMM feature enabled")); - goto cleanup; + return -1; } } @@ -5751,7 +5711,7 @@ qemuDomainDefValidate(const virDomainDef *def, !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMGENID)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("this QEMU does not support the 'genid' capability")); - goto cleanup; + return -1; } /* Serial graphics adapter */ @@ -5759,23 +5719,23 @@ qemuDomainDefValidate(const virDomainDef *def, if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SGA)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("qemu does not support SGA")); - goto cleanup; + return -1; } if (!def->nserials) { virReportError(VIR_ERR_XML_ERROR, "%s", _("need at least one serial port to use SGA")); - goto cleanup; + return -1; } } if (qemuDomainDefValidateClockTimers(def, qemuCaps) < 0) - goto cleanup; + return -1; if (qemuDomainDefValidatePM(def, qemuCaps) < 0) - goto cleanup; + return -1; if (qemuDomainDefValidateBoot(def, qemuCaps) < 0) - goto cleanup; + return -1; /* QEMU 2.7 (detected via the availability of query-hotpluggable-cpus) * enforces stricter rules than previous versions when it comes to guest @@ -5792,7 +5752,7 @@ qemuDomainDefValidate(const virDomainDef *def, if (topologycpus != virDomainDefGetVcpusMax(def)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("CPU topology doesn't match maximum vcpu count")); - goto cleanup; + return -1; } numacpus = virDomainNumaGetCPUCountTotal(def->numa); @@ -5810,12 +5770,12 @@ qemuDomainDefValidate(const virDomainDef *def, _("vCPUs count must be a multiple of the vCPU " "hotplug granularity (%u)"), granularity); - goto cleanup; + return -1; } } if (qemuDomainValidateCpuCount(def, qemuCaps) < 0) - goto cleanup; + return -1; if (ARCH_IS_X86(def->os.arch) && virDomainDefGetVcpusMax(def) > QEMU_MAX_VCPUS_WITHOUT_EIM) { @@ -5824,14 +5784,14 @@ qemuDomainDefValidate(const virDomainDef *def, _("more than %d vCPUs are only supported on " "q35-based machine types"), QEMU_MAX_VCPUS_WITHOUT_EIM); - goto cleanup; + return -1; } if (!def->iommu || def->iommu->eim != VIR_TRISTATE_SWITCH_ON) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("more than %d vCPUs require extended interrupt " "mode enabled on the iommu device"), QEMU_MAX_VCPUS_WITHOUT_EIM); - goto cleanup; + return -1; } } @@ -5839,20 +5799,20 @@ qemuDomainDefValidate(const virDomainDef *def, def->virtType != VIR_DOMAIN_VIRT_KVM) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("cachetune is only supported for KVM domains")); - goto cleanup; + return -1; } if (qemuDomainDefValidateFeatures(def, qemuCaps) < 0) - goto cleanup; + return -1; if (qemuDomainDefValidateMemory(def, qemuCaps) < 0) - goto cleanup; + return -1; if (qemuDomainDefValidateNuma(def, qemuCaps) < 0) - goto cleanup; + return -1; if (qemuDomainDefValidateConsole(def, qemuCaps) < 0) - goto cleanup; + return -1; if (cfg->vncTLS && cfg->vncTLSx509secretUUID && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_TLS_CREDS_X509)) { @@ -5861,15 +5821,12 @@ qemuDomainDefValidate(const virDomainDef *def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("encrypted VNC TLS keys are not supported with " "this QEMU binary")); - goto cleanup; + return -1; } } } - ret = 0; - - cleanup: - return ret; + return 0; } @@ -8835,7 +8792,6 @@ qemuDomainDeviceDiskDefPostParseRestoreSecAlias(virDomainDiskDefPtr disk, bool restoreEncSecret = false; g_autofree char *authalias = NULL; g_autofree char *encalias = NULL; - int ret = -1; if (!(parseFlags & VIR_DOMAIN_DEF_PARSE_STATUS) || !qemuCaps || @@ -8875,24 +8831,21 @@ qemuDomainDeviceDiskDefPostParseRestoreSecAlias(virDomainDiskDefPtr disk, if (restoreAuthSecret) { if (!(authalias = qemuDomainGetSecretAESAlias(disk->info.alias, false))) - goto cleanup; + return -1; if (qemuStorageSourcePrivateDataAssignSecinfo(&priv->secinfo, &authalias) < 0) - goto cleanup; + return -1; } if (restoreEncSecret) { if (!(encalias = qemuDomainGetSecretAESAlias(disk->info.alias, true))) - goto cleanup; + return -1; if (qemuStorageSourcePrivateDataAssignSecinfo(&priv->encinfo, &encalias) < 0) - goto cleanup; + return -1; } - ret = 0; - - cleanup: - return ret; + return 0; } @@ -10450,10 +10403,10 @@ qemuDomainLogContextPtr qemuDomainLogContextNew(virQEMUDriverPtr driver, qemuDomainLogContextPtr ctxt = NULL; if (qemuDomainInitialize() < 0) - goto cleanup; + return NULL; if (!(ctxt = virObjectNew(qemuDomainLogContextClass))) - goto cleanup; + return NULL; VIR_DEBUG("Context new %p stdioLogD=%d", ctxt, cfg->stdioLogD); ctxt->writefd = -1; @@ -10519,13 +10472,11 @@ qemuDomainLogContextPtr qemuDomainLogContextNew(virQEMUDriverPtr driver, } } - cleanup: return ctxt; error: virObjectUnref(ctxt); - ctxt = NULL; - goto cleanup; + return NULL; } @@ -10709,7 +10660,6 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm, const char *snapshotDir) { g_autofree char *newxml = NULL; - int ret = -1; g_autofree char *snapDir = NULL; g_autofree char *snapFile = NULL; char uuidstr[VIR_UUID_STRING_BUFLEN]; @@ -10728,15 +10678,12 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm, if (virFileMakePath(snapDir) < 0) { virReportSystemError(errno, _("cannot create snapshot directory '%s'"), snapDir); - goto cleanup; + return -1; } snapFile = g_strdup_printf("%s/%s.xml", snapDir, def->parent.name); - ret = virXMLSaveFile(snapFile, NULL, "snapshot-edit", newxml); - - cleanup: - return ret; + return virXMLSaveFile(snapFile, NULL, "snapshot-edit", newxml); } @@ -10841,7 +10788,6 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver, bool metadata_only) { g_autofree char *snapFile = NULL; - int ret = -1; qemuDomainObjPrivatePtr priv; virDomainMomentObjPtr parentsnap = NULL; g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); @@ -10851,7 +10797,7 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver, /* Ignore any skipped disks */ if (qemuDomainSnapshotForEachQcow2(driver, vm, snap, "-d", true) < 0) - goto cleanup; + return -1; } else { priv = vm->privateData; qemuDomainObjEnterMonitor(driver, vm); @@ -10891,10 +10837,7 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver, virDomainMomentDropParent(snap); virDomainSnapshotObjListRemove(vm->snapshots, snap); - ret = 0; - - cleanup: - return ret; + return 0; } /* Hash iterator callback to discard multiple snapshots. */ @@ -11275,17 +11218,13 @@ qemuDomainStorageFileInit(virQEMUDriverPtr driver, g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); uid_t uid; gid_t gid; - int ret = -1; qemuDomainGetImageIds(cfg, vm, src, parent, &uid, &gid); if (virStorageFileInitAs(src, uid, gid) < 0) - goto cleanup; - - ret = 0; + return -1; - cleanup: - return ret; + return 0; } @@ -14441,7 +14380,6 @@ qemuDomainSetupDev(virQEMUDriverConfigPtr cfg, { g_autofree char *mount_options = NULL; g_autofree char *opts = NULL; - int ret = -1; VIR_DEBUG("Setting up /dev/ for domain %s", vm->def->name); @@ -14457,14 +14395,12 @@ qemuDomainSetupDev(virQEMUDriverConfigPtr cfg, opts = g_strdup_printf("mode=755,size=65536%s", mount_options); if (virFileSetupDev(data->path, opts) < 0) - goto cleanup; + return -1; if (qemuDomainPopulateDevices(cfg, vm, data) < 0) - goto cleanup; + return -1; - ret = 0; - cleanup: - return ret; + return 0; } @@ -14475,7 +14411,6 @@ qemuDomainSetupDisk(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED, { virStorageSourcePtr next; bool hasNVMe = false; - int ret = -1; for (next = disk->src; virStorageSourceIsBacking(next); next = next->backingStore) { if (next->type == VIR_STORAGE_TYPE_NVME) { @@ -14484,10 +14419,10 @@ qemuDomainSetupDisk(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED, hasNVMe = true; if (!(nvmePath = virPCIDeviceAddressGetIOMMUGroupDev(&next->nvme->pciAddr))) - goto cleanup; + return -1; if (qemuDomainCreateDevice(nvmePath, data, false) < 0) - goto cleanup; + return -1; } else { if (!next->path || !virStorageSourceIsLocalStorage(next)) { /* Not creating device. Just continue. */ @@ -14495,22 +14430,20 @@ qemuDomainSetupDisk(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED, } if (qemuDomainCreateDevice(next->path, data, false) < 0) - goto cleanup; + return -1; } } /* qemu-pr-helper might require access to /dev/mapper/control. */ if (disk->src->pr && qemuDomainCreateDevice(QEMU_DEVICE_MAPPER_CONTROL_PATH, data, true) < 0) - goto cleanup; + return -1; if (hasNVMe && qemuDomainCreateDevice(QEMU_DEV_VFIO, data, false) < 0) - goto cleanup; + return -1; - ret = 0; - cleanup: - return ret; + return 0; } @@ -14994,15 +14927,12 @@ qemuDomainCreateNamespace(virQEMUDriverPtr driver, virDomainObjPtr vm) { g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); - int ret = -1; if (virBitmapIsBitSet(cfg->namespaces, QEMU_DOMAIN_NS_MOUNT) && qemuDomainEnableNamespace(vm, QEMU_DOMAIN_NS_MOUNT) < 0) - goto cleanup; + return -1; - ret = 0; - cleanup: - return ret; + return 0; } @@ -15879,7 +15809,7 @@ qemuDomainGetStorageSourceByDevstr(const char *devstr, if (!disk) { virReportError(VIR_ERR_INVALID_ARG, _("failed to find disk '%s'"), target); - goto cleanup; + return NULL; } if (idx == 0) @@ -15887,7 +15817,6 @@ qemuDomainGetStorageSourceByDevstr(const char *devstr, else src = virStorageFileChainLookup(disk->src, NULL, NULL, idx, NULL); - cleanup: return src; } -- 2.24.1

qemuDomainChrDefDropDefaultPath() returns an int, but it's always returning 0. Callers are checking for result < 0 to run their cleanup code needlessly. Turn the function to 'void' and adjust the callers. Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> --- src/qemu/qemu_domain.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 931554eeb6..153f5897bc 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8468,20 +8468,19 @@ qemuDomainDefaultNetModel(const virDomainDef *def, * This function clears the path for migration as well, so we need to clear * the path even if we are not storing it in the XML. */ -static int +static void qemuDomainChrDefDropDefaultPath(virDomainChrDefPtr chr, virQEMUDriverPtr driver) { g_autoptr(virQEMUDriverConfig) cfg = NULL; virBuffer buf = VIR_BUFFER_INITIALIZER; g_autofree char *regexp = NULL; - int ret = -1; if (chr->deviceType != VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL || chr->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO || chr->source->type != VIR_DOMAIN_CHR_TYPE_UNIX || !chr->source->data.nix.path) { - return 0; + return; } cfg = virQEMUDriverGetConfig(driver); @@ -8494,9 +8493,6 @@ qemuDomainChrDefDropDefaultPath(virDomainChrDefPtr chr, if (virStringMatch(chr->source->data.nix.path, regexp)) VIR_FREE(chr->source->data.nix.path); - - ret = 0; - return ret; } @@ -8758,8 +8754,7 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr, /* clear auto generated unix socket path for inactive definitions */ if (parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) { - if (qemuDomainChrDefDropDefaultPath(chr, driver) < 0) - return -1; + qemuDomainChrDefDropDefaultPath(chr, driver); /* For UNIX chardev if no path is provided we generate one. * This also implies that the mode is 'bind'. */ @@ -10118,10 +10113,8 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver, } } - for (i = 0; i < def->nchannels; i++) { - if (qemuDomainChrDefDropDefaultPath(def->channels[i], driver) < 0) - goto cleanup; - } + for (i = 0; i < def->nchannels; i++) + qemuDomainChrDefDropDefaultPath(def->channels[i], driver); for (i = 0; i < def->nserials; i++) { virDomainChrDefPtr serial = def->serials[i]; -- 2.24.1

Starting on commit 1f43393283ff, qemuDomainFillDeviceIsolationGroup() returns 0 in all circunstances. Let's turn it to 'void' make it clearer that the function will not fail. This also spares a check for < 0 return in qemu_hotplug.c. The qemuDomainFillDeviceIsolationGroupIter() callback now returns 0 at all times - which is already happening anyway. Refer to 1f43393283ff commit message for more details on why the function was changed to never return an error. Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> --- src/qemu/qemu_domain_address.c | 20 ++++++++++---------- src/qemu/qemu_domain_address.h | 2 +- src/qemu/qemu_hotplug.c | 6 ++---- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 9e3bcc434d..4fb9db1e14 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1252,7 +1252,7 @@ qemuDomainFindUnusedIsolationGroup(virDomainDefPtr def) * * Return: 0 on success, <0 on failure * */ -int +void qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def, virDomainDeviceDefPtr dev) { @@ -1270,7 +1270,7 @@ qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def, /* Only PCI host devices are subject to isolation */ if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS || hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) { - return 0; + return; } hostAddr = &hostdev->source.subsys.u.pci.addr; @@ -1278,7 +1278,7 @@ qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def, /* If a non-default isolation has already been assigned to the * device, we can avoid looking up the information again */ if (info->isolationGroup > 0) - return 0; + return; /* The isolation group depends on the IOMMU group assigned by the host */ tmp = virPCIDeviceAddressGetIOMMUGroupNum(hostAddr); @@ -1288,7 +1288,7 @@ qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def, "%04x:%02x:%02x.%x, device won't be isolated", hostAddr->domain, hostAddr->bus, hostAddr->slot, hostAddr->function); - return 0; + return; } /* The isolation group for a host device is its IOMMU group, @@ -1314,13 +1314,13 @@ qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def, * require us to isolate the guest device, so we can skip them */ if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK || virDomainNetResolveActualType(iface) != VIR_DOMAIN_NET_TYPE_HOSTDEV) { - return 0; + return; } /* If a non-default isolation has already been assigned to the * device, we can avoid looking up the information again */ if (info->isolationGroup > 0) - return 0; + return; /* Obtain a synthetic isolation group for the device, since at this * point in time we don't have access to the IOMMU group of the host @@ -1332,7 +1332,7 @@ qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def, "configured to use hostdev-backed network '%s', " "device won't be isolated", iface->data.network.name); - return 0; + return; } info->isolationGroup = tmp; @@ -1341,8 +1341,6 @@ qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def, "hostdev-backed network '%s' is %u", iface->data.network.name, info->isolationGroup); } - - return 0; } @@ -1364,7 +1362,9 @@ qemuDomainFillDeviceIsolationGroupIter(virDomainDefPtr def, virDomainDeviceInfoPtr info G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED) { - return qemuDomainFillDeviceIsolationGroup(def, dev); + qemuDomainFillDeviceIsolationGroup(def, dev); + + return 0; } diff --git a/src/qemu/qemu_domain_address.h b/src/qemu/qemu_domain_address.h index bf04e6bfdb..7ef3308246 100644 --- a/src/qemu/qemu_domain_address.h +++ b/src/qemu/qemu_domain_address.h @@ -49,7 +49,7 @@ int qemuDomainEnsurePCIAddress(virDomainObjPtr obj, virQEMUDriverPtr driver) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); -int qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def, +void qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def, virDomainDeviceDefPtr dev) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 31d455505b..cb5d587940 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1598,11 +1598,9 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, if (qemuAssignDeviceHostdevAlias(vm->def, &info->alias, -1) < 0) goto error; - if (qemuDomainIsPSeries(vm->def)) { + if (qemuDomainIsPSeries(vm->def)) /* Isolation groups are only relevant for pSeries guests */ - if (qemuDomainFillDeviceIsolationGroup(vm->def, &dev) < 0) - goto error; - } + qemuDomainFillDeviceIsolationGroup(vm->def, &dev); if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) goto error; -- 2.24.1

On 1/9/20 3:33 PM, Daniel Henrique Barboza wrote:
Starting on commit 1f43393283ff, qemuDomainFillDeviceIsolationGroup() returns 0 in all circunstances. Let's turn it to 'void' make it clearer that the function will not fail. This also spares a check for < 0 return in qemu_hotplug.c. The qemuDomainFillDeviceIsolationGroupIter() callback now returns 0 at all times - which is already happening anyway.
Refer to 1f43393283ff commit message for more details on why the function was changed to never return an error.
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> --- src/qemu/qemu_domain_address.c | 20 ++++++++++---------- src/qemu/qemu_domain_address.h | 2 +- src/qemu/qemu_hotplug.c | 6 ++---- 3 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 9e3bcc434d..4fb9db1e14 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1252,7 +1252,7 @@ qemuDomainFindUnusedIsolationGroup(virDomainDefPtr def) * * Return: 0 on success, <0 on failure * */
I forgot to update the return value to 'void' in the function docs up here ^ I can fix it in a next spin together with other review corrections from the rest of the series. DHB
-int +void qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def, virDomainDeviceDefPtr dev) { @@ -1270,7 +1270,7 @@ qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def, /* Only PCI host devices are subject to isolation */ if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS || hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) { - return 0; + return; }
hostAddr = &hostdev->source.subsys.u.pci.addr; @@ -1278,7 +1278,7 @@ qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def, /* If a non-default isolation has already been assigned to the * device, we can avoid looking up the information again */ if (info->isolationGroup > 0) - return 0; + return;
/* The isolation group depends on the IOMMU group assigned by the host */ tmp = virPCIDeviceAddressGetIOMMUGroupNum(hostAddr); @@ -1288,7 +1288,7 @@ qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def, "%04x:%02x:%02x.%x, device won't be isolated", hostAddr->domain, hostAddr->bus, hostAddr->slot, hostAddr->function); - return 0; + return; }
/* The isolation group for a host device is its IOMMU group, @@ -1314,13 +1314,13 @@ qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def, * require us to isolate the guest device, so we can skip them */ if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK || virDomainNetResolveActualType(iface) != VIR_DOMAIN_NET_TYPE_HOSTDEV) { - return 0; + return; }
/* If a non-default isolation has already been assigned to the * device, we can avoid looking up the information again */ if (info->isolationGroup > 0) - return 0; + return;
/* Obtain a synthetic isolation group for the device, since at this * point in time we don't have access to the IOMMU group of the host @@ -1332,7 +1332,7 @@ qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def, "configured to use hostdev-backed network '%s', " "device won't be isolated", iface->data.network.name); - return 0; + return; }
info->isolationGroup = tmp; @@ -1341,8 +1341,6 @@ qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def, "hostdev-backed network '%s' is %u", iface->data.network.name, info->isolationGroup); } - - return 0; }
@@ -1364,7 +1362,9 @@ qemuDomainFillDeviceIsolationGroupIter(virDomainDefPtr def, virDomainDeviceInfoPtr info G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED) { - return qemuDomainFillDeviceIsolationGroup(def, dev); + qemuDomainFillDeviceIsolationGroup(def, dev); + + return 0; }
diff --git a/src/qemu/qemu_domain_address.h b/src/qemu/qemu_domain_address.h index bf04e6bfdb..7ef3308246 100644 --- a/src/qemu/qemu_domain_address.h +++ b/src/qemu/qemu_domain_address.h @@ -49,7 +49,7 @@ int qemuDomainEnsurePCIAddress(virDomainObjPtr obj, virQEMUDriverPtr driver) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
-int qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def, +void qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def, virDomainDeviceDefPtr dev) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 31d455505b..cb5d587940 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1598,11 +1598,9 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, if (qemuAssignDeviceHostdevAlias(vm->def, &info->alias, -1) < 0) goto error;
- if (qemuDomainIsPSeries(vm->def)) { + if (qemuDomainIsPSeries(vm->def)) /* Isolation groups are only relevant for pSeries guests */ - if (qemuDomainFillDeviceIsolationGroup(vm->def, &dev) < 0) - goto error; - } + qemuDomainFillDeviceIsolationGroup(vm->def, &dev);
if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) goto error;

Ping On 1/9/20 3:33 PM, Daniel Henrique Barboza wrote:
Hi,
These are a few cleanups in some files that I'll end up messing with in a future series (which isn't Glibfied ATM). Figured it's best to clean them up now instead of adding more non-Glibfied code on top.
Patches 7 and 8 are stuff that I noted some time ago and figured it might be worth sending as well.
Daniel Henrique Barboza (8): conf/domain_addr.c: use g_autofree in strings conf/domain_addr.c: remove unneeded 'cleanup' labels qemu_domain.c: remove redundant virObjectUnref() qemu_domain.c: use g_autofree when possible qemu_domain.c: use g_autoptr when possible qemu_domain.c: removing unneeded cleanup labels qemu_domain.c: turn qemuDomainChrDefDropDefaultPath to void qemu_domain_address.c: turn qemuDomainFillDeviceIsolationGroup to void
src/conf/domain_addr.c | 124 +++----- src/qemu/qemu_domain.c | 511 +++++++++++---------------------- src/qemu/qemu_domain_address.c | 20 +- src/qemu/qemu_domain_address.h | 2 +- src/qemu/qemu_hotplug.c | 6 +- 5 files changed, 227 insertions(+), 436 deletions(-)

On 1/9/20 7:33 PM, Daniel Henrique Barboza wrote:
Hi,
These are a few cleanups in some files that I'll end up messing with in a future series (which isn't Glibfied ATM). Figured it's best to clean them up now instead of adding more non-Glibfied code on top.
Patches 7 and 8 are stuff that I noted some time ago and figured it might be worth sending as well.
Daniel Henrique Barboza (8): conf/domain_addr.c: use g_autofree in strings conf/domain_addr.c: remove unneeded 'cleanup' labels qemu_domain.c: remove redundant virObjectUnref() qemu_domain.c: use g_autofree when possible qemu_domain.c: use g_autoptr when possible qemu_domain.c: removing unneeded cleanup labels qemu_domain.c: turn qemuDomainChrDefDropDefaultPath to void qemu_domain_address.c: turn qemuDomainFillDeviceIsolationGroup to void
src/conf/domain_addr.c | 124 +++----- src/qemu/qemu_domain.c | 511 +++++++++++---------------------- src/qemu/qemu_domain_address.c | 20 +- src/qemu/qemu_domain_address.h | 2 +- src/qemu/qemu_hotplug.c | 6 +- 5 files changed, 227 insertions(+), 436 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> and pushed. Sorry for the delay. Michal
participants (2)
-
Daniel Henrique Barboza
-
Michal Privoznik