Blame SOURCES/libvirt-qemu_hotplug-remove-erroneous-call-to-qemuDomainDetachExtensionDevice.patch

c480ed
From 77404a4f0ff85fbc0a2c24afc736ffbd8b82ef4d Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <77404a4f0ff85fbc0a2c24afc736ffbd8b82ef4d@dist-git>
c480ed
From: Laine Stump <laine@laine.org>
c480ed
Date: Mon, 8 Apr 2019 10:57:31 +0200
c480ed
Subject: [PATCH] qemu_hotplug: remove erroneous call to
c480ed
 qemuDomainDetachExtensionDevice()
c480ed
MIME-Version: 1.0
c480ed
Content-Type: text/plain; charset=UTF-8
c480ed
Content-Transfer-Encoding: 8bit
c480ed
c480ed
qemuDomainDetachControllerDevice() calls
c480ed
qemuDomainDetachExtensionDevice() when the controller type is
c480ed
PCI. This is incorrect in multiple ways:
c480ed
c480ed
* Any code that tears down a device should be in the
c480ed
  qemuDomainRemove*Device() function (which is called after libvirt
c480ed
  gets a DEVICE_DELETED event from qemu indicating that the guest is
c480ed
  finished with the device on its end. The qemuDomainDetach*Device()
c480ed
  functions should only contain code that ensures the requested
c480ed
  operation is valid, and sends the command to qemu to initiate the
c480ed
  unplug.
c480ed
c480ed
* qemuDomainDetachExtensionDevice() is a function that applies to
c480ed
  devices that plug into a PCI slot, *not* necessarily PCI controllers
c480ed
  (which is what's being checked in the offending code). The proper
c480ed
  way to check for this would be to see if the DeviceInfo for the
c480ed
  controller device had a PCI address, not to check if the controller
c480ed
  is a PCI controller (the code being removed was doing the latter).
c480ed
c480ed
* According to commit 1d1e264f1 that added this code (and other
c480ed
  support for hotplugging zPCI devices on s390), it's not necessary to
c480ed
  explicitly detach the zPCI device when unplugging a PCI device. To
c480ed
  quote:
c480ed
c480ed
       There's no need to implement hot unplug for zPCI as QEMU
c480ed
       implements an unplug callback which will unplug both PCI and
c480ed
       zPCI device in a cascaded way.
c480ed
c480ed
  and the evidence bears this out - all the other uses of
c480ed
  qemuDomainDetachExtensionDevice() (except one, which I believe is
c480ed
  also in error, and is being removed in a separate patch) are only to
c480ed
  remove the zPCI extension device in cases where it was successfully
c480ed
  added, but there was some other failure later in the hotplug process
c480ed
  (so there was no regular PCI device to remove and trigger removal of
c480ed
  the zPCI extension device).
c480ed
c480ed
* PCI controllers are not hot pluggable, so this is dead code
c480ed
  anyway. (The only controllers that can currently be
c480ed
  hotplugged/unplugged are SCSI controllers).
c480ed
c480ed
Signed-off-by: Laine Stump <laine@laine.org>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
c480ed
c480ed
(cherry picked from commit 143291698358f5a1e693c768893d89038420af25)
c480ed
c480ed
https://bugzilla.redhat.com/show_bug.cgi?id=1508149
c480ed
c480ed
Conflicts:
c480ed
c480ed
  * src/qemu/qemu_hotplug.c
c480ed
    + the code dealing with entering and exiting the monitor is
c480ed
      quite a bit different because we don't have backported
c480ed
      qemuDomainDeleteDevice() downstream
c480ed
      - missing 4cd13478ac33
c480ed
c480ed
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
c480ed
Message-Id: <20190408085732.28684-15-abologna@redhat.com>
c480ed
Reviewed-by: Laine Stump <laine@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 src/qemu/qemu_hotplug.c | 6 ------
c480ed
 1 file changed, 6 deletions(-)
c480ed
c480ed
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
c480ed
index 8394efa739..f16213c6e0 100644
c480ed
--- a/src/qemu/qemu_hotplug.c
c480ed
+++ b/src/qemu/qemu_hotplug.c
c480ed
@@ -5077,17 +5077,11 @@ int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver,
c480ed
         qemuDomainMarkDeviceForRemoval(vm, &detach->info);
c480ed
 
c480ed
     qemuDomainObjEnterMonitor(driver, vm);
c480ed
-    if (detach->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
c480ed
-        qemuDomainDetachExtensionDevice(priv->mon, &detach->info)) {
c480ed
-        goto exit_monitor;
c480ed
-    }
c480ed
-
c480ed
     if (qemuMonitorDelDevice(priv->mon, detach->info.alias)) {
c480ed
         ignore_value(qemuDomainObjExitMonitor(driver, vm));
c480ed
         goto cleanup;
c480ed
     }
c480ed
 
c480ed
- exit_monitor:
c480ed
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
c480ed
         goto cleanup;
c480ed
 
c480ed
-- 
c480ed
2.22.0
c480ed