|
|
0a7476 |
From a0b96a992d89ee5243ad56974979a0ccc0df788a Mon Sep 17 00:00:00 2001
|
|
|
0a7476 |
Message-Id: <a0b96a992d89ee5243ad56974979a0ccc0df788a@dist-git>
|
|
|
0a7476 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
0a7476 |
Date: Thu, 11 Apr 2019 15:14:29 -0400
|
|
|
0a7476 |
Subject: [PATCH] qemu: hotplug: Merge virtio and non-virtio disk unplug code
|
|
|
0a7476 |
MIME-Version: 1.0
|
|
|
0a7476 |
Content-Type: text/plain; charset=UTF-8
|
|
|
0a7476 |
Content-Transfer-Encoding: 8bit
|
|
|
0a7476 |
|
|
|
0a7476 |
The functions do basically exactly the same thing modulo few checks.
|
|
|
0a7476 |
In case of virtio disks we check that the device is not multifunction as
|
|
|
0a7476 |
that can't be unplugged at once. In case of USB and SCSI disks we
|
|
|
0a7476 |
checked that no active block job is running.
|
|
|
0a7476 |
|
|
|
0a7476 |
The check for running blockjobs should have also been done for virtio
|
|
|
0a7476 |
disks. By moving the multifunction check into the common function we fix
|
|
|
0a7476 |
this case and also simplify the code.
|
|
|
0a7476 |
|
|
|
0a7476 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
0a7476 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
0a7476 |
(cherry picked from commit 0b7d544c8842841b27de0d88234148794ce4545e)
|
|
|
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-18-laine@redhat.com>
|
|
|
0a7476 |
Acked-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
0a7476 |
---
|
|
|
0a7476 |
src/qemu/qemu_hotplug.c | 49 ++++++++---------------------------------
|
|
|
0a7476 |
1 file changed, 9 insertions(+), 40 deletions(-)
|
|
|
0a7476 |
|
|
|
0a7476 |
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
|
|
|
0a7476 |
index 5e8583ae8b..ffb2e258b5 100644
|
|
|
0a7476 |
--- a/src/qemu/qemu_hotplug.c
|
|
|
0a7476 |
+++ b/src/qemu/qemu_hotplug.c
|
|
|
0a7476 |
@@ -4721,43 +4721,6 @@ qemuDomainSignalDeviceRemoval(virDomainObjPtr vm,
|
|
|
0a7476 |
}
|
|
|
0a7476 |
|
|
|
0a7476 |
|
|
|
0a7476 |
-static int
|
|
|
0a7476 |
-qemuDomainDetachVirtioDiskDevice(virQEMUDriverPtr driver,
|
|
|
0a7476 |
- virDomainObjPtr vm,
|
|
|
0a7476 |
- virDomainDiskDefPtr 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: %s"),
|
|
|
0a7476 |
- detach->dst);
|
|
|
0a7476 |
- goto cleanup;
|
|
|
0a7476 |
- }
|
|
|
0a7476 |
-
|
|
|
0a7476 |
- if (!async)
|
|
|
0a7476 |
- qemuDomainMarkDeviceForRemoval(vm, &detach->info);
|
|
|
0a7476 |
-
|
|
|
0a7476 |
- if (qemuDomainDeleteDevice(vm, detach->info.alias) < 0) {
|
|
|
0a7476 |
- if (virDomainObjIsActive(vm))
|
|
|
0a7476 |
- virDomainAuditDisk(vm, detach->src, NULL, "detach", false);
|
|
|
0a7476 |
- goto cleanup;
|
|
|
0a7476 |
- }
|
|
|
0a7476 |
-
|
|
|
0a7476 |
- if (async) {
|
|
|
0a7476 |
- ret = 0;
|
|
|
0a7476 |
- } else {
|
|
|
0a7476 |
- if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
|
|
|
0a7476 |
- ret = qemuDomainRemoveDiskDevice(driver, vm, detach);
|
|
|
0a7476 |
- }
|
|
|
0a7476 |
-
|
|
|
0a7476 |
- cleanup:
|
|
|
0a7476 |
- if (!async)
|
|
|
0a7476 |
- qemuDomainResetDeviceRemoval(vm);
|
|
|
0a7476 |
- return ret;
|
|
|
0a7476 |
-}
|
|
|
0a7476 |
-
|
|
|
0a7476 |
static int
|
|
|
0a7476 |
qemuDomainDetachDiskDevice(virQEMUDriverPtr driver,
|
|
|
0a7476 |
virDomainObjPtr vm,
|
|
|
0a7476 |
@@ -4767,7 +4730,15 @@ qemuDomainDetachDiskDevice(virQEMUDriverPtr driver,
|
|
|
0a7476 |
int ret = -1;
|
|
|
0a7476 |
|
|
|
0a7476 |
if (qemuDomainDiskBlockJobIsActive(detach))
|
|
|
0a7476 |
- goto cleanup;
|
|
|
0a7476 |
+ return -1;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ if (detach->bus == VIR_DOMAIN_DISK_BUS_VIRTIO &&
|
|
|
0a7476 |
+ qemuIsMultiFunctionDevice(vm->def, &detach->info)) {
|
|
|
0a7476 |
+ virReportError(VIR_ERR_OPERATION_FAILED,
|
|
|
0a7476 |
+ _("cannot hot unplug multifunction PCI device: %s"),
|
|
|
0a7476 |
+ detach->dst);
|
|
|
0a7476 |
+ return -1;
|
|
|
0a7476 |
+ }
|
|
|
0a7476 |
|
|
|
0a7476 |
if (!async)
|
|
|
0a7476 |
qemuDomainMarkDeviceForRemoval(vm, &detach->info);
|
|
|
0a7476 |
@@ -4826,8 +4797,6 @@ qemuDomainDetachDeviceDiskLive(virQEMUDriverPtr driver,
|
|
|
0a7476 |
|
|
|
0a7476 |
switch ((virDomainDiskBus) disk->bus) {
|
|
|
0a7476 |
case VIR_DOMAIN_DISK_BUS_VIRTIO:
|
|
|
0a7476 |
- return qemuDomainDetachVirtioDiskDevice(driver, vm, disk, async);
|
|
|
0a7476 |
-
|
|
|
0a7476 |
case VIR_DOMAIN_DISK_BUS_USB:
|
|
|
0a7476 |
case VIR_DOMAIN_DISK_BUS_SCSI:
|
|
|
0a7476 |
return qemuDomainDetachDiskDevice(driver, vm, disk, async);
|
|
|
0a7476 |
--
|
|
|
0a7476 |
2.21.0
|
|
|
0a7476 |
|