render / rpms / libvirt

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