vhost-user: verify that number of queues is non-zero
authorVictor Kaplansky <victork@redhat.com>
Tue, 1 Dec 2015 13:32:26 +0000 (15:32 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 2 Dec 2015 14:42:27 +0000 (16:42 +0200)
Fix QEMU crash when -netdev type=vhost-user,queues=n is passed
with zero number of queues.

Signed-off-by: Victor Kaplansky <victork@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
net/vhost-user.c

index 5071602e9b8b9e33ed2866c5ee7ca8d358d016ed..b368a9021922ec2896d7d4121eb9f30fd06e58df 100644 (file)
@@ -316,6 +316,11 @@ int net_init_vhost_user(const NetClientOptions *opts, const char *name,
     }
 
     queues = vhost_user_opts->has_queues ? vhost_user_opts->queues : 1;
+    if (queues < 1) {
+        error_setg(errp,
+                   "vhost-user number of queues must be bigger than zero");
+        return -1;
+    }
 
     return net_vhost_user_init(peer, "vhost_user", name, chr, queues);
 }