[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] libvhost-user-glib: fix VugDev main fd cleanup
From: |
Johannes Berg |
Subject: |
[Qemu-devel] [PATCH] libvhost-user-glib: fix VugDev main fd cleanup |
Date: |
Tue, 27 Aug 2019 11:31:24 +0300 |
From: Johannes Berg <address@hidden>
If you try to make a device implementation that can handle multiple
connections and allow disconnections (which requires overriding the
VHOST_USER_NONE handling), then glib will warn that we remove a src
while it's still on the mainloop, and will poll() an FD that doesn't
exist anymore.
Fix this by just using the internal add_watch() function that has
all necessary cleanups built in via the hashtable, rather than
treating the "main" fd of a device specially.
Fixes: 8bb7ddb78a1c ("libvhost-user: add glib source helper")
Signed-off-by: Johannes Berg <address@hidden>
---
contrib/libvhost-user/libvhost-user-glib.c | 3 +--
contrib/libvhost-user/libvhost-user-glib.h | 1 -
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/contrib/libvhost-user/libvhost-user-glib.c
b/contrib/libvhost-user/libvhost-user-glib.c
index 99edd2f3de45..a092a55c1d57 100644
--- a/contrib/libvhost-user/libvhost-user-glib.c
+++ b/contrib/libvhost-user/libvhost-user-glib.c
@@ -146,7 +146,7 @@ vug_init(VugDev *dev, uint16_t max_queues, int socket,
dev->fdmap = g_hash_table_new_full(NULL, NULL, NULL,
(GDestroyNotify) g_source_destroy);
- dev->src = vug_source_new(dev, socket, G_IO_IN, vug_watch, NULL);
+ set_watch(&dev->parent, socket, VU_WATCH_IN, vug_watch, NULL);
return true;
}
@@ -157,5 +157,4 @@ vug_deinit(VugDev *dev)
g_assert(dev);
g_hash_table_unref(dev->fdmap);
- g_source_unref(dev->src);
}
diff --git a/contrib/libvhost-user/libvhost-user-glib.h
b/contrib/libvhost-user/libvhost-user-glib.h
index 64d539d93aba..32a6ec6df063 100644
--- a/contrib/libvhost-user/libvhost-user-glib.h
+++ b/contrib/libvhost-user/libvhost-user-glib.h
@@ -22,7 +22,6 @@ typedef struct VugDev {
VuDev parent;
GHashTable *fdmap; /* fd -> gsource */
- GSource *src;
} VugDev;
bool vug_init(VugDev *dev, uint16_t max_queues, int socket,
--
2.23.0
- [Qemu-devel] [PATCH] libvhost-user-glib: fix VugDev main fd cleanup,
Johannes Berg <=