While the FDs are closed right after use to prevent leaks, at certain
point we don't need the whole helper any more. Clear them for char
devices after hotplug and on start.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_command.c | 2 ++
src/qemu/qemu_domain.c | 14 ++++++++++++--
src/qemu/qemu_domain.h | 3 +++
src/qemu/qemu_hotplug.c | 3 +++
4 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3032cbc623..95632827cb 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1526,6 +1526,8 @@ qemuBuildChardevCommand(virCommand *cmd,
virCommandAddArgList(cmd, "-chardev", charstr, NULL);
+ qemuDomainChrSourcePrivateClearFDPass(chrSourcePriv);
+
return 0;
}
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index a726e2624a..2df02943bf 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -908,13 +908,23 @@ qemuDomainChrSourcePrivateNew(void)
}
+void
+qemuDomainChrSourcePrivateClearFDPass(qemuDomainChrSourcePrivate *priv)
+{
+ if (!priv)
+ return;
+
+ g_clear_pointer(&priv->sourcefd, qemuFDPassFree);
+ g_clear_pointer(&priv->logfd, qemuFDPassFree);
+}
+
+
static void
qemuDomainChrSourcePrivateDispose(void *obj)
{
qemuDomainChrSourcePrivate *priv = obj;
- qemuFDPassFree(priv->sourcefd);
- qemuFDPassFree(priv->logfd);
+ qemuDomainChrSourcePrivateClearFDPass(priv);
g_free(priv->tlsCertPath);
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 358f1c163f..e13c6be399 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -356,6 +356,9 @@ struct _qemuDomainChrSourcePrivate {
};
+void
+qemuDomainChrSourcePrivateClearFDPass(qemuDomainChrSourcePrivate *priv);
+
typedef struct _qemuDomainVsockPrivate qemuDomainVsockPrivate;
struct _qemuDomainVsockPrivate {
virObject parent;
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 62cfc29a16..e8e028706b 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2293,6 +2293,9 @@ qemuDomainAttachChrDevice(virQEMUDriver *driver,
if (teardowndevice && qemuDomainNamespaceTeardownChardev(vm, chr) <
0)
VIR_WARN("Unable to remove chr device from /dev");
}
+
+ qemuDomainChrSourcePrivateClearFDPass(charpriv);
+
return ret;
exit_monitor:
--
2.35.1