qga/channel-win32.c | 6 ++++++ 1 file changed, 6 insertions(+)
From 4010649ca861e78bb45688258db7f37edfe81342 Mon Sep 17 00:00:00 2001
From: Martin Drab <martin.drab@virtuozzo.com>
Date: Wed, 15 Oct 2025 23:37:24 +0200
Subject: [PATCH] [qga]: Close handle to the serial device when destroying a
channel
It seems the handle is not being closed when QGA is freeing its
communication channel. The open handle prevents the serial device from
being removed. That may happen, for example, when the Virtio serial
driver fails to restart its devices after HW resource reassignment due
to a CPU/memory hotplug.
This fix adds the handle closing code into the ga_channel_free function.
Only QGA for Windows is being fixed.
Signed-Off-By: Martin Drab <martin.drab@virtuozzo.com>
---
qga/channel-win32.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/qga/channel-win32.c b/qga/channel-win32.c
index 779007e39b..520cd6ae50 100644
--- a/qga/channel-win32.c
+++ b/qga/channel-win32.c
@@ -354,6 +354,12 @@ void ga_channel_free(GAChannel *c)
if (c->rstate.ov.hEvent) {
CloseHandle(c->rstate.ov.hEvent);
}
+
+ if (c->handle) {
+ CancelIo(c->handle);
+ CloseHandle(c->handle);
+ }
+
g_free(c->rstate.buf);
g_free(c);
}
--
2.39.1.windows.1
From: Martin Drab <martin.drab@virtuozzo.com>
It seems the handle is not being closed when QGA is freeing its communication channel. The open handle prevents the serial device from being removed. That may happen, for example, when the Virtio serial driver fails to restart its devices after HW resource reassignment due to a CPU/memory hotplug.
This fix adds the handle closing code into the ga_channel_free function. Only QGA for Windows is being fixed.
Signed-Off-By: Martin Drab <martin.drab@virtuozzo.com>
---
qga/channel-win32.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/qga/channel-win32.c b/qga/channel-win32.c
index 779007e39b..520cd6ae50 100644
--- a/qga/channel-win32.c
+++ b/qga/channel-win32.c
@@ -354,6 +354,12 @@ void ga_channel_free(GAChannel *c)
if (c->rstate.ov.hEvent) {
CloseHandle(c->rstate.ov.hEvent);
}
+
+ if (c->handle) {
+ CancelIo(c->handle);
+ CloseHandle(c->handle);
+ }
+
g_free(c->rstate.buf);
g_free(c);
}
--
2.39.1.windows.1
© 2016 - 2025 Red Hat, Inc.