Skip to contentSkip to conversation

: Close handle to the serial device when destroying a, channel

PATCH New Martin Drab 2 participants 2 messages Oct 16, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : Close handle to the serial device when destroying a, channel

From 4010649ca861e78bb45688258db7f37edfe81342 Mon Sep 17 00:00:00 2001
From: Martin Drab <[email protected]>
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.

---
 qga/channel-win32.c | 6 ++++++

 1 file changed, 6 insertions(+)
qga/channel-win32.c +0 -0
index 779007e39b..520cd6ae50 100644
@@ -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);
 }

Signature · 1 line
2.39.1.windows.1
#1 lore raw

PATCH 1/1 qga: Close handle to the serial device when destroying a channel

From: Martin Drab <[email protected]>

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.

---
 qga/channel-win32.c | 6 ++++++
 1 file changed, 6 insertions(+)
qga/channel-win32.c +6 -0
index 779007e39b..520cd6ae50 100644
@@ -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);
 }
Signature · 1 line
2.39.1.windows.1