From: Johannes Berg <johannes@sipsolutions.net>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Johannes Berg" <johannes.berg@intel.com>
Subject: [Qemu-devel] [PATCH] libvhost-user-glib: fix VugDev main fd cleanup
Date: Tue, 27 Aug 2019 11:31:24 +0300 [thread overview]
Message-ID: <20190827083124.30791-1-johannes@sipsolutions.net> (raw)
From: Johannes Berg <johannes.berg@intel.com>
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 <johannes.berg@intel.com>
---
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
next reply other threads:[~2019-08-27 8:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-27 8:31 Johannes Berg [this message]
2019-08-27 10:47 ` [Qemu-devel] [PATCH] libvhost-user-glib: fix VugDev main fd cleanup Marc-André Lureau
2019-08-27 11:37 ` Johannes Berg
2019-08-27 11:44 ` Marc-André Lureau
2019-08-27 12:05 ` Johannes Berg
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=20190827083124.30791-1-johannes@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=johannes.berg@intel.com \
--cc=marcandre.lureau@redhat.com \
--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).