mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-31 14:23:53 -06:00
libvhost-user-glib: export vug_source_new()
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 <marcandre.lureau@redhat.com> Message-Id: <20190308140454.32437-10-marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
9af84c02e2
commit
922ef483ec
2 changed files with 9 additions and 5 deletions
|
@ -68,15 +68,16 @@ static GSourceFuncs vug_src_funcs = {
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static GSource *
|
GSource *
|
||||||
vug_source_new(VuDev *dev, int fd, GIOCondition cond,
|
vug_source_new(VugDev *gdev, int fd, GIOCondition cond,
|
||||||
vu_watch_cb vu_cb, gpointer data)
|
vu_watch_cb vu_cb, gpointer data)
|
||||||
{
|
{
|
||||||
|
VuDev *dev = &gdev->parent;
|
||||||
GSource *gsrc;
|
GSource *gsrc;
|
||||||
VugSrc *src;
|
VugSrc *src;
|
||||||
guint id;
|
guint id;
|
||||||
|
|
||||||
g_assert(dev);
|
g_assert(gdev);
|
||||||
g_assert(fd >= 0);
|
g_assert(fd >= 0);
|
||||||
g_assert(vu_cb);
|
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);
|
g_assert(cb);
|
||||||
|
|
||||||
dev = container_of(vu_dev, VugDev, parent);
|
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);
|
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,
|
dev->fdmap = g_hash_table_new_full(NULL, NULL, NULL,
|
||||||
(GDestroyNotify) g_source_destroy);
|
(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
|
void
|
||||||
|
|
|
@ -29,4 +29,7 @@ void vug_init(VugDev *dev, int socket,
|
||||||
vu_panic_cb panic, const VuDevIface *iface);
|
vu_panic_cb panic, const VuDevIface *iface);
|
||||||
void vug_deinit(VugDev *dev);
|
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 */
|
#endif /* LIBVHOST_USER_GLIB_H */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue