qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [qga]: Close handle to the serial device when destroying a, channel
@ 2025-10-16 13:08 Martin Drab
  2025-10-16 21:21 ` [PATCH] qga: Close handle to the serial device when destroying a channel md
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Drab @ 2025-10-16 13:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: martin.drab

 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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-10-16 22:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-16 13:08 [PATCH] [qga]: Close handle to the serial device when destroying a, channel Martin Drab
2025-10-16 21:21 ` [PATCH] qga: Close handle to the serial device when destroying a channel md

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).