diff mbox

[27/54] char-win: do not override chr_free

Message ID 20161212224325.20790-28-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau Dec. 12, 2016, 10:42 p.m. UTC
For some unclear reason to me, char-file does not have chr_free on
win32. Since we want to switch to instance finalizer instead of class
chr_free, we should be able to run the base WinChardev class finalizer
in any case. Use a boolean to skip free to ease the transition to
instance finalizer.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qemu-char.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/qemu-char.c b/qemu-char.c
index 3dfb249d81..63b254f632 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2117,6 +2117,8 @@  typedef struct {
 
     /* Protected by the Chardev chr_write_lock.  */
     OVERLAPPED osend;
+    /* FIXME: file/console do not finalize */
+    BOOL skip_free;
 } WinChardev;
 
 #define TYPE_CHARDEV_WIN "chardev-win"
@@ -2147,6 +2149,10 @@  static void win_chr_free(Chardev *chr)
 {
     WinChardev *s = WIN_CHARDEV(chr);
 
+    if (s->skip_free) {
+        return;
+    }
+
     if (s->hsend) {
         CloseHandle(s->hsend);
         s->hsend = NULL;
@@ -2427,6 +2433,7 @@  static void qemu_chr_open_win_file(Chardev *chr, HANDLE fd_out)
 {
     WinChardev *s = WIN_CHARDEV(chr);
 
+    s->skip_free = true;
     s->hcom = fd_out;
 }
 
@@ -2463,7 +2470,6 @@  static void char_console_class_init(ObjectClass *oc, void *data)
     ChardevClass *cc = CHARDEV_CLASS(oc);
 
     cc->open = qemu_chr_open_win_con;
-    cc->chr_free = NULL;
 }
 
 static const TypeInfo char_console_type_info = {
@@ -4728,10 +4734,6 @@  static void char_file_class_init(ObjectClass *oc, void *data)
     ChardevClass *cc = CHARDEV_CLASS(oc);
 
     cc->open = qmp_chardev_open_file;
-#ifdef _WIN32
-    /* FIXME: no chr_free */
-    cc->chr_free = NULL;
-#endif
 }
 
 static const TypeInfo char_file_type_info = {