From patchwork Fri Feb 13 12:00:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linhaifeng X-Patchwork-Id: 439489 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 766951402D6 for ; Fri, 13 Feb 2015 23:01:25 +1100 (AEDT) Received: from localhost ([::1]:54667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMEvz-0008Qr-2S for incoming@patchwork.ozlabs.org; Fri, 13 Feb 2015 07:01:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47556) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMEvb-0007rk-JC for qemu-devel@nongnu.org; Fri, 13 Feb 2015 07:01:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YMEvW-0005fq-2O for qemu-devel@nongnu.org; Fri, 13 Feb 2015 07:00:59 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:56969) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMEvV-0005eX-DN for qemu-devel@nongnu.org; Fri, 13 Feb 2015 07:00:54 -0500 Received: from 172.24.2.119 (EHLO szxeml430-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BBX14648; Fri, 13 Feb 2015 20:00:41 +0800 (CST) Received: from localhost (10.177.19.115) by szxeml430-hub.china.huawei.com (10.82.67.185) with Microsoft SMTP Server id 14.3.158.1; Fri, 13 Feb 2015 20:00:35 +0800 From: linhaifeng To: Date: Fri, 13 Feb 2015 20:00:30 +0800 Message-ID: <1423828831-12152-3-git-send-email-haifeng.lin@huawei.com> X-Mailer: git-send-email 1.8.5.2.msysgit.0 In-Reply-To: <1423828831-12152-1-git-send-email-haifeng.lin@huawei.com> References: <1423828831-12152-1-git-send-email-haifeng.lin@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.19.115] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.54DDE769.00A4, ss=1, re=0.001, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: e0ba4a1ad8f2a1efff66dc4960d5234a X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.66 Cc: mst@redhat.com Subject: [Qemu-devel] [PATCH v1 2/3] vhost-user:update the version to 0x6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Linhaifeng 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 --- 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) {