|
|
fbe740 |
From ec2f52e9e935136d8517567bbe0e56c6e8c40af1 Mon Sep 17 00:00:00 2001
|
|
|
fbe740 |
Message-Id: <ec2f52e9e935136d8517567bbe0e56c6e8c40af1@dist-git>
|
|
|
fbe740 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
fbe740 |
Date: Wed, 19 Feb 2020 15:10:05 +0100
|
|
|
fbe740 |
Subject: [PATCH] qemu: hotplug: Fix handling of the 'copy-on-read' layer with
|
|
|
fbe740 |
blockdev
|
|
|
fbe740 |
MIME-Version: 1.0
|
|
|
fbe740 |
Content-Type: text/plain; charset=UTF-8
|
|
|
fbe740 |
Content-Transfer-Encoding: 8bit
|
|
|
fbe740 |
|
|
|
fbe740 |
My original implementation was completely broken because it attempted to
|
|
|
fbe740 |
use object-add/del instead of blockdev-add/del.
|
|
|
fbe740 |
|
|
|
fbe740 |
https://bugzilla.redhat.com/show_bug.cgi?id=1798366
|
|
|
fbe740 |
|
|
|
fbe740 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
|
|
|
fbe740 |
(cherry picked from commit b71cf8726c25ea135ac81051e332544e6b886ad2)
|
|
|
fbe740 |
|
|
|
fbe740 |
https://bugzilla.redhat.com/show_bug.cgi?id=1798366
|
|
|
fbe740 |
Message-Id: <170358b3722e56fc308e7cf3b0a2625349346ae9.1582120424.git.pkrempa@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
fbe740 |
---
|
|
|
fbe740 |
src/qemu/qemu_hotplug.c | 25 ++++++++++++++++---------
|
|
|
fbe740 |
1 file changed, 16 insertions(+), 9 deletions(-)
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
|
|
|
fbe740 |
index 31d455505b..12bc1f9dd5 100644
|
|
|
fbe740 |
--- a/src/qemu/qemu_hotplug.c
|
|
|
fbe740 |
+++ b/src/qemu/qemu_hotplug.c
|
|
|
fbe740 |
@@ -680,6 +680,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
|
|
|
fbe740 |
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
|
|
fbe740 |
g_autoptr(virJSONValue) corProps = NULL;
|
|
|
fbe740 |
g_autofree char *corAlias = NULL;
|
|
|
fbe740 |
+ bool corAdded = false;
|
|
|
fbe740 |
bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
|
|
|
fbe740 |
|
|
|
fbe740 |
if (qemuDomainStorageSourceChainAccessAllow(driver, vm, disk->src) < 0)
|
|
|
fbe740 |
@@ -692,9 +693,12 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
|
|
|
fbe740 |
goto cleanup;
|
|
|
fbe740 |
|
|
|
fbe740 |
if (blockdev) {
|
|
|
fbe740 |
- if (disk->copy_on_read == VIR_TRISTATE_SWITCH_ON &&
|
|
|
fbe740 |
- !(corProps = qemuBlockStorageGetCopyOnReadProps(disk)))
|
|
|
fbe740 |
- goto cleanup;
|
|
|
fbe740 |
+ if (disk->copy_on_read == VIR_TRISTATE_SWITCH_ON) {
|
|
|
fbe740 |
+ if (!(corProps = qemuBlockStorageGetCopyOnReadProps(disk)))
|
|
|
fbe740 |
+ goto cleanup;
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ corAlias = g_strdup(QEMU_DOMAIN_DISK_PRIVATE(disk)->nodeCopyOnRead);
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
|
|
|
fbe740 |
if (!(data = qemuBuildStorageSourceChainAttachPrepareBlockdev(disk->src,
|
|
|
fbe740 |
priv->qemuCaps)))
|
|
|
fbe740 |
@@ -719,9 +723,12 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
|
|
|
fbe740 |
if (qemuBlockStorageSourceChainAttach(priv->mon, data) < 0)
|
|
|
fbe740 |
goto exit_monitor;
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (corProps &&
|
|
|
fbe740 |
- qemuMonitorAddObject(priv->mon, &corProps, &corAlias) < 0)
|
|
|
fbe740 |
- goto exit_monitor;
|
|
|
fbe740 |
+ if (corProps) {
|
|
|
fbe740 |
+ if (qemuMonitorBlockdevAdd(priv->mon, &corProps) < 0)
|
|
|
fbe740 |
+ goto exit_monitor;
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ corAdded = true;
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
|
|
|
fbe740 |
if (qemuDomainAttachExtensionDevice(priv->mon, &disk->info) < 0)
|
|
|
fbe740 |
goto exit_monitor;
|
|
|
fbe740 |
@@ -763,8 +770,8 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
|
|
|
fbe740 |
return ret;
|
|
|
fbe740 |
|
|
|
fbe740 |
exit_monitor:
|
|
|
fbe740 |
- if (corAlias)
|
|
|
fbe740 |
- ignore_value(qemuMonitorDelObject(priv->mon, corAlias));
|
|
|
fbe740 |
+ if (corAdded)
|
|
|
fbe740 |
+ ignore_value(qemuMonitorBlockdevDel(priv->mon, corAlias));
|
|
|
fbe740 |
qemuBlockStorageSourceChainDetach(priv->mon, data);
|
|
|
fbe740 |
|
|
|
fbe740 |
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
|
fbe740 |
@@ -4252,7 +4259,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
|
|
|
fbe740 |
qemuDomainObjEnterMonitor(driver, vm);
|
|
|
fbe740 |
|
|
|
fbe740 |
if (corAlias)
|
|
|
fbe740 |
- ignore_value(qemuMonitorDelObject(priv->mon, corAlias));
|
|
|
fbe740 |
+ ignore_value(qemuMonitorBlockdevDel(priv->mon, corAlias));
|
|
|
fbe740 |
|
|
|
fbe740 |
if (diskBackend)
|
|
|
fbe740 |
qemuBlockStorageSourceChainDetach(priv->mon, diskBackend);
|
|
|
fbe740 |
--
|
|
|
fbe740 |
2.25.0
|
|
|
fbe740 |
|