From patchwork Fri Oct 2 13:45:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 525600 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 E27D314030F for ; Sat, 3 Oct 2015 01:28:33 +1000 (AEST) Received: from localhost ([::1]:60787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi2G7-0002pA-U6 for incoming@patchwork.ozlabs.org; Fri, 02 Oct 2015 11:28:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi0en-0003a3-JK for qemu-devel@nongnu.org; Fri, 02 Oct 2015 09:45:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zi0eh-0000mt-2S for qemu-devel@nongnu.org; Fri, 02 Oct 2015 09:45:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37229) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi0eg-0000mX-M5 for qemu-devel@nongnu.org; Fri, 02 Oct 2015 09:45:46 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 5D81EC0B64A1; Fri, 2 Oct 2015 13:45:46 +0000 (UTC) Received: from redhat.com (ovpn-116-85.ams2.redhat.com [10.36.116.85]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t92DjhtG012669; Fri, 2 Oct 2015 09:45:44 -0400 Date: Fri, 2 Oct 2015 16:45:43 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1443793405-15190-12-git-send-email-mst@redhat.com> References: <1443793405-15190-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1443793405-15190-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Marcel Apfelbaum , Peter Maydell , Yuanhan Liu , =?us-ascii?B?PT9VVEYtOD9xP01hcmMtQW5kcj1DMz1BOT0yMEx1cmVhdT89?= Subject: [Qemu-devel] [PULL 11/15] vhost-user: unit test for new messages 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 Data is empty for now, but do make sure master sets the new feature bit flag. Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- tests/vhost-user-test.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 0e04f06..87281b9 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -46,6 +46,8 @@ #define VHOST_MEMORY_MAX_NREGIONS 8 +#define VHOST_USER_F_PROTOCOL_FEATURES 30 + typedef enum VhostUserRequest { VHOST_USER_NONE = 0, VHOST_USER_GET_FEATURES = 1, @@ -62,6 +64,8 @@ typedef enum VhostUserRequest { VHOST_USER_SET_VRING_KICK = 12, VHOST_USER_SET_VRING_CALL = 13, VHOST_USER_SET_VRING_ERR = 14, + VHOST_USER_GET_PROTOCOL_FEATURES = 15, + VHOST_USER_SET_PROTOCOL_FEATURES = 16, VHOST_USER_MAX } VhostUserRequest; @@ -214,6 +218,20 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) /* send back features to qemu */ msg.flags |= VHOST_USER_REPLY_MASK; msg.size = sizeof(m.u64); + msg.u64 = 0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES; + p = (uint8_t *) &msg; + qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size); + break; + + case VHOST_USER_SET_FEATURES: + g_assert_cmpint(msg.u64 & (0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES), + !=, 0ULL); + break; + + case VHOST_USER_GET_PROTOCOL_FEATURES: + /* send back features to qemu */ + msg.flags |= VHOST_USER_REPLY_MASK; + msg.size = sizeof(m.u64); msg.u64 = 0; p = (uint8_t *) &msg; qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size);