libvirt/SOURCES/libvirt-qemuDomainRemoveRNGDevice-Remove-associated-chardev-too.patch
2021-09-10 11:57:18 +00:00

77 lines
2.6 KiB
Diff

From d50cf2d60114e7e33c2bd25fb67566a889057b77 Mon Sep 17 00:00:00 2001
Message-Id: <d50cf2d60114e7e33c2bd25fb67566a889057b77@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Mon, 8 Apr 2019 10:57:30 +0200
Subject: [PATCH] qemuDomainRemoveRNGDevice: Remove associated chardev too
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 7730a2ead4279e3a11771e1069096747988410cf)
https://bugzilla.redhat.com/show_bug.cgi?id=1508149
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20190408085732.28684-14-abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
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 abe2632556..8394efa739 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -4408,7 +4408,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);
@@ -4422,7 +4422,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;
@@ -4431,7 +4441,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.22.0