[libvirt] [PATCH v2] qemuDomainRemoveRNGDevice: Remove associated chardev too

Michal Privoznik posted 1 patch 1 week ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/0788176b171336ac2c8d39a8cade7896c61eb944.1543935937.git.mprivozn@redhat.com
src/qemu/qemu_hotplug.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)

[libvirt] [PATCH v2] qemuDomainRemoveRNGDevice: Remove associated chardev too

Posted by Michal Privoznik 1 week ago
https://bugzilla.redhat.com/show_bug.cgi?id=1656014

An RNG device can consists of more devices than RND device
itself. For instance, in case of EGD there is a chardev that
connects to EGD daemon and feeds the qemu with random data. When
doing RNG device removal we have to remove the associated chardev
as well.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---

diff to v1:
- Detach Extension Device too
- Reoder the way in which devices are detached (as suggested in v1)

 src/qemu/qemu_hotplug.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 5f756b7267..f5f8cec59e 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -4814,7 +4814,7 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver,
     qemuDomainObjPrivatePtr priv = vm->privateData;
     ssize_t idx;
     int ret = -1;
-    int rc;
+    int rc = 0;
 
     VIR_DEBUG("Removing RNG device %s from domain %p %s",
               rng->info.alias, vm, vm->def->name);
@@ -4828,7 +4828,17 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver,
 
     qemuDomainObjEnterMonitor(driver, vm);
 
-    rc = qemuMonitorDelObject(priv->mon, objAlias);
+    if (qemuDomainDetachExtensionDevice(priv->mon, &rng->info) < 0)
+        rc = -1;
+
+    if (rc == 0 &&
+        qemuMonitorDelObject(priv->mon, objAlias) < 0)
+        rc = -1;
+
+    if (rng->backend == VIR_DOMAIN_RNG_BACKEND_EGD &&
+        rc == 0 &&
+        qemuMonitorDetachCharDev(priv->mon, charAlias) < 0)
+        rc = -1;
 
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
         goto cleanup;
@@ -4837,7 +4847,7 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver,
         rc == 0 &&
         qemuDomainDelChardevTLSObjects(driver, vm, rng->source.chardev,
                                        charAlias) < 0)
-        goto cleanup;
+        rc = -1;
 
     virDomainAuditRNG(vm, rng, NULL, "detach", rc == 0);
 
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2] qemuDomainRemoveRNGDevice: Remove associated chardev too

Posted by Ján Tomko 1 week ago
On Tue, Dec 04, 2018 at 04:06:50PM +0100, Michal Privoznik wrote:
>https://bugzilla.redhat.com/show_bug.cgi?id=1656014
>
>An RNG device can consists of more devices than RND device
>itself. For instance, in case of EGD there is a chardev that
>connects to EGD daemon and feeds the qemu with random data. When
>doing RNG device removal we have to remove the associated chardev
>as well.
>
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>---
>
>diff to v1:
>- Detach Extension Device too
>- Reoder the way in which devices are detached (as suggested in v1)
>
> src/qemu/qemu_hotplug.c | 16 +++++++++++++---
> 1 file changed, 13 insertions(+), 3 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list