[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 09/12] libvhost-user-glib: export vug_source_new(
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH v6 09/12] libvhost-user-glib: export vug_source_new() |
Date: |
Fri, 8 Mar 2019 15:04:51 +0100 |
Simplify the creation of FD sources for other users. This is just
convenience to avoid duplicating similar code elsewhere.
Signed-off-by: Marc-André Lureau <address@hidden>
---
contrib/libvhost-user/libvhost-user-glib.h | 3 +++
contrib/libvhost-user/libvhost-user-glib.c | 11 ++++++-----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/contrib/libvhost-user/libvhost-user-glib.h
b/contrib/libvhost-user/libvhost-user-glib.h
index 6b2110b94c..d3200f3afc 100644
--- a/contrib/libvhost-user/libvhost-user-glib.h
+++ b/contrib/libvhost-user/libvhost-user-glib.h
@@ -29,4 +29,7 @@ void vug_init(VugDev *dev, int socket,
vu_panic_cb panic, const VuDevIface *iface);
void vug_deinit(VugDev *dev);
+GSource *vug_source_new(VugDev *dev, int fd, GIOCondition cond,
+ vu_watch_cb vu_cb, gpointer data);
+
#endif /* LIBVHOST_USER_GLIB_H */
diff --git a/contrib/libvhost-user/libvhost-user-glib.c
b/contrib/libvhost-user/libvhost-user-glib.c
index 545f089587..42660a1b36 100644
--- a/contrib/libvhost-user/libvhost-user-glib.c
+++ b/contrib/libvhost-user/libvhost-user-glib.c
@@ -68,15 +68,16 @@ static GSourceFuncs vug_src_funcs = {
NULL
};
-static GSource *
-vug_source_new(VuDev *dev, int fd, GIOCondition cond,
+GSource *
+vug_source_new(VugDev *gdev, int fd, GIOCondition cond,
vu_watch_cb vu_cb, gpointer data)
{
+ VuDev *dev = &gdev->parent;
GSource *gsrc;
VugSrc *src;
guint id;
- g_assert(dev);
+ g_assert(gdev);
g_assert(fd >= 0);
g_assert(vu_cb);
@@ -106,7 +107,7 @@ set_watch(VuDev *vu_dev, int fd, int vu_evt, vu_watch_cb
cb, void *pvt)
g_assert(cb);
dev = container_of(vu_dev, VugDev, parent);
- src = vug_source_new(vu_dev, fd, vu_evt, cb, pvt);
+ src = vug_source_new(dev, fd, vu_evt, cb, pvt);
g_hash_table_replace(dev->fdmap, GINT_TO_POINTER(fd), src);
}
@@ -141,7 +142,7 @@ vug_init(VugDev *dev, int socket,
dev->fdmap = g_hash_table_new_full(NULL, NULL, NULL,
(GDestroyNotify) g_source_destroy);
- dev->src = vug_source_new(&dev->parent, socket, G_IO_IN, vug_watch, NULL);
+ dev->src = vug_source_new(dev, socket, G_IO_IN, vug_watch, NULL);
}
void
--
2.21.0.4.g36eb1cb9cf
- Re: [Qemu-devel] [PATCH v6 06/12] Add vhost-user-backend, (continued)
[Qemu-devel] [PATCH v6 09/12] libvhost-user-glib: export vug_source_new(),
Marc-André Lureau <=
[Qemu-devel] [PATCH v6 11/12] Add vhost-user-input-pci, Marc-André Lureau, 2019/03/08
[Qemu-devel] [PATCH v6 12/12] contrib: add vhost-user-input, Marc-André Lureau, 2019/03/08
[Qemu-devel] [PATCH v6 10/12] libvhost-user: add vu_queue_unpop(), Marc-André Lureau, 2019/03/08