qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH v3 3/3] vhost-user: add reply for other messages


From: linhaifeng
Subject: [Qemu-devel] [PATCH v3 3/3] vhost-user: add reply for other messages
Date: Sun, 15 Feb 2015 13:37:03 +0800

From: Linhaifeng <address@hidden>

If slave's version bigger than 0x5 we will wait for reply.

Signed-off-by: Linhaifeng <address@hidden>
---
 hw/virtio/vhost-user.c | 42 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index d56115a..ae684b6 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -80,10 +80,17 @@ static VhostUserMsg m __attribute__ ((unused));
 #define VHOST_USER_PAYLOAD_SIZE (sizeof(m) - VHOST_USER_HDR_SIZE)
 
 /* The version of the protocol we support.
- * Slaves' version should maller than  VHOST_USER_VERSION.
+ * Slaves' version must not bigger than  VHOST_USER_VERSION.
  */
+#define VHOST_USER_BASE       (0x5)
 #define VHOST_USER_VERSION    (0x6)
 
+#define VHOST_NEED_REPLY \
+{    \
+    if (slave_version > VHOST_USER_BASE)     \
+        need_reply = 1;    \
+}
+
 static bool ioeventfd_enabled(void)
 {
     return kvm_enabled() && kvm_eventfds_enabled();
@@ -207,6 +214,8 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned 
long int request,
     case VHOST_SET_LOG_BASE:
         msg.u64 = *((__u64 *) arg);
         msg.size = sizeof(m.u64);
+
+        VHOST_NEED_REPLY;
         break;
 
     case VHOST_SET_OWNER:
@@ -244,16 +253,21 @@ static int vhost_user_call(struct vhost_dev *dev, 
unsigned long int request,
         msg.size += sizeof(m.memory.padding);
         msg.size += fd_num * sizeof(VhostUserMemoryRegion);
 
+        VHOST_NEED_REPLY;
         break;
 
     case VHOST_SET_LOG_FD:
         fds[fd_num++] = *((int *) arg);
+
+        VHOST_NEED_REPLY;
         break;
 
     case VHOST_SET_VRING_NUM:
     case VHOST_SET_VRING_BASE:
         memcpy(&msg.state, arg, sizeof(struct vhost_vring_state));
         msg.size = sizeof(m.state);
+
+        VHOST_NEED_REPLY;
         break;
 
     case VHOST_GET_VRING_BASE:
@@ -265,6 +279,8 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned 
long int request,
     case VHOST_SET_VRING_ADDR:
         memcpy(&msg.addr, arg, sizeof(struct vhost_vring_addr));
         msg.size = sizeof(m.addr);
+
+        VHOST_NEED_REPLY;
         break;
 
     case VHOST_SET_VRING_KICK:
@@ -278,6 +294,8 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned 
long int request,
         } else {
             msg.u64 |= VHOST_USER_VRING_NOFD_MASK;
         }
+
+        VHOST_NEED_REPLY;
         break;
     default:
         error_report("vhost-user trying to send unhandled ioctl\n");
@@ -315,6 +333,28 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned 
long int request,
             }
             memcpy(arg, &msg.state, sizeof(struct vhost_vring_state));
             break;
+        case VHOST_USER_SET_FEATURES:
+        case VHOST_USER_SET_LOG_BASE:
+        case VHOST_USER_SET_OWNER:
+        case VHOST_USER_RESET_OWNER:
+        case VHOST_USER_SET_MEM_TABLE:
+        case VHOST_USER_SET_LOG_FD:
+        case VHOST_USER_SET_VRING_NUM:
+        case VHOST_USER_SET_VRING_BASE:
+        case VHOST_USER_SET_VRING_ADDR:
+        case VHOST_USER_SET_VRING_KICK:
+        case VHOST_USER_SET_VRING_CALL:
+        case VHOST_USER_SET_VRING_ERR:
+            if (msg.size != sizeof(m.u64)) {
+                error_report("Received bad msg size.");
+                return -1;
+            } else {
+                if (m.u64) {
+                    error_report("Failed to handle request %d.", msg_request);
+                    return -1;
+                }
+            }
+            break;
         default:
             error_report("Received unexpected msg type.\n");
             return -1;
-- 
1.7.12.4





reply via email to

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