[{"id":1783886,"web_url":"http://patchwork.ozlabs.org/comment/1783886/","msgid":"<7d512cc6-ecbb-7cef-2b4c-36441b5ee614@redhat.com>","list_archive_url":null,"date":"2017-10-10T16:22:12","subject":"Re: [Qemu-devel] [PATCH v2 25/27] libvhost-user: add glib source\n\thelper","submitter":{"id":2701,"url":"http://patchwork.ozlabs.org/api/people/2701/","name":"Paolo Bonzini","email":"pbonzini@redhat.com"},"content":"On 19/09/2017 18:52, Marc-André Lureau wrote:\n> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>\nMaybe a few lines would help here, like\n\nThis file implements a bridge from the vu_init API of libvhost-user to\nGSource, so that libvhost-user can be used inside a GLib main loop.\n\nPaolo\n\n> ---\n>  contrib/libvhost-user/libvhost-user-glib.h |  32 ++++++\n>  contrib/libvhost-user/libvhost-user-glib.c | 154 +++++++++++++++++++++++++++++\n>  contrib/libvhost-user/Makefile.objs        |   2 +-\n>  3 files changed, 187 insertions(+), 1 deletion(-)\n>  create mode 100644 contrib/libvhost-user/libvhost-user-glib.h\n>  create mode 100644 contrib/libvhost-user/libvhost-user-glib.c\n> \n> diff --git a/contrib/libvhost-user/libvhost-user-glib.h b/contrib/libvhost-user/libvhost-user-glib.h\n> new file mode 100644\n> index 0000000000..6b2110b94c\n> --- /dev/null\n> +++ b/contrib/libvhost-user/libvhost-user-glib.h\n> @@ -0,0 +1,32 @@\n> +/*\n> + * Vhost User library\n> + *\n> + * Copyright (c) 2016 Nutanix Inc. All rights reserved.\n> + * Copyright (c) 2017 Red Hat, Inc.\n> + *\n> + * Authors:\n> + *  Marc-André Lureau <mlureau@redhat.com>\n> + *  Felipe Franciosi <felipe@nutanix.com>\n> + *\n> + * This work is licensed under the terms of the GNU GPL, version 2 or\n> + * later.  See the COPYING file in the top-level directory.\n> + */\n> +\n> +#ifndef LIBVHOST_USER_GLIB_H\n> +#define LIBVHOST_USER_GLIB_H\n> +\n> +#include <glib.h>\n> +#include \"libvhost-user.h\"\n> +\n> +typedef struct VugDev {\n> +    VuDev parent;\n> +\n> +    GHashTable *fdmap; /* fd -> gsource */\n> +    GSource *src;\n> +} VugDev;\n> +\n> +void vug_init(VugDev *dev, int socket,\n> +              vu_panic_cb panic, const VuDevIface *iface);\n> +void vug_deinit(VugDev *dev);\n> +\n> +#endif /* LIBVHOST_USER_GLIB_H */\n> diff --git a/contrib/libvhost-user/libvhost-user-glib.c b/contrib/libvhost-user/libvhost-user-glib.c\n> new file mode 100644\n> index 0000000000..545f089587\n> --- /dev/null\n> +++ b/contrib/libvhost-user/libvhost-user-glib.c\n> @@ -0,0 +1,154 @@\n> +/*\n> + * Vhost User library\n> + *\n> + * Copyright (c) 2016 Nutanix Inc. All rights reserved.\n> + * Copyright (c) 2017 Red Hat, Inc.\n> + *\n> + * Authors:\n> + *  Marc-André Lureau <mlureau@redhat.com>\n> + *  Felipe Franciosi <felipe@nutanix.com>\n> + *\n> + * This work is licensed under the terms of the GNU GPL, version 2 or\n> + * later.  See the COPYING file in the top-level directory.\n> + */\n> +\n> +#include \"qemu/osdep.h\"\n> +\n> +#include \"libvhost-user-glib.h\"\n> +\n> +/* glib event loop integration for libvhost-user and misc callbacks */\n> +\n> +G_STATIC_ASSERT((int)G_IO_IN == (int)VU_WATCH_IN);\n> +G_STATIC_ASSERT((int)G_IO_OUT == (int)VU_WATCH_OUT);\n> +G_STATIC_ASSERT((int)G_IO_PRI == (int)VU_WATCH_PRI);\n> +G_STATIC_ASSERT((int)G_IO_ERR == (int)VU_WATCH_ERR);\n> +G_STATIC_ASSERT((int)G_IO_HUP == (int)VU_WATCH_HUP);\n> +\n> +typedef struct VugSrc {\n> +    GSource parent;\n> +    VuDev *dev;\n> +    GPollFD gfd;\n> +} VugSrc;\n> +\n> +static gboolean\n> +vug_src_prepare(GSource *gsrc, gint *timeout)\n> +{\n> +    g_assert(timeout);\n> +\n> +    *timeout = -1;\n> +    return FALSE;\n> +}\n> +\n> +static gboolean\n> +vug_src_check(GSource *gsrc)\n> +{\n> +    VugSrc *src = (VugSrc *)gsrc;\n> +\n> +    g_assert(src);\n> +\n> +    return src->gfd.revents & src->gfd.events;\n> +}\n> +\n> +static gboolean\n> +vug_src_dispatch(GSource *gsrc, GSourceFunc cb, gpointer data)\n> +{\n> +    VugSrc *src = (VugSrc *)gsrc;\n> +\n> +    g_assert(src);\n> +\n> +    ((vu_watch_cb)cb)(src->dev, src->gfd.revents, data);\n> +\n> +    return G_SOURCE_CONTINUE;\n> +}\n> +\n> +static GSourceFuncs vug_src_funcs = {\n> +    vug_src_prepare,\n> +    vug_src_check,\n> +    vug_src_dispatch,\n> +    NULL\n> +};\n> +\n> +static GSource *\n> +vug_source_new(VuDev *dev, int fd, GIOCondition cond,\n> +               vu_watch_cb vu_cb, gpointer data)\n> +{\n> +    GSource *gsrc;\n> +    VugSrc *src;\n> +    guint id;\n> +\n> +    g_assert(dev);\n> +    g_assert(fd >= 0);\n> +    g_assert(vu_cb);\n> +\n> +    gsrc = g_source_new(&vug_src_funcs, sizeof(VugSrc));\n> +    g_source_set_callback(gsrc, (GSourceFunc)vu_cb, data, NULL);\n> +    src = (VugSrc *)gsrc;\n> +    src->dev = dev;\n> +    src->gfd.fd = fd;\n> +    src->gfd.events = cond;\n> +\n> +    g_source_add_poll(gsrc, &src->gfd);\n> +    id = g_source_attach(gsrc, NULL);\n> +    g_assert(id);\n> +    g_source_unref(gsrc);\n> +\n> +    return gsrc;\n> +}\n> +\n> +static void\n> +set_watch(VuDev *vu_dev, int fd, int vu_evt, vu_watch_cb cb, void *pvt)\n> +{\n> +    GSource *src;\n> +    VugDev *dev;\n> +\n> +    g_assert(vu_dev);\n> +    g_assert(fd >= 0);\n> +    g_assert(cb);\n> +\n> +    dev = container_of(vu_dev, VugDev, parent);\n> +    src = vug_source_new(vu_dev, fd, vu_evt, cb, pvt);\n> +    g_hash_table_replace(dev->fdmap, GINT_TO_POINTER(fd), src);\n> +}\n> +\n> +static void\n> +remove_watch(VuDev *vu_dev, int fd)\n> +{\n> +    VugDev *dev;\n> +\n> +    g_assert(vu_dev);\n> +    g_assert(fd >= 0);\n> +\n> +    dev = container_of(vu_dev, VugDev, parent);\n> +    g_hash_table_remove(dev->fdmap, GINT_TO_POINTER(fd));\n> +}\n> +\n> +\n> +static void vug_watch(VuDev *dev, int condition, void *data)\n> +{\n> +    if (!vu_dispatch(dev) != 0) {\n> +        dev->panic(dev, \"Error processing vhost message\");\n> +    }\n> +}\n> +\n> +void\n> +vug_init(VugDev *dev, int socket,\n> +         vu_panic_cb panic, const VuDevIface *iface)\n> +{\n> +    g_assert(dev);\n> +    g_assert(iface);\n> +\n> +    vu_init(&dev->parent, socket, panic, set_watch, remove_watch, iface);\n> +    dev->fdmap = g_hash_table_new_full(NULL, NULL, NULL,\n> +                                       (GDestroyNotify) g_source_destroy);\n> +\n> +    dev->src = vug_source_new(&dev->parent, socket, G_IO_IN, vug_watch, NULL);\n> +}\n> +\n> +void\n> +vug_deinit(VugDev *dev)\n> +{\n> +    g_assert(dev);\n> +\n> +    g_hash_table_unref(dev->fdmap);\n> +    g_source_unref(dev->src);\n> +}\n> diff --git a/contrib/libvhost-user/Makefile.objs b/contrib/libvhost-user/Makefile.objs\n> index cef1ad6e31..ef3778edd4 100644\n> --- a/contrib/libvhost-user/Makefile.objs\n> +++ b/contrib/libvhost-user/Makefile.objs\n> @@ -1 +1 @@\n> -libvhost-user-obj-y = libvhost-user.o\n> +libvhost-user-obj-y += libvhost-user.o libvhost-user-glib.o\n> \n\nReviewed-by: Paolo Bonzini <pbonzini@redhat.com>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3yBMpl11P9z9tYR\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 11 Oct 2017 03:22:53 +1100 (AEDT)","from localhost ([::1]:35999 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1e1xIv-0008IH-O7\n\tfor incoming@patchwork.ozlabs.org; Tue, 10 Oct 2017 12:22:49 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:60581)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <pbonzini@redhat.com>) id 1e1xIS-0008Ht-PU\n\tfor qemu-devel@nongnu.org; Tue, 10 Oct 2017 12:22:27 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <pbonzini@redhat.com>) id 1e1xIO-0006Qy-PS\n\tfor qemu-devel@nongnu.org; Tue, 10 Oct 2017 12:22:20 -0400","from mail-wm0-f51.google.com ([74.125.82.51]:50662)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <pbonzini@redhat.com>) id 1e1xIO-0006Qp-Fd\n\tfor qemu-devel@nongnu.org; Tue, 10 Oct 2017 12:22:16 -0400","by mail-wm0-f51.google.com with SMTP id u138so6727108wmu.5\n\tfor <qemu-devel@nongnu.org>; Tue, 10 Oct 2017 09:22:16 -0700 (PDT)","from [192.168.10.165]\n\t(dynamic-adsl-78-12-246-117.clienti.tiscali.it.\n\t[78.12.246.117]) by smtp.gmail.com with ESMTPSA id\n\tl96sm1744761wrc.21.2017.10.10.09.22.13\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tTue, 10 Oct 2017 09:22:14 -0700 (PDT)"],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:subject:to:cc:references:from:message-id:date\n\t:user-agent:mime-version:in-reply-to:content-language\n\t:content-transfer-encoding;\n\tbh=82LuULecafu7Ai8yJWBJir3+XUCHB0C2mAaLkmjiOmQ=;\n\tb=gA0GOvcheCBffSs4li1tQ4tL4GIajPlt4Yi6g0ESdOpsbSIdd7IX+NO1IBkWDRdF6G\n\tyq1aP1jUKPRt8MeGTyNtW4UiCCZtSwwEwImkAHMo1sLXT4gCosyxhExkaRGg6TZTG1gr\n\tMlBgsl35vrbU4Ig3P3wZgDXfbwyQk3UEC1h6hihriicjJnuJd2qNT3hbN+qYU633d4U2\n\tzBYPGtpuhwDqzR9Q/W8xynj7HWQme0BV+zVaWdP/i0TYe3qgnP7+YjRVpz7aru70Si2b\n\tMF6YDSTWzzX0W4UYli24N1QPuxdz9eAUdoVL1X/6GdoadgeOUT8ApooUKP78AshHUGRl\n\t+IXQ==","X-Gm-Message-State":"AMCzsaVy6IkqODZd3Tmfu4N1v3F9m9HDu8DrVnYoVEGUTBfFa3gQxuBs\n\tdBDFy/j78wUhz7fjOCOvYVmTLw==","X-Google-Smtp-Source":"AOwi7QAFM+DjbUL80/SSAtgp+YtTpixGLsIPVJFSVgAT2vAxkmWVwSzVQ3p9J2AfioOkLgsuTzE1gQ==","X-Received":"by 10.28.109.220 with SMTP id b89mr12519797wmi.30.1507652535104; \n\tTue, 10 Oct 2017 09:22:15 -0700 (PDT)","To":"=?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>,\n\tqemu-devel@nongnu.org","References":"<20170919165226.23022-1-marcandre.lureau@redhat.com>\n\t<20170919165226.23022-26-marcandre.lureau@redhat.com>","From":"Paolo Bonzini <pbonzini@redhat.com>","Message-ID":"<7d512cc6-ecbb-7cef-2b4c-36441b5ee614@redhat.com>","Date":"Tue, 10 Oct 2017 18:22:12 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<20170919165226.23022-26-marcandre.lureau@redhat.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"8bit","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"74.125.82.51","Subject":"Re: [Qemu-devel] [PATCH v2 25/27] libvhost-user: add glib source\n\thelper","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"f4bug@amsat.org, changpeng.liu@intel.com, felipe@nutanix.com","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1783888,"web_url":"http://patchwork.ozlabs.org/comment/1783888/","msgid":"<CAJ+F1CJD0H+-XkJPg-4yZm9HkO9uMa25Erdu6_c=UFXw5cd2qg@mail.gmail.com>","list_archive_url":null,"date":"2017-10-10T16:25:19","subject":"Re: [Qemu-devel] [PATCH v2 25/27] libvhost-user: add glib source\n\thelper","submitter":{"id":6442,"url":"http://patchwork.ozlabs.org/api/people/6442/","name":"Marc-André Lureau","email":"marcandre.lureau@gmail.com"},"content":"On Tue, Oct 10, 2017 at 6:22 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:\n> On 19/09/2017 18:52, Marc-André Lureau wrote:\n>> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>\n> Maybe a few lines would help here, like\n>\n> This file implements a bridge from the vu_init API of libvhost-user to\n> GSource, so that libvhost-user can be used inside a GLib main loop.\n>\n\nIndeed, added.\n\n> Paolo\n>\n>> ---\n>>  contrib/libvhost-user/libvhost-user-glib.h |  32 ++++++\n>>  contrib/libvhost-user/libvhost-user-glib.c | 154 +++++++++++++++++++++++++++++\n>>  contrib/libvhost-user/Makefile.objs        |   2 +-\n>>  3 files changed, 187 insertions(+), 1 deletion(-)\n>>  create mode 100644 contrib/libvhost-user/libvhost-user-glib.h\n>>  create mode 100644 contrib/libvhost-user/libvhost-user-glib.c\n>>\n>> diff --git a/contrib/libvhost-user/libvhost-user-glib.h b/contrib/libvhost-user/libvhost-user-glib.h\n>> new file mode 100644\n>> index 0000000000..6b2110b94c\n>> --- /dev/null\n>> +++ b/contrib/libvhost-user/libvhost-user-glib.h\n>> @@ -0,0 +1,32 @@\n>> +/*\n>> + * Vhost User library\n>> + *\n>> + * Copyright (c) 2016 Nutanix Inc. All rights reserved.\n>> + * Copyright (c) 2017 Red Hat, Inc.\n>> + *\n>> + * Authors:\n>> + *  Marc-André Lureau <mlureau@redhat.com>\n>> + *  Felipe Franciosi <felipe@nutanix.com>\n>> + *\n>> + * This work is licensed under the terms of the GNU GPL, version 2 or\n>> + * later.  See the COPYING file in the top-level directory.\n>> + */\n>> +\n>> +#ifndef LIBVHOST_USER_GLIB_H\n>> +#define LIBVHOST_USER_GLIB_H\n>> +\n>> +#include <glib.h>\n>> +#include \"libvhost-user.h\"\n>> +\n>> +typedef struct VugDev {\n>> +    VuDev parent;\n>> +\n>> +    GHashTable *fdmap; /* fd -> gsource */\n>> +    GSource *src;\n>> +} VugDev;\n>> +\n>> +void vug_init(VugDev *dev, int socket,\n>> +              vu_panic_cb panic, const VuDevIface *iface);\n>> +void vug_deinit(VugDev *dev);\n>> +\n>> +#endif /* LIBVHOST_USER_GLIB_H */\n>> diff --git a/contrib/libvhost-user/libvhost-user-glib.c b/contrib/libvhost-user/libvhost-user-glib.c\n>> new file mode 100644\n>> index 0000000000..545f089587\n>> --- /dev/null\n>> +++ b/contrib/libvhost-user/libvhost-user-glib.c\n>> @@ -0,0 +1,154 @@\n>> +/*\n>> + * Vhost User library\n>> + *\n>> + * Copyright (c) 2016 Nutanix Inc. All rights reserved.\n>> + * Copyright (c) 2017 Red Hat, Inc.\n>> + *\n>> + * Authors:\n>> + *  Marc-André Lureau <mlureau@redhat.com>\n>> + *  Felipe Franciosi <felipe@nutanix.com>\n>> + *\n>> + * This work is licensed under the terms of the GNU GPL, version 2 or\n>> + * later.  See the COPYING file in the top-level directory.\n>> + */\n>> +\n>> +#include \"qemu/osdep.h\"\n>> +\n>> +#include \"libvhost-user-glib.h\"\n>> +\n>> +/* glib event loop integration for libvhost-user and misc callbacks */\n>> +\n>> +G_STATIC_ASSERT((int)G_IO_IN == (int)VU_WATCH_IN);\n>> +G_STATIC_ASSERT((int)G_IO_OUT == (int)VU_WATCH_OUT);\n>> +G_STATIC_ASSERT((int)G_IO_PRI == (int)VU_WATCH_PRI);\n>> +G_STATIC_ASSERT((int)G_IO_ERR == (int)VU_WATCH_ERR);\n>> +G_STATIC_ASSERT((int)G_IO_HUP == (int)VU_WATCH_HUP);\n>> +\n>> +typedef struct VugSrc {\n>> +    GSource parent;\n>> +    VuDev *dev;\n>> +    GPollFD gfd;\n>> +} VugSrc;\n>> +\n>> +static gboolean\n>> +vug_src_prepare(GSource *gsrc, gint *timeout)\n>> +{\n>> +    g_assert(timeout);\n>> +\n>> +    *timeout = -1;\n>> +    return FALSE;\n>> +}\n>> +\n>> +static gboolean\n>> +vug_src_check(GSource *gsrc)\n>> +{\n>> +    VugSrc *src = (VugSrc *)gsrc;\n>> +\n>> +    g_assert(src);\n>> +\n>> +    return src->gfd.revents & src->gfd.events;\n>> +}\n>> +\n>> +static gboolean\n>> +vug_src_dispatch(GSource *gsrc, GSourceFunc cb, gpointer data)\n>> +{\n>> +    VugSrc *src = (VugSrc *)gsrc;\n>> +\n>> +    g_assert(src);\n>> +\n>> +    ((vu_watch_cb)cb)(src->dev, src->gfd.revents, data);\n>> +\n>> +    return G_SOURCE_CONTINUE;\n>> +}\n>> +\n>> +static GSourceFuncs vug_src_funcs = {\n>> +    vug_src_prepare,\n>> +    vug_src_check,\n>> +    vug_src_dispatch,\n>> +    NULL\n>> +};\n>> +\n>> +static GSource *\n>> +vug_source_new(VuDev *dev, int fd, GIOCondition cond,\n>> +               vu_watch_cb vu_cb, gpointer data)\n>> +{\n>> +    GSource *gsrc;\n>> +    VugSrc *src;\n>> +    guint id;\n>> +\n>> +    g_assert(dev);\n>> +    g_assert(fd >= 0);\n>> +    g_assert(vu_cb);\n>> +\n>> +    gsrc = g_source_new(&vug_src_funcs, sizeof(VugSrc));\n>> +    g_source_set_callback(gsrc, (GSourceFunc)vu_cb, data, NULL);\n>> +    src = (VugSrc *)gsrc;\n>> +    src->dev = dev;\n>> +    src->gfd.fd = fd;\n>> +    src->gfd.events = cond;\n>> +\n>> +    g_source_add_poll(gsrc, &src->gfd);\n>> +    id = g_source_attach(gsrc, NULL);\n>> +    g_assert(id);\n>> +    g_source_unref(gsrc);\n>> +\n>> +    return gsrc;\n>> +}\n>> +\n>> +static void\n>> +set_watch(VuDev *vu_dev, int fd, int vu_evt, vu_watch_cb cb, void *pvt)\n>> +{\n>> +    GSource *src;\n>> +    VugDev *dev;\n>> +\n>> +    g_assert(vu_dev);\n>> +    g_assert(fd >= 0);\n>> +    g_assert(cb);\n>> +\n>> +    dev = container_of(vu_dev, VugDev, parent);\n>> +    src = vug_source_new(vu_dev, fd, vu_evt, cb, pvt);\n>> +    g_hash_table_replace(dev->fdmap, GINT_TO_POINTER(fd), src);\n>> +}\n>> +\n>> +static void\n>> +remove_watch(VuDev *vu_dev, int fd)\n>> +{\n>> +    VugDev *dev;\n>> +\n>> +    g_assert(vu_dev);\n>> +    g_assert(fd >= 0);\n>> +\n>> +    dev = container_of(vu_dev, VugDev, parent);\n>> +    g_hash_table_remove(dev->fdmap, GINT_TO_POINTER(fd));\n>> +}\n>> +\n>> +\n>> +static void vug_watch(VuDev *dev, int condition, void *data)\n>> +{\n>> +    if (!vu_dispatch(dev) != 0) {\n>> +        dev->panic(dev, \"Error processing vhost message\");\n>> +    }\n>> +}\n>> +\n>> +void\n>> +vug_init(VugDev *dev, int socket,\n>> +         vu_panic_cb panic, const VuDevIface *iface)\n>> +{\n>> +    g_assert(dev);\n>> +    g_assert(iface);\n>> +\n>> +    vu_init(&dev->parent, socket, panic, set_watch, remove_watch, iface);\n>> +    dev->fdmap = g_hash_table_new_full(NULL, NULL, NULL,\n>> +                                       (GDestroyNotify) g_source_destroy);\n>> +\n>> +    dev->src = vug_source_new(&dev->parent, socket, G_IO_IN, vug_watch, NULL);\n>> +}\n>> +\n>> +void\n>> +vug_deinit(VugDev *dev)\n>> +{\n>> +    g_assert(dev);\n>> +\n>> +    g_hash_table_unref(dev->fdmap);\n>> +    g_source_unref(dev->src);\n>> +}\n>> diff --git a/contrib/libvhost-user/Makefile.objs b/contrib/libvhost-user/Makefile.objs\n>> index cef1ad6e31..ef3778edd4 100644\n>> --- a/contrib/libvhost-user/Makefile.objs\n>> +++ b/contrib/libvhost-user/Makefile.objs\n>> @@ -1 +1 @@\n>> -libvhost-user-obj-y = libvhost-user.o\n>> +libvhost-user-obj-y += libvhost-user.o libvhost-user-glib.o\n>>\n>\n> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>\n>\n\nthanks","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"SGEL5p4p\"; dkim-atps=neutral"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3yBMt951mgz9tYR\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 11 Oct 2017 03:25:53 +1100 (AEDT)","from localhost ([::1]:36010 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1e1xLr-0001Ci-Pl\n\tfor incoming@patchwork.ozlabs.org; Tue, 10 Oct 2017 12:25:51 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:33028)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <marcandre.lureau@gmail.com>) id 1e1xLO-0001BV-6F\n\tfor qemu-devel@nongnu.org; Tue, 10 Oct 2017 12:25:25 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <marcandre.lureau@gmail.com>) id 1e1xLM-0007qw-SH\n\tfor qemu-devel@nongnu.org; Tue, 10 Oct 2017 12:25:22 -0400","from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:47360)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <marcandre.lureau@gmail.com>)\n\tid 1e1xLM-0007pq-Kf\n\tfor qemu-devel@nongnu.org; Tue, 10 Oct 2017 12:25:20 -0400","by mail-qt0-x244.google.com with SMTP id z50so47921152qtj.4\n\tfor <qemu-devel@nongnu.org>; Tue, 10 Oct 2017 09:25:20 -0700 (PDT)","by 10.12.178.211 with HTTP; Tue, 10 Oct 2017 09:25:19 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc:content-transfer-encoding;\n\tbh=xhMlcWP8wLni1gfBKrutD8ji41vijcama4j0id+O99U=;\n\tb=SGEL5p4p+UQkY75MYxaCnlVY1yMemYWUR98wSzgzPjrB+vemE6aLL7+4pKwpN5TaHl\n\tgUJSwKCsFiXIaVUfgvy7sZ+fa/zA67ECHBQz8aST4YIcqHDt2G3l3QVhISRFdthAx4ve\n\tFw5aHsxPA4zUCWCXOe+YfRjsklQTDzujLgxped1j+6FD3qw1eA53qbr+HtBNgTlNraVs\n\tuoEjVO0HdjprvJBS388vm5OXJQJmGnIvYJ/gE4+fVMWnV9lbAFHv0OObI0us/zqONEeG\n\tQ1OIqAdVkrazjBbI5bXCBx6tjRHWlyCESMwuWBEFBfyd6SoAwB1Fz8JsmW68LREJnodl\n\tSTQg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc:content-transfer-encoding;\n\tbh=xhMlcWP8wLni1gfBKrutD8ji41vijcama4j0id+O99U=;\n\tb=YL2WHk6IYMc8z7mxiuQ89TihEf9KJzG1aRjFXzEYeb4JDOzZLtl2GXadcuJu9LE3Bx\n\tDkg8tzT75Ai3FJ3J92WW5ZIQAO56FVCrJtJLqYoZzaIVEbDCk4phpVlfYkaXQjfU5reN\n\ttBTQEsYatqVTqVWs9LF4wheeBWyBfe5Hjx4yZXjKuziI13Fapgxh+kFDnRx0vp1QJtr6\n\tYwkmVYUmTXGtfGe5ukjKT2iZiK71TjTyCyWozTJ1niu+fuNUeYdJ+zsUGIbukkAiPchl\n\tJ3e6i0CSRJwkBSkBW2mFc/n9ZdOVQ++duqgI2jsgRiTFWeR2JLjywROJM8UFiJq2EKYu\n\teibg==","X-Gm-Message-State":"AMCzsaVFoo8XmfztTmHcCJuwaM+EvwsjBDJ9WolGtWQg9dwVX8BMza4W\n\tVEv24zauLv6MRgSZO5tpbZngC5yK5myJ/lQyoPM=","X-Google-Smtp-Source":"AOwi7QA5CxlSmMLns75eenv4FDb6XllalnGoIsjbCnF1MfAAfwZheBhCppMOaYs7Gm35sCtMbmRLUtSnssSJWSJhDIo=","X-Received":"by 10.237.62.84 with SMTP id m20mr17408161qtf.82.1507652720025; \n\tTue, 10 Oct 2017 09:25:20 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<7d512cc6-ecbb-7cef-2b4c-36441b5ee614@redhat.com>","References":"<20170919165226.23022-1-marcandre.lureau@redhat.com>\n\t<20170919165226.23022-26-marcandre.lureau@redhat.com>\n\t<7d512cc6-ecbb-7cef-2b4c-36441b5ee614@redhat.com>","From":"=?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@gmail.com>","Date":"Tue, 10 Oct 2017 18:25:19 +0200","Message-ID":"<CAJ+F1CJD0H+-XkJPg-4yZm9HkO9uMa25Erdu6_c=UFXw5cd2qg@mail.gmail.com>","To":"Paolo Bonzini <pbonzini@redhat.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"2607:f8b0:400d:c0d::244","Subject":"Re: [Qemu-devel] [PATCH v2 25/27] libvhost-user: add glib source\n\thelper","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"\"Liu, Changpeng\" <changpeng.liu@intel.com>, Felipe Franciosi\n\t<felipe@nutanix.com>, QEMU <qemu-devel@nongnu.org>, =?utf-8?q?Philipp?=\n\t=?utf-8?q?e_Mathieu-Daud=C3=A9?= <f4bug@amsat.org>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]