|
|
0a7476 |
From ff34df48cc7f197877034c319409c11f4a3b794e Mon Sep 17 00:00:00 2001
|
|
|
0a7476 |
Message-Id: <ff34df48cc7f197877034c319409c11f4a3b794e@dist-git>
|
|
|
0a7476 |
From: Laine Stump <laine@laine.org>
|
|
|
0a7476 |
Date: Thu, 11 Apr 2019 15:14:36 -0400
|
|
|
0a7476 |
Subject: [PATCH] qemu_hotplug: merge qemuDomainDetachThisHostDevice into
|
|
|
0a7476 |
qemuDomainDetachHostDevice
|
|
|
0a7476 |
|
|
|
0a7476 |
It's now only called from one place, and combining the two functions
|
|
|
0a7476 |
highlights the similarity with Detach functions for other device
|
|
|
0a7476 |
types.
|
|
|
0a7476 |
|
|
|
0a7476 |
Signed-off-by: Laine Stump <laine@laine.org>
|
|
|
0a7476 |
ACKed-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
0a7476 |
(cherry picked from commit 6be2414820a23663f9e6b7b4ed510ebbf3126307)
|
|
|
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-25-laine@redhat.com>
|
|
|
0a7476 |
Acked-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
0a7476 |
---
|
|
|
0a7476 |
src/qemu/qemu_hotplug.c | 101 +++++++++++++++-------------------------
|
|
|
0a7476 |
1 file changed, 38 insertions(+), 63 deletions(-)
|
|
|
0a7476 |
|
|
|
0a7476 |
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
|
|
|
0a7476 |
index ac395b9177..8a3946a6e2 100644
|
|
|
0a7476 |
--- a/src/qemu/qemu_hotplug.c
|
|
|
0a7476 |
+++ b/src/qemu/qemu_hotplug.c
|
|
|
0a7476 |
@@ -4938,68 +4938,6 @@ int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver,
|
|
|
0a7476 |
}
|
|
|
0a7476 |
|
|
|
0a7476 |
|
|
|
0a7476 |
-static int
|
|
|
0a7476 |
-qemuDomainDetachThisHostDevice(virQEMUDriverPtr driver,
|
|
|
0a7476 |
- virDomainObjPtr vm,
|
|
|
0a7476 |
- virDomainHostdevDefPtr detach,
|
|
|
0a7476 |
- bool async)
|
|
|
0a7476 |
-{
|
|
|
0a7476 |
- int ret = -1;
|
|
|
0a7476 |
-
|
|
|
0a7476 |
- if (qemuIsMultiFunctionDevice(vm->def, detach->info)) {
|
|
|
0a7476 |
- virReportError(VIR_ERR_OPERATION_FAILED,
|
|
|
0a7476 |
- _("cannot hot unplug multifunction PCI device with guest address: "
|
|
|
0a7476 |
- "%.4x:%.2x:%.2x.%.1x"),
|
|
|
0a7476 |
- detach->info->addr.pci.domain, detach->info->addr.pci.bus,
|
|
|
0a7476 |
- detach->info->addr.pci.slot, detach->info->addr.pci.function);
|
|
|
0a7476 |
- return -1;
|
|
|
0a7476 |
- }
|
|
|
0a7476 |
-
|
|
|
0a7476 |
- if (!detach->info->alias) {
|
|
|
0a7476 |
- virReportError(VIR_ERR_OPERATION_FAILED,
|
|
|
0a7476 |
- "%s", _("device cannot be detached without a device alias"));
|
|
|
0a7476 |
- return -1;
|
|
|
0a7476 |
- }
|
|
|
0a7476 |
-
|
|
|
0a7476 |
- switch (detach->source.subsys.type) {
|
|
|
0a7476 |
- case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
|
|
|
0a7476 |
- case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
|
|
|
0a7476 |
- case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
|
|
|
0a7476 |
- case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
|
|
|
0a7476 |
- case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV:
|
|
|
0a7476 |
- /* we support detach of all these types of hostdev */
|
|
|
0a7476 |
- break;
|
|
|
0a7476 |
-
|
|
|
0a7476 |
- default:
|
|
|
0a7476 |
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
0a7476 |
- _("hot unplug is not supported for hostdev subsys type '%s'"),
|
|
|
0a7476 |
- virDomainHostdevSubsysTypeToString(detach->source.subsys.type));
|
|
|
0a7476 |
- return -1;
|
|
|
0a7476 |
- }
|
|
|
0a7476 |
-
|
|
|
0a7476 |
- if (!async)
|
|
|
0a7476 |
- qemuDomainMarkDeviceForRemoval(vm, detach->info);
|
|
|
0a7476 |
-
|
|
|
0a7476 |
- if (qemuDomainDeleteDevice(vm, detach->info->alias) < 0) {
|
|
|
0a7476 |
- if (virDomainObjIsActive(vm))
|
|
|
0a7476 |
- virDomainAuditHostdev(vm, detach, "detach", false);
|
|
|
0a7476 |
- goto cleanup;
|
|
|
0a7476 |
- }
|
|
|
0a7476 |
-
|
|
|
0a7476 |
- if (async) {
|
|
|
0a7476 |
- ret = 0;
|
|
|
0a7476 |
- } else {
|
|
|
0a7476 |
- if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
|
|
|
0a7476 |
- ret = qemuDomainRemoveHostDevice(driver, vm, detach);
|
|
|
0a7476 |
- }
|
|
|
0a7476 |
-
|
|
|
0a7476 |
- cleanup:
|
|
|
0a7476 |
- if (!async)
|
|
|
0a7476 |
- qemuDomainResetDeviceRemoval(vm);
|
|
|
0a7476 |
-
|
|
|
0a7476 |
- return ret;
|
|
|
0a7476 |
-}
|
|
|
0a7476 |
-
|
|
|
0a7476 |
/* search for a hostdev matching dev and detach it */
|
|
|
0a7476 |
int qemuDomainDetachHostDevice(virQEMUDriverPtr driver,
|
|
|
0a7476 |
virDomainObjPtr vm,
|
|
|
0a7476 |
@@ -5014,6 +4952,7 @@ int qemuDomainDetachHostDevice(virQEMUDriverPtr driver,
|
|
|
0a7476 |
virDomainHostdevSubsysMediatedDevPtr mdevsrc = &subsys->u.mdev;
|
|
|
0a7476 |
virDomainHostdevDefPtr detach = NULL;
|
|
|
0a7476 |
int idx;
|
|
|
0a7476 |
+ int ret = -1;
|
|
|
0a7476 |
|
|
|
0a7476 |
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
|
|
|
0a7476 |
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
0a7476 |
@@ -5075,7 +5014,43 @@ int qemuDomainDetachHostDevice(virQEMUDriverPtr driver,
|
|
|
0a7476 |
return -1;
|
|
|
0a7476 |
}
|
|
|
0a7476 |
|
|
|
0a7476 |
- return qemuDomainDetachThisHostDevice(driver, vm, detach, async);
|
|
|
0a7476 |
+ if (qemuIsMultiFunctionDevice(vm->def, detach->info)) {
|
|
|
0a7476 |
+ virReportError(VIR_ERR_OPERATION_FAILED,
|
|
|
0a7476 |
+ _("cannot hot unplug multifunction PCI device with guest address: "
|
|
|
0a7476 |
+ "%.4x:%.2x:%.2x.%.1x"),
|
|
|
0a7476 |
+ detach->info->addr.pci.domain, detach->info->addr.pci.bus,
|
|
|
0a7476 |
+ detach->info->addr.pci.slot, detach->info->addr.pci.function);
|
|
|
0a7476 |
+ return -1;
|
|
|
0a7476 |
+ }
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ if (!detach->info->alias) {
|
|
|
0a7476 |
+ virReportError(VIR_ERR_OPERATION_FAILED,
|
|
|
0a7476 |
+ "%s", _("device cannot be detached without a device alias"));
|
|
|
0a7476 |
+ return -1;
|
|
|
0a7476 |
+ }
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ if (!async)
|
|
|
0a7476 |
+ qemuDomainMarkDeviceForRemoval(vm, detach->info);
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ if (qemuDomainDeleteDevice(vm, detach->info->alias) < 0) {
|
|
|
0a7476 |
+ if (virDomainObjIsActive(vm))
|
|
|
0a7476 |
+ virDomainAuditHostdev(vm, detach, "detach", false);
|
|
|
0a7476 |
+ goto cleanup;
|
|
|
0a7476 |
+ }
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ if (async) {
|
|
|
0a7476 |
+ ret = 0;
|
|
|
0a7476 |
+ } else {
|
|
|
0a7476 |
+ if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
|
|
|
0a7476 |
+ ret = qemuDomainRemoveHostDevice(driver, vm, detach);
|
|
|
0a7476 |
+ }
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ cleanup:
|
|
|
0a7476 |
+ if (!async)
|
|
|
0a7476 |
+ qemuDomainResetDeviceRemoval(vm);
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ return ret;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
}
|
|
|
0a7476 |
|
|
|
0a7476 |
|
|
|
0a7476 |
--
|
|
|
0a7476 |
2.21.0
|
|
|
0a7476 |
|