[PATCH v3 09/21] qemu: hotplug: move assignment outside qemuDomainAttachHostPCIDevice

Daniel Henrique Barboza danielhb413 at gmail.com
Wed May 20 21:11:31 UTC 2020


From: Shivaprasad G Bhat <sbhat at linux.vnet.ibm.com>

No functional change.

Signed-off-by: Shivaprasad G Bhat <sbhat at linux.vnet.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
---
 src/qemu/qemu_hotplug.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index d88a0922d4..6991d7988c 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1605,12 +1605,9 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
                               virDomainHostdevDefPtr hostdev)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
-    virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_HOSTDEV,
-                               { .hostdev = hostdev } };
     virDomainDeviceInfoPtr info = hostdev->info;
     int ret;
     g_autofree char *devstr = NULL;
-    bool releaseaddr = false;
     bool teardowncgroup = false;
     bool teardownlabel = false;
     bool teardowndevice = false;
@@ -1643,14 +1640,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
     if (qemuAssignDeviceHostdevAlias(vm->def, &info->alias, -1) < 0)
         goto error;
 
-    if (qemuDomainIsPSeries(vm->def))
-        /* Isolation groups are only relevant for pSeries guests */
-        qemuDomainFillDeviceIsolationGroup(vm->def, &dev);
-
-    if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0)
-        goto error;
-    releaseaddr = true;
-
     if (!virDomainObjIsActive(vm)) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("guest unexpectedly quit during hotplug"));
@@ -1692,9 +1681,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
     if (teardownmemlock && qemuDomainAdjustMaxMemLock(vm, false) < 0)
         VIR_WARN("Unable to reset maximum locked memory on hotplug fail");
 
-    if (releaseaddr)
-        qemuDomainReleaseDeviceAddress(vm, info);
-
     return -1;
 }
 
@@ -2934,6 +2920,8 @@ qemuDomainAttachHostDevice(virQEMUDriverPtr driver,
                            virDomainHostdevDefPtr hostdev)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
+    virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_HOSTDEV,
+                               { .hostdev = hostdev } };
 
     if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -2948,7 +2936,15 @@ qemuDomainAttachHostDevice(virQEMUDriverPtr driver,
                                                  hostdev, priv->qemuCaps) < 0)
             return -1;
 
+        if (qemuDomainIsPSeries(vm->def))
+            /* Isolation groups are only relevant for pSeries guests */
+            qemuDomainFillDeviceIsolationGroup(vm->def, &dev);
+
+        if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0)
+            return -1;
+
         if (qemuDomainAttachHostPCIDevice(driver, vm, hostdev) < 0) {
+            qemuDomainReleaseDeviceAddress(vm, hostdev->info);
             qemuHostdevReAttachPCIDevices(driver, vm->def->name, &hostdev, 1);
             return -1;
         }
-- 
2.26.2




More information about the libvir-list mailing list