From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZG6Kk-0002Tq-0e for qemu-devel@nongnu.org; Fri, 17 Jul 2015 10:09:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZG6Kf-0004nb-VQ for qemu-devel@nongnu.org; Fri, 17 Jul 2015 10:09:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44834) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZG6Kf-0004nK-Qn for qemu-devel@nongnu.org; Fri, 17 Jul 2015 10:09:45 -0400 Date: Fri, 17 Jul 2015 17:09:41 +0300 From: "Michael S. Tsirkin" Message-ID: <1437142095-20217-5-git-send-email-mst@redhat.com> References: <1437142095-20217-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1437142095-20217-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PATCH 4/4] vhost-user: unit test for new messages List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , haifeng.lin@huawei.com, thibaut.collet@6wind.com, Nikolay Nikolaev , Gonglei , marcandre.lureau@gmail.com, Stefan Hajnoczi , fbl@redhat.com, changchun.ouyang@intel.com Data is empty for now, but do make sure master sets the new feature bit flag. Signed-off-by: Michael S. Tsirkin --- tests/vhost-user-test.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 75fedf0..228acb6 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -53,6 +53,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, @@ -69,6 +71,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; @@ -293,11 +297,26 @@ 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); break; + case VHOST_USER_GET_VRING_BASE: /* send back vring base to qemu */ msg.flags |= VHOST_USER_REPLY_MASK; -- MST