From patchwork Fri Feb 13 13:45:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linhaifeng X-Patchwork-Id: 439500 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 03FF01402EA for ; Sat, 14 Feb 2015 00:46:29 +1100 (AEDT) Received: from localhost ([::1]:55570 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMGZe-0004c4-DF for incoming@patchwork.ozlabs.org; Fri, 13 Feb 2015 08:46:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMGZJ-0004Cl-3y for qemu-devel@nongnu.org; Fri, 13 Feb 2015 08:46:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YMGZE-0000iI-8b for qemu-devel@nongnu.org; Fri, 13 Feb 2015 08:46:05 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:13221) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMGZD-0000hZ-EI for qemu-devel@nongnu.org; Fri, 13 Feb 2015 08:46:00 -0500 Received: from 172.24.2.119 (EHLO szxeml428-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CHG55752; Fri, 13 Feb 2015 21:45:49 +0800 (CST) Received: from localhost (10.177.19.115) by szxeml428-hub.china.huawei.com (10.82.67.183) with Microsoft SMTP Server id 14.3.158.1; Fri, 13 Feb 2015 21:45:43 +0800 From: linhaifeng To: Date: Fri, 13 Feb 2015 21:45:38 +0800 Message-ID: <1423835139-9648-3-git-send-email-haifeng.lin@huawei.com> X-Mailer: git-send-email 1.8.5.2.msysgit.0 In-Reply-To: <1423835139-9648-1-git-send-email-haifeng.lin@huawei.com> References: <1423835139-9648-1-git-send-email-haifeng.lin@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.19.115] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.65 Cc: mst@redhat.com Subject: [Qemu-devel] [PATCH v2 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) {