qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Martin Drab <martin.drab@virtuozzo.com>
To: qemu-devel@nongnu.org
Cc: martin.drab@email.cz
Subject: [PATCH] [qga]: Close handle to the serial device when destroying a, channel
Date: Thu, 16 Oct 2025 15:08:51 +0200	[thread overview]
Message-ID: <561f5abd-c699-48e5-a396-fd4714b11fa0@virtuozzo.com> (raw)

 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



             reply	other threads:[~2025-10-16 14:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-16 13:08 Martin Drab [this message]
2025-10-16 21:21 ` [PATCH] qga: Close handle to the serial device when destroying a channel md

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=561f5abd-c699-48e5-a396-fd4714b11fa0@virtuozzo.com \
    --to=martin.drab@virtuozzo.com \
    --cc=martin.drab@email.cz \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).