diff options
author | Changchun Ouyang <changchun.ouyang@intel.com> | 2015-09-23 12:20:01 +0800 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2015-09-24 16:27:53 +0300 |
commit | 7263a0ad7899994b719ebed736a1119cc2e08110 (patch) | |
tree | 6e832134bdf7c95b2a8ba0e9f03b47c0f7a216b5 /hw/virtio | |
parent | b931bfbf042983f311b3b09894d8030b2755a638 (diff) | |
download | qemu-7263a0ad7899994b719ebed736a1119cc2e08110.zip qemu-7263a0ad7899994b719ebed736a1119cc2e08110.tar.gz qemu-7263a0ad7899994b719ebed736a1119cc2e08110.tar.bz2 |
vhost-user: add a new message to disable/enable a specific virt queue.
Add a new message, VHOST_USER_SET_VRING_ENABLE, to enable or disable
a specific virt queue, which is similar to attach/detach queue for
tap device.
virtio driver on guest doesn't have to use max virt queue pair, it
could enable any number of virt queue ranging from 1 to max virt
queue pair.
Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
Tested-by: Marcel Apfelbaum <marcel@redhat.com>
Diffstat (limited to 'hw/virtio')
-rw-r--r-- | hw/virtio/vhost-user.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index e42fde6..b11c0d2 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -48,6 +48,7 @@ typedef enum VhostUserRequest { VHOST_USER_GET_PROTOCOL_FEATURES = 15, VHOST_USER_SET_PROTOCOL_FEATURES = 16, VHOST_USER_GET_QUEUE_NUM = 17, + VHOST_USER_SET_VRING_ENABLE = 18, VHOST_USER_MAX } VhostUserRequest; @@ -290,6 +291,7 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request, case VHOST_USER_SET_VRING_NUM: case VHOST_USER_SET_VRING_BASE: + case VHOST_USER_SET_VRING_ENABLE: memcpy(&msg.state, arg, sizeof(struct vhost_vring_state)); msg.size = sizeof(m.state); break; @@ -406,6 +408,22 @@ static int vhost_user_init(struct vhost_dev *dev, void *opaque) return 0; } +static int vhost_user_set_vring_enable(struct vhost_dev *dev, int enable) +{ + struct vhost_vring_state state = { + .index = dev->vq_index, + .num = enable, + }; + + assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER); + + if (!(dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_MQ))) { + return -1; + } + + return vhost_user_call(dev, VHOST_USER_SET_VRING_ENABLE, &state); +} + static int vhost_user_cleanup(struct vhost_dev *dev) { assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER); @@ -428,4 +446,5 @@ const VhostOps user_ops = { .vhost_backend_init = vhost_user_init, .vhost_backend_cleanup = vhost_user_cleanup, .vhost_backend_get_vq_index = vhost_user_get_vq_index, + .vhost_backend_set_vring_enable = vhost_user_set_vring_enable, }; |