Blob Blame History Raw
From 9eba70b364bae88085b524d528ac71cb4337e57c Mon Sep 17 00:00:00 2001
Message-Id: <9eba70b364bae88085b524d528ac71cb4337e57c@dist-git>
From: Laine Stump <laine@laine.org>
Date: Thu, 11 Apr 2019 15:14:30 -0400
Subject: [PATCH] qemu_hotplug: remove unnecessary check for valid PCI address
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When support for hotplug/unplug of SCSI controllers was added way back
in December 2009 (commit da9d937b), unplug was handled by calling the
now-extinct function qemuMonitorRemovePCIDevice(), which required a
PCI address as an argument. At the same time, the idea of every device
in the config having a PCI address apparently was not yet fully
implemented, because the author of the patch including a check for a
valid PCI address in the device object.

These days, all PCI devices are guaranteed to have a valid PCI
address. But more important than that, we no longer detach devices by
PCI address, but instead use qemuDomainDeleteDevice(), which
identifies the device by its alias. So checking for a valid PCI
address is just pointless extra code that obscures the high level of
similarity between all the individual qemuDomainDetach*Device()
functions.

Signed-off-by: Laine Stump <laine@laine.org>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 155064e0ed53b13701ff176c3f92605b1a850a9d)

Partially-Resolves: https://bugzilla.redhat.com/1658198
Signed-off-by: Laine Stump <laine@redhat.com>
Signed-off-by: Laine Stump <laine@laine.org>
Message-Id: <20190411191453.24055-19-laine@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_hotplug.c | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index ffb2e258b5..39e40e2740 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -4915,22 +4915,6 @@ int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver,
 
     detach = vm->def->controllers[idx];
 
-    if (detach->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
-        detach->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW &&
-        detach->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) {
-        virReportError(VIR_ERR_OPERATION_FAILED,
-                       _("device with '%s' address cannot be detached"),
-                       virDomainDeviceAddressTypeToString(detach->info.type));
-        goto cleanup;
-    }
-
-    if (!virDomainDeviceAddressIsValid(&detach->info, detach->info.type)) {
-        virReportError(VIR_ERR_OPERATION_FAILED,
-                       _("device with invalid '%s' address cannot be detached"),
-                       virDomainDeviceAddressTypeToString(detach->info.type));
-        goto cleanup;
-    }
-
     if (qemuIsMultiFunctionDevice(vm->def, &detach->info)) {
         virReportError(VIR_ERR_OPERATION_FAILED,
                        _("cannot hot unplug multifunction PCI device: %s"),
-- 
2.21.0