From patchwork Tue Aug 2 09:50:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594855 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4207429maz; Tue, 2 Aug 2022 03:11:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vA4TDdcx2vvtW8EXbNIYNrW+0S0kZ9nBYWXnzHLmcQ6kgirHSBTAaCZqXi6x3MPod+cSqQ X-Received: by 2002:a05:620a:2053:b0:6b5:ee04:9b6f with SMTP id d19-20020a05620a205300b006b5ee049b6fmr14856353qka.731.1659435085011; Tue, 02 Aug 2022 03:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659435085; cv=none; d=google.com; s=arc-20160816; b=G1C4Oi3ZM5NdqtGE6qp6+AnH3q2nCR+MEEN5Zl/jR+3cEanblf7ys2Ak3lKSYy50h9 QoojNtHy8sbwzqQI6Ks247C0vrotphAOYnng4Km9sHJV4mq/EGGxvRmIdc5Cn6Y8XH4J AAbH43rlPGhMK0WrsNeZ++NBmF6uUqJL1jxunVR3H0vd3W+VGHVApPWufPJ8pu9Fvkg5 J60ISBB3UHwssbFTiGSpAWh+hYaMSiVIPB1WCqHTCwCckbDS04zc826UvopyApUZeXKE 1fxmKnOqpSb0gBJQFdAbdDSKyoCacgy8ZJ3GP05esIjVsP8CcL2rPSog7WEFVAkoOwgT qDSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vdim50/4QWM59eJmuqXHbqgfci2iCoUWAD1+T4jr3FI=; b=iqKZkDObbeteoZohpIvucCIiq9gdbZC9d0mOPQrw4g1/kTwibfjbo3CQLrh78Q+ABH U2tvUpa0gY7B5h2jOxSpc4duJ3ZZbzMMoclr9dDixqADdSVCa0GrMeUZIlJ/EGf9W/ba jUld614Sy/CcO357OOE1+cn1c3DNC3RQkrZrce7RWskW+v3LE0cLHpKW9iL9V0LtXGSV BzLIGQkZtibkjfKP6JQ6cAavkrrT3eOgy8JEwm1Mgjis5kLt1iyho3YDv/wsbgmjDJNA 43/oCLpxZtwkTitpwsQnMnjRC/basFsvCNcaF2bNQwEo/C66ZeyfVlN21RKjMDdt0XFW q+Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gYsUZovi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r4-20020ac87ee4000000b0031eb245dfe2si7073937qtc.381.2022.08.02.03.11.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 03:11:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gYsUZovi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIos0-0004zY-Je for patch@linaro.org; Tue, 02 Aug 2022 06:11:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIohP-00058t-16 for qemu-devel@nongnu.org; Tue, 02 Aug 2022 06:00:27 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:34344) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIohN-0006QU-3j for qemu-devel@nongnu.org; Tue, 02 Aug 2022 06:00:26 -0400 Received: by mail-wr1-x432.google.com with SMTP id j1so8815749wrw.1 for ; Tue, 02 Aug 2022 03:00:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=vdim50/4QWM59eJmuqXHbqgfci2iCoUWAD1+T4jr3FI=; b=gYsUZoviNG20Yp8iVFGsqKJVFG6KjmJvAV+gErCRnbn1Ez/vfOtE3QE9U/Xxk1GEXh LAOZleDGvgqDorkSk2czqVF4B/l51jO+wLKlExweGpWZaQjSSVeoRcH/Sj/3yJVrmw2q dkRSpSqUeIRYNinFUVxqm68TnLNUiyx1YvtwpWYbJzamsRTQNaECO4EUr0sCLJVUJAPz e8DdBkhdZAfJXzRGGA67lpSJCdD1SkyyliMzfRUYfiyDK3UvxnZFaXTw4hyroTnkqLgH ZTaG3SUe32YHNhuMpwehFtqbdLMJvDe9YI5Kripl0e7y4p8g5HSYT4CvQvd0PjN0+EL9 SwFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=vdim50/4QWM59eJmuqXHbqgfci2iCoUWAD1+T4jr3FI=; b=JvbjA7i7VwRmsr5RDHesFCo1Ze+44xCHL1f8gg5Zj346Itm91XFVJdPqsUjVTO6eUL dFi6BctDQQ+/yD2MX5BgzBOhC1aFv1kLcE7MJFQK17Qc9ueEd81YjYg7Lc2U5wfre9/H zjvyM8mdyRZjvQ4FnehLPDuvUeye3EEqXDy6ZmS4r5NUk8G7yVGhnJaPAdCpTJZZSDRa +mXq+Hm4poSSzfb2nIHtuEkXLy9795zndm+UpF2x9Usmtcy1Z7HOsBgZItTjw5Dq1rCb v41vXpdVK68J0Gfn+g581RweYBD4rWAfDju1svQd+7ZWRhNaomNBmXs0nukp+YADRTWR cUDA== X-Gm-Message-State: ACgBeo2zLYL51Q+os1zR6WDwbicTYyz8NxEYcUtTzZxjIu9CQ47kWL0j DyyEEgTYIkDAEo5HY6yUSjpVlA== X-Received: by 2002:adf:fb83:0:b0:21d:649a:72d9 with SMTP id a3-20020adffb83000000b0021d649a72d9mr12115328wrr.688.1659434423706; Tue, 02 Aug 2022 03:00:23 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id u13-20020a05600c19cd00b003a2e1883a27sm28459213wmq.18.2022.08.02.03.00.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 03:00:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7C4BC1FFCD; Tue, 2 Aug 2022 10:50:12 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 21/22] tests/qtest: add a get_features op to vhost-user-test Date: Tue, 2 Aug 2022 10:50:09 +0100 Message-Id: <20220802095010.3330793-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" As we expand this test for more virtio devices we will need to support different feature sets. Add a mandatory op field to fetch the list of features needed for the test itself. Signed-off-by: Alex Bennée --- tests/qtest/vhost-user-test.c | 37 +++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 61980bfc6a..fe46e28cf2 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -171,10 +171,11 @@ struct vhost_user_ops { const char *chr_opts); /* VHOST-USER commands. */ + uint64_t (*get_features)(TestServer *s); void (*set_features)(TestServer *s, CharBackend *chr, - VhostUserMsg *msg); + VhostUserMsg *msg); void (*get_protocol_features)(TestServer *s, - CharBackend *chr, VhostUserMsg *msg); + CharBackend *chr, VhostUserMsg *msg); }; static const char *init_hugepagefs(void); @@ -338,20 +339,22 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) switch (msg.request) { case VHOST_USER_GET_FEATURES: + /* Mandatory for tests to define get_features */ + g_assert(s->vu_ops->get_features); + /* send back features to qemu */ msg.flags |= VHOST_USER_REPLY_MASK; msg.size = sizeof(m.payload.u64); - msg.payload.u64 = 0x1ULL << VHOST_F_LOG_ALL | - 0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES; - if (s->queues > 1) { - msg.payload.u64 |= 0x1ULL << VIRTIO_NET_F_MQ; - } + if (s->test_flags >= TEST_FLAGS_BAD) { msg.payload.u64 = 0; s->test_flags = TEST_FLAGS_END; + } else { + msg.payload.u64 = s->vu_ops->get_features(s); } - p = (uint8_t *) &msg; - qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size); + + qemu_chr_fe_write_all(chr, (uint8_t *) &msg, + VHOST_USER_HDR_SIZE + msg.size); break; case VHOST_USER_SET_FEATURES: @@ -993,8 +996,21 @@ static void test_multiqueue(void *obj, void *arg, QGuestAllocator *alloc) wait_for_rings_started(s, s->queues * 2); } + +static uint64_t vu_net_get_features(TestServer *s) +{ + uint64_t features = 0x1ULL << VHOST_F_LOG_ALL | + 0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES; + + if (s->queues > 1) { + features |= 0x1ULL << VIRTIO_NET_F_MQ; + } + + return features; +} + static void vu_net_set_features(TestServer *s, CharBackend *chr, - VhostUserMsg *msg) + VhostUserMsg *msg) { g_assert(msg->payload.u64 & (0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES)); if (s->test_flags == TEST_FLAGS_DISCONNECT) { @@ -1023,6 +1039,7 @@ static struct vhost_user_ops g_vu_net_ops = { .append_opts = append_vhost_net_opts, + .get_features = vu_net_get_features, .set_features = vu_net_set_features, .get_protocol_features = vu_net_get_protocol_features, };