diff options
author | Stefan Hajnoczi | 2019-06-26 09:48:13 +0200 |
---|---|---|
committer | Michael S. Tsirkin | 2019-07-04 23:00:32 +0200 |
commit | 6f5fd837889814e57a4bb473bf80ce08e355a12d (patch) | |
tree | 94a9980f0db7259a68621d91d65cc5a83477663d /contrib/libvhost-user/libvhost-user-glib.c | |
parent | libvhost-user: add vmsg_set_reply_u64() helper (diff) | |
download | qemu-6f5fd837889814e57a4bb473bf80ce08e355a12d.tar.gz qemu-6f5fd837889814e57a4bb473bf80ce08e355a12d.tar.xz qemu-6f5fd837889814e57a4bb473bf80ce08e355a12d.zip |
libvhost-user: support many virtqueues
Currently libvhost-user is hardcoded to at most 8 virtqueues. The
device backend should decide the number of virtqueues, not
libvhost-user. This is important for multiqueue device backends where
the guest driver needs an accurate number of virtqueues.
This change breaks libvhost-user and libvhost-user-glib API stability.
There is no stability guarantee yet, so make this change now and update
all in-tree library users.
This patch touches up vhost-user-blk, vhost-user-gpu, vhost-user-input,
vhost-user-scsi, and vhost-user-bridge. If the device has a fixed
number of queues that exact number is used. Otherwise the previous
default of 8 virtqueues is used.
vu_init() and vug_init() can now fail if malloc() returns NULL. I
considered aborting with an error in libvhost-user but it should be safe
to instantiate new vhost-user instances at runtime without risk of
terminating the process. Therefore callers need to handle the vu_init()
failure now.
vhost-user-blk and vhost-user-scsi duplicate virtqueue index checks that
are already performed by libvhost-user. This code would need to be
modified to use max_queues but remove it completely instead since it's
redundant.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20190626074815.19994-3-stefanha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'contrib/libvhost-user/libvhost-user-glib.c')
-rw-r--r-- | contrib/libvhost-user/libvhost-user-glib.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/contrib/libvhost-user/libvhost-user-glib.c b/contrib/libvhost-user/libvhost-user-glib.c index 42660a1b36..99edd2f3de 100644 --- a/contrib/libvhost-user/libvhost-user-glib.c +++ b/contrib/libvhost-user/libvhost-user-glib.c @@ -131,18 +131,24 @@ static void vug_watch(VuDev *dev, int condition, void *data) } } -void -vug_init(VugDev *dev, int socket, +bool +vug_init(VugDev *dev, uint16_t max_queues, int socket, vu_panic_cb panic, const VuDevIface *iface) { g_assert(dev); g_assert(iface); - vu_init(&dev->parent, socket, panic, set_watch, remove_watch, iface); + if (!vu_init(&dev->parent, max_queues, socket, panic, set_watch, + remove_watch, iface)) { + return false; + } + 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); + + return true; } void |