mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-24 12:22:20 +00:00
qemu: Clear 'qemuFDPass' helpers of char devices when no longer needed
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@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
6b3373ffa5
commit
686f83e66e
@ -1547,6 +1547,8 @@ qemuBuildChardevCommand(virCommand *cmd,
|
||||
|
||||
virCommandAddArgList(cmd, "-chardev", charstr, NULL);
|
||||
|
||||
qemuDomainChrSourcePrivateClearFDPass(chrSourcePriv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -359,6 +359,9 @@ struct _qemuDomainChrSourcePrivate {
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
qemuDomainChrSourcePrivateClearFDPass(qemuDomainChrSourcePrivate *priv);
|
||||
|
||||
typedef struct _qemuDomainVsockPrivate qemuDomainVsockPrivate;
|
||||
struct _qemuDomainVsockPrivate {
|
||||
virObject parent;
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user