mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
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>
This commit is contained in:
parent
db68f4ff06
commit
6f5fd83788
9 changed files with 105 additions and 51 deletions
|
@ -19,6 +19,10 @@
|
|||
|
||||
#define VUS_ISCSI_INITIATOR "iqn.2016-11.com.nutanix:vhost-user-scsi"
|
||||
|
||||
enum {
|
||||
VHOST_USER_SCSI_MAX_QUEUES = 8,
|
||||
};
|
||||
|
||||
typedef struct VusIscsiLun {
|
||||
struct iscsi_context *iscsi_ctx;
|
||||
int iscsi_lun;
|
||||
|
@ -231,11 +235,6 @@ static void vus_proc_req(VuDev *vu_dev, int idx)
|
|||
|
||||
gdev = container_of(vu_dev, VugDev, parent);
|
||||
vdev_scsi = container_of(gdev, VusDev, parent);
|
||||
if (idx < 0 || idx >= VHOST_MAX_NR_VIRTQUEUE) {
|
||||
g_warning("VQ Index out of range: %d", idx);
|
||||
vus_panic_cb(vu_dev, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
vq = vu_get_queue(vu_dev, idx);
|
||||
if (!vq) {
|
||||
|
@ -295,12 +294,6 @@ static void vus_queue_set_started(VuDev *vu_dev, int idx, bool started)
|
|||
|
||||
assert(vu_dev);
|
||||
|
||||
if (idx < 0 || idx >= VHOST_MAX_NR_VIRTQUEUE) {
|
||||
g_warning("VQ Index out of range: %d", idx);
|
||||
vus_panic_cb(vu_dev, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
vq = vu_get_queue(vu_dev, idx);
|
||||
|
||||
if (idx == 0 || idx == 1) {
|
||||
|
@ -398,7 +391,11 @@ int main(int argc, char **argv)
|
|||
goto err;
|
||||
}
|
||||
|
||||
vug_init(&vdev_scsi->parent, csock, vus_panic_cb, &vus_iface);
|
||||
if (!vug_init(&vdev_scsi->parent, VHOST_USER_SCSI_MAX_QUEUES, csock,
|
||||
vus_panic_cb, &vus_iface)) {
|
||||
g_printerr("Failed to initialize libvhost-user-glib\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
g_main_loop_run(vdev_scsi->loop);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue