qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RESEND Patch v1 13/37] vhost-pci-slave/msg: VHOST_USER_GET


From: Wei Wang
Subject: [Qemu-devel] [RESEND Patch v1 13/37] vhost-pci-slave/msg: VHOST_USER_GET_QUEUE_NUM
Date: Mon, 19 Dec 2016 13:58:48 +0800

Send the max supported queue num according to the device type back to
the master.

Signed-off-by: Wei Wang <address@hidden>
---
 hw/virtio/vhost-pci-slave.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/hw/virtio/vhost-pci-slave.c b/hw/virtio/vhost-pci-slave.c
index 3f35649..7f237bd 100644
--- a/hw/virtio/vhost-pci-slave.c
+++ b/hw/virtio/vhost-pci-slave.c
@@ -92,6 +92,23 @@ static void vp_slave_set_device_type(VhostUserMsg *msg)
     }
 }
 
+static int vp_slave_get_queue_num(CharBackend *chr_be, VhostUserMsg *msg)
+{
+    switch (vp_slave->dev_type) {
+    case VIRTIO_ID_NET:
+        msg->payload.u64 = VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX;
+        break;
+    default:
+        error_report("GET_QUEUE_NUM: device type %d is not supported",
+                     vp_slave->dev_type);
+        return -1;
+    }
+    msg->size = sizeof(msg->payload.u64);
+    msg->flags |= VHOST_USER_REPLY_MASK;
+
+    return vp_slave_write(chr_be, msg);
+}
+
 static int vp_slave_can_read(void *opaque)
 {
     return VHOST_USER_HDR_SIZE;
@@ -146,6 +163,12 @@ static void vp_slave_read(void *opaque, const uint8_t 
*buf, int size)
     case VHOST_USER_SET_DEVICE_ID:
         vp_slave_set_device_type(&msg);
         break;
+    case VHOST_USER_GET_QUEUE_NUM:
+        ret = vp_slave_get_queue_num(chr_be, &msg);
+        if (ret < 0) {
+            goto err_handling;
+        }
+        break;
     default:
         error_report("vhost-pci-slave does not support msg request = %d",
                      msg.request);
-- 
2.7.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]