render / rpms / libvirt

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