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>
		
			
				
	
	
		
			36 lines
		
	
	
		
			887 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			887 B
		
	
	
	
		
			C
		
	
	
	
	
	
/*
 | 
						|
 * Vhost User library
 | 
						|
 *
 | 
						|
 * Copyright (c) 2016 Nutanix Inc. All rights reserved.
 | 
						|
 * Copyright (c) 2017 Red Hat, Inc.
 | 
						|
 *
 | 
						|
 * Authors:
 | 
						|
 *  Marc-André Lureau <mlureau@redhat.com>
 | 
						|
 *  Felipe Franciosi <felipe@nutanix.com>
 | 
						|
 *
 | 
						|
 * This work is licensed under the terms of the GNU GPL, version 2 or
 | 
						|
 * later.  See the COPYING file in the top-level directory.
 | 
						|
 */
 | 
						|
 | 
						|
#ifndef LIBVHOST_USER_GLIB_H
 | 
						|
#define LIBVHOST_USER_GLIB_H
 | 
						|
 | 
						|
#include <glib.h>
 | 
						|
#include "libvhost-user.h"
 | 
						|
 | 
						|
typedef struct VugDev {
 | 
						|
    VuDev parent;
 | 
						|
 | 
						|
    GHashTable *fdmap; /* fd -> gsource */
 | 
						|
    GSource *src;
 | 
						|
} VugDev;
 | 
						|
 | 
						|
bool vug_init(VugDev *dev, uint16_t max_queues, 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 */
 |