render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c480ed
From d50cf2d60114e7e33c2bd25fb67566a889057b77 Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <d50cf2d60114e7e33c2bd25fb67566a889057b77@dist-git>
c480ed
From: Michal Privoznik <mprivozn@redhat.com>
c480ed
Date: Mon, 8 Apr 2019 10:57:30 +0200
c480ed
Subject: [PATCH] qemuDomainRemoveRNGDevice: Remove associated chardev too
c480ed
MIME-Version: 1.0
c480ed
Content-Type: text/plain; charset=UTF-8
c480ed
Content-Transfer-Encoding: 8bit
c480ed
c480ed
https://bugzilla.redhat.com/show_bug.cgi?id=1656014
c480ed
c480ed
An RNG device can consists of more devices than RND device
c480ed
itself. For instance, in case of EGD there is a chardev that
c480ed
connects to EGD daemon and feeds the qemu with random data. When
c480ed
doing RNG device removal we have to remove the associated chardev
c480ed
as well.
c480ed
c480ed
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
c480ed
(cherry picked from commit 7730a2ead4279e3a11771e1069096747988410cf)
c480ed
c480ed
https://bugzilla.redhat.com/show_bug.cgi?id=1508149
c480ed
c480ed
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
c480ed
Message-Id: <20190408085732.28684-14-abologna@redhat.com>
c480ed
Reviewed-by: Laine Stump <laine@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 src/qemu/qemu_hotplug.c | 16 +++++++++++++---
c480ed
 1 file changed, 13 insertions(+), 3 deletions(-)
c480ed
c480ed
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
c480ed
index abe2632556..8394efa739 100644
c480ed
--- a/src/qemu/qemu_hotplug.c
c480ed
+++ b/src/qemu/qemu_hotplug.c
c480ed
@@ -4408,7 +4408,7 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver,
c480ed
     qemuDomainObjPrivatePtr priv = vm->privateData;
c480ed
     ssize_t idx;
c480ed
     int ret = -1;
c480ed
-    int rc;
c480ed
+    int rc = 0;
c480ed
 
c480ed
     VIR_DEBUG("Removing RNG device %s from domain %p %s",
c480ed
               rng->info.alias, vm, vm->def->name);
c480ed
@@ -4422,7 +4422,17 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver,
c480ed
 
c480ed
     qemuDomainObjEnterMonitor(driver, vm);
c480ed
 
c480ed
-    rc = qemuMonitorDelObject(priv->mon, objAlias);
c480ed
+    if (qemuDomainDetachExtensionDevice(priv->mon, &rng->info) < 0)
c480ed
+        rc = -1;
c480ed
+
c480ed
+    if (rc == 0 &&
c480ed
+        qemuMonitorDelObject(priv->mon, objAlias) < 0)
c480ed
+        rc = -1;
c480ed
+
c480ed
+    if (rng->backend == VIR_DOMAIN_RNG_BACKEND_EGD &&
c480ed
+        rc == 0 &&
c480ed
+        qemuMonitorDetachCharDev(priv->mon, charAlias) < 0)
c480ed
+        rc = -1;
c480ed
 
c480ed
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
c480ed
         goto cleanup;
c480ed
@@ -4431,7 +4441,7 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver,
c480ed
         rc == 0 &&
c480ed
         qemuDomainDelChardevTLSObjects(driver, vm, rng->source.chardev,
c480ed
                                        charAlias) < 0)
c480ed
-        goto cleanup;
c480ed
+        rc = -1;
c480ed
 
c480ed
     virDomainAuditRNG(vm, rng, NULL, "detach", rc == 0);
c480ed
 
c480ed
-- 
c480ed
2.22.0
c480ed