From 22d5ce025295916462c0eb7da4daabf64f99cae0 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 3 Feb 2022 10:35:03 +0100 Subject: [PATCH] qemuDomainRemoveChrDevice: Detach fdset after chardev hot-unplug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Our code uses fdsets for the pipe passed from virtlogd to qemu, but the chardev hot-unplug code neglected to detach the fdset after the chardev was removed. This kept the FDs open by qemu even after they were not used any more. After the refactor to use qemuFDPass for chardevs we now configure the 'opaque' field for fdsets used for chardevs so we can use qemuHotplugRemoveFDSet to remove the unused fdset. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_hotplug.c | 1 + tests/qemuhotplugtest.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 537c1d73d1..05993aa5d7 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -4881,6 +4881,7 @@ qemuDomainRemoveChrDevice(virQEMUDriver *driver, if (monitor) { qemuDomainObjEnterMonitor(driver, vm); rc = qemuMonitorDetachCharDev(priv->mon, charAlias); + qemuHotplugRemoveFDSet(priv->mon, chr->info.alias, NULL); qemuDomainObjExitMonitor(driver, vm); } diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 263a92425c..fe1b227b4e 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -708,7 +708,7 @@ mymain(void) DO_TEST_DETACH("console-compat-2-live", "console-virtio", false, false, "device_del", QMP_DEVICE_DELETED("console1") QMP_OK, - "chardev-remove", QMP_OK); + "chardev-remove", QMP_OK, "query-fdsets", "{\"return\": []}"); DO_TEST_ATTACH("base-live", "disk-virtio", false, true, "human-monitor-command", HMP("OK\\r\\n"), @@ -768,7 +768,7 @@ mymain(void) "device_add", QMP_OK); DO_TEST_DETACH("base-live", "qemu-agent-detach", false, false, "device_del", QMP_DEVICE_DELETED("channel0") QMP_OK, - "chardev-remove", QMP_OK); + "chardev-remove", QMP_OK, "query-fdsets", "{\"return\": []}"); DO_TEST_ATTACH("base-ccw-live", "ccw-virtio", false, true, "human-monitor-command", HMP("OK\\r\\n"),