diff options
author | Ouyang Changchun <changchun.ouyang@intel.com> | 2015-05-28 09:23:06 +0800 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2015-06-01 14:18:55 +0200 |
commit | 830d70db692e374b55555f4407f96a1ceefdcc97 (patch) | |
tree | 3b10c88b7e16ff9db59d3eb253d0a2d6b7819aac /net/vhost-user.c | |
parent | 019a3edbb25f1571e876f8af1ce4c55412939e5d (diff) |
vhost-user: add multi queue support
Based on patch by Nikolay Nikolaev:
Vhost-user will implement the multi queue support in a similar way
to what vhost already has - a separate thread for each queue.
To enable the multi queue functionality - a new command line parameter
"queues" is introduced for the vhost-user netdev.
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'net/vhost-user.c')
-rw-r--r-- | net/vhost-user.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/net/vhost-user.c b/net/vhost-user.c index 11899c53c0..8d2672846f 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -121,35 +121,39 @@ static void net_vhost_user_event(void *opaque, int event) case CHR_EVENT_OPENED: vhost_user_start(s); net_vhost_link_down(s, false); - error_report("chardev \"%s\" went up", s->chr->label); + error_report("chardev \"%s\" went up", s->nc.info_str); break; case CHR_EVENT_CLOSED: net_vhost_link_down(s, true); vhost_user_stop(s); - error_report("chardev \"%s\" went down", s->chr->label); + error_report("chardev \"%s\" went down", s->nc.info_str); break; } } static int net_vhost_user_init(NetClientState *peer, const char *device, - const char *name, CharDriverState *chr) + const char *name, CharDriverState *chr, + uint32_t queues) { NetClientState *nc; VhostUserState *s; + int i; - nc = qemu_new_net_client(&net_vhost_user_info, peer, device, name); + for (i = 0; i < queues; i++) { + nc = qemu_new_net_client(&net_vhost_user_info, peer, device, name); - snprintf(nc->info_str, sizeof(nc->info_str), "vhost-user to %s", - chr->label); + snprintf(nc->info_str, sizeof(nc->info_str), "vhost-user%d to %s", + i, chr->label); - s = DO_UPCAST(VhostUserState, nc, nc); + s = DO_UPCAST(VhostUserState, nc, nc); - /* We don't provide a receive callback */ - s->nc.receive_disabled = 1; - s->chr = chr; - - qemu_chr_add_handlers(s->chr, NULL, NULL, net_vhost_user_event, s); + /* We don't provide a receive callback */ + s->nc.receive_disabled = 1; + s->chr = chr; + s->nc.queue_index = i; + qemu_chr_add_handlers(s->chr, NULL, NULL, net_vhost_user_event, s); + } return 0; } @@ -226,6 +230,7 @@ int net_init_vhost_user(const NetClientOptions *opts, const char *name, NetClientState *peer, Error **errp) { /* FIXME error_setg(errp, ...) on failure */ + uint32_t queues; const NetdevVhostUserOptions *vhost_user_opts; CharDriverState *chr; @@ -244,6 +249,12 @@ int net_init_vhost_user(const NetClientOptions *opts, const char *name, return -1; } + /* number of queues for multiqueue */ + if (vhost_user_opts->has_queues) { + queues = vhost_user_opts->queues; + } else { + queues = 1; + } - return net_vhost_user_init(peer, "vhost_user", name, chr); + return net_vhost_user_init(peer, "vhost_user", name, chr, queues); } |