[PATCH 12/16] qemuDomainAttachChrDeviceAssignAddr: Simplify return value handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rather than returning a different error code if the device address needs
to be released pass in the 'need_release' flag via a pointer.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_hotplug.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index d44523fe7e..5e44210aff 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2125,13 +2125,12 @@ qemuDomainChrRemove(virDomainDef *vmdef,
     return ret;
 }

-/* Returns  1 if the address will need to be released later,
- *         -1 on error
- *          0 otherwise
- */
+
+
 static int
 qemuDomainAttachChrDeviceAssignAddr(virDomainObj *vm,
-                                    virDomainChrDef *chr)
+                                    virDomainChrDef *chr,
+                                    bool *need_release)
 {
     virDomainDef *def = vm->def;
     qemuDomainObjPrivate *priv = vm->privateData;
@@ -2147,13 +2146,16 @@ qemuDomainAttachChrDeviceAssignAddr(virDomainObj *vm,
                chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI) {
         if (qemuDomainEnsurePCIAddress(vm, &dev) < 0)
             return -1;
-        return 1;

+        *need_release = true;
+        return 0;
     } else if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
                chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB) {
         if (virDomainUSBAddressEnsure(priv->usbaddrs, &chr->info) < 0)
             return -1;
-        return 1;
+
+        *need_release = true;
+        return 0;

     } else if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
                chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) {
@@ -2176,7 +2178,7 @@ int qemuDomainAttachChrDevice(virQEMUDriver *driver,
                               virDomainObj *vm,
                               virDomainChrDef *chr)
 {
-    int ret = -1, rc;
+    int ret = -1;
     qemuDomainObjPrivate *priv = vm->privateData;
     virErrorPtr orig_err;
     virDomainDef *vmdef = vm->def;
@@ -2203,10 +2205,8 @@ int qemuDomainAttachChrDevice(virQEMUDriver *driver,
     if (qemuAssignDeviceChrAlias(vmdef, chr, -1) < 0)
         goto cleanup;

-    if ((rc = qemuDomainAttachChrDeviceAssignAddr(vm, chr)) < 0)
+    if (qemuDomainAttachChrDeviceAssignAddr(vm, chr, &need_release) < 0)
         goto cleanup;
-    if (rc == 1)
-        need_release = true;

     if (qemuDomainNamespaceSetupChardev(vm, chr, &teardowndevice) < 0)
         goto cleanup;
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux