render / rpms / libvirt

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