qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH v2 2/3] vhost-user:update the version to 0x6


From: linhaifeng
Subject: [Qemu-devel] [PATCH v2 2/3] vhost-user:update the version to 0x6
Date: Fri, 13 Feb 2015 21:45:38 +0800

From: Linhaifeng <address@hidden>

We not need the VHOST_USER_REPLY_MASK so the base version now is 0x5.
  - update the version to 0x6.
  - change the name form flag to version.

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

diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index aefe0bb..d56115a 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -59,10 +59,7 @@ typedef struct VhostUserMemory {
 
 typedef struct VhostUserMsg {
     VhostUserRequest request;
-
-#define VHOST_USER_VERSION_MASK     (0x3)
-#define VHOST_USER_REPLY_MASK       (0x1<<2)
-    uint32_t flags;
+    uint32_t version;
     uint32_t size; /* the following payload size */
     union {
 #define VHOST_USER_VRING_IDX_MASK   (0xff)
@@ -74,15 +71,18 @@ typedef struct VhostUserMsg {
     };
 } QEMU_PACKED VhostUserMsg;
 
+static uint32_t slave_version;
 static VhostUserMsg m __attribute__ ((unused));
 #define VHOST_USER_HDR_SIZE (sizeof(m.request) \
-                            + sizeof(m.flags) \
+                            + sizeof(m.version) \
                             + sizeof(m.size))
 
 #define VHOST_USER_PAYLOAD_SIZE (sizeof(m) - VHOST_USER_HDR_SIZE)
 
-/* The version of the protocol we support */
-#define VHOST_USER_VERSION    (0x1)
+/* The version of the protocol we support.
+ * Slaves' version should maller than  VHOST_USER_VERSION.
+ */
+#define VHOST_USER_VERSION    (0x6)
 
 static bool ioeventfd_enabled(void)
 {
@@ -134,12 +134,12 @@ static int vhost_user_read(struct vhost_dev *dev, 
VhostUserMsg *msg)
     }
 
     /* validate received flags */
-    if (msg->flags != (VHOST_USER_REPLY_MASK | VHOST_USER_VERSION)) {
-        error_report("Failed to read msg header."
-                " Flags 0x%x instead of 0x%x.\n", msg->flags,
-                VHOST_USER_REPLY_MASK | VHOST_USER_VERSION);
+    if (msg->version > VHOST_USER_VERSION) {
+        error_report("Invalid version 0x%x.\n"
+                "Vhost user version is 0x%x", msg->version, 
VHOST_USER_VERSION);
         goto fail;
     }
+    slave_version = msg->version;
 
     /* validate message size is sane */
     if (msg->size > VHOST_USER_PAYLOAD_SIZE) {
@@ -195,7 +195,7 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned 
long int request,
 
     msg_request = vhost_user_request_translate(request);
     msg.request = msg_request;
-    msg.flags = VHOST_USER_VERSION;
+    msg.version = VHOST_USER_VERSION;
     msg.size = 0;
 
     switch (request) {
-- 
1.7.12.4





reply via email to

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