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