Blame SOURCES/libvirt-qemu_hotplug-pull-qemuDomainUpdateDeviceList-out-of-qemuDomainDetachDeviceLive.patch

99cbc7
From 6cd6434ab5772a1b42cbacc02b894e51bc26056c Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <6cd6434ab5772a1b42cbacc02b894e51bc26056c@dist-git>
99cbc7
From: Laine Stump <laine@laine.org>
99cbc7
Date: Thu, 11 Apr 2019 15:14:42 -0400
99cbc7
Subject: [PATCH] qemu_hotplug: pull qemuDomainUpdateDeviceList out of
99cbc7
 qemuDomainDetachDeviceLive
99cbc7
99cbc7
qemuDomainDetachDeviceLive() is called from two places in
99cbc7
qemu_driver.c, and qemuDomainUpdateDeviceList() is called from the
99cbc7
end of qemuDomainDetachDeviceLive(), which is now in qemu_hotplug.c
99cbc7
99cbc7
This patch replaces the single call to qemuDomainUpdateDeviceList()
99cbc7
with two calls to it immediately after return from
99cbc7
qemuDomainDetachDeviceLive(). This is only done if the return from
99cbc7
that function is exactly 0, in order to exactly preserve previous
99cbc7
behavior.
99cbc7
99cbc7
Removing that one call from qemuDomainDetachDeviceList() will permit
99cbc7
us to call it from the test driver hotplug test, replacing the
99cbc7
separate calls to qemuDomainDetachDeviceDiskLive(),
99cbc7
qemuDomainDetachChrDevice(), qemuDomainDetachShmemDevice() and
99cbc7
qemuDomainDetachWatchdog(). We want to do this so that part of the
99cbc7
common functionality of those three functions (and the rest of the
99cbc7
device-specific Detach functions) can be pulled up into
99cbc7
qemuDomainDetachDeviceLive() without breaking the test. (This is done
99cbc7
in the next patch).
99cbc7
99cbc7
NB: Almost certainly this is "not the best place" to call
99cbc7
qemuDomainUpdateDeviceList() (actually, it is provably the *wrong*
99cbc7
place), since it's purpose is to retrieve an "up to date" list of
99cbc7
aliases for all devices from qemu, and if the guest OS hasn't yet
99cbc7
processed the detach request, the now-being-removed device may still
99cbc7
be on that list. It would arguably be better to instead call
99cbc7
qemuDomainUpdateDevicesList() later during the response to the
99cbc7
DEVICE_DELETED event for the device. But removing the call from the
99cbc7
current point in the detach could have some unforeseen ill effect due
99cbc7
to changed timing, so the change to move it into
99cbc7
qemuDomainRemove*Device() will be done in a separate patch (in order
99cbc7
to make it easily revertible in case it causes a regression).
99cbc7
99cbc7
Signed-off-by: Laine Stump <laine@laine.org>
99cbc7
ACKed-by: Peter Krempa <pkrempa@redhat.com>
99cbc7
(cherry picked from commit b20494186578fb779547b714fff77f07e2ca03ea)
99cbc7
99cbc7
Partially-Resolves: https://bugzilla.redhat.com/1658198
99cbc7
Signed-off-by: Laine Stump <laine@redhat.com>
99cbc7
Signed-off-by: Laine Stump <laine@laine.org>
99cbc7
Message-Id: <20190411191453.24055-31-laine@redhat.com>
99cbc7
Acked-by: Michal Privoznik <mprivozn@redhat.com>
99cbc7
---
99cbc7
 src/qemu/qemu_driver.c  | 14 ++++++++++++--
99cbc7
 src/qemu/qemu_hotplug.c |  3 ---
99cbc7
 2 files changed, 12 insertions(+), 5 deletions(-)
99cbc7
99cbc7
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
99cbc7
index 4cdc68a83a..e11f57a56a 100644
99cbc7
--- a/src/qemu/qemu_driver.c
99cbc7
+++ b/src/qemu/qemu_driver.c
99cbc7
@@ -8681,8 +8681,14 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr driver,
99cbc7
     }
99cbc7
 
99cbc7
     if (flags & VIR_DOMAIN_AFFECT_LIVE) {
99cbc7
-        if (qemuDomainDetachDeviceLive(vm, dev_copy, driver, false) < 0)
99cbc7
+        int rc;
99cbc7
+
99cbc7
+        if ((rc = qemuDomainDetachDeviceLive(vm, dev_copy, driver, false)) < 0)
99cbc7
             goto cleanup;
99cbc7
+
99cbc7
+        if (rc == 0 && qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
99cbc7
+            goto cleanup;
99cbc7
+
99cbc7
         /*
99cbc7
          * update domain status forcibly because the domain status may be
99cbc7
          * changed even if we failed to attach the device. For example,
99cbc7
@@ -8759,11 +8765,15 @@ qemuDomainDetachDeviceAliasLiveAndConfig(virQEMUDriverPtr driver,
99cbc7
 
99cbc7
     if (def) {
99cbc7
         virDomainDeviceDef dev;
99cbc7
+        int rc;
99cbc7
 
99cbc7
         if (virDomainDefFindDevice(def, alias, &dev, true) < 0)
99cbc7
             goto cleanup;
99cbc7
 
99cbc7
-        if (qemuDomainDetachDeviceLive(vm, &dev, driver, true) < 0)
99cbc7
+        if ((rc = qemuDomainDetachDeviceLive(vm, &dev, driver, true)) < 0)
99cbc7
+            goto cleanup;
99cbc7
+
99cbc7
+        if (rc == 0 && qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
99cbc7
             goto cleanup;
99cbc7
     }
99cbc7
 
99cbc7
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
99cbc7
index 1b15116a9f..fd78f4ca01 100644
99cbc7
--- a/src/qemu/qemu_hotplug.c
99cbc7
+++ b/src/qemu/qemu_hotplug.c
99cbc7
@@ -5714,9 +5714,6 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm,
99cbc7
         break;
99cbc7
     }
99cbc7
 
99cbc7
-    if (ret == 0)
99cbc7
-        ret = qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE);
99cbc7
-
99cbc7
     return ret;
99cbc7
 }
99cbc7
 
99cbc7
-- 
99cbc7
2.21.0
99cbc7