From patchwork Tue Jul 26 19:21:49 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: 593483 Delivered-To: patch@linaro.org Received: by 2002:a5d:6682:0:0:0:0:0 with SMTP id l2csp2907705wru; Tue, 26 Jul 2022 12:57:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uvvuPe6OLjJyMaKOYNhazaXnrfDRXWo2QJ04/uChnZpKwUmEYPWVKsZla/NWxHdotWIhHU X-Received: by 2002:a37:c12:0:b0:6b5:e41a:86db with SMTP id 18-20020a370c12000000b006b5e41a86dbmr14127273qkm.435.1658865438999; Tue, 26 Jul 2022 12:57:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658865438; cv=none; d=google.com; s=arc-20160816; b=w9TKT9CAFWm1T2QJI/gIKQ+dBdDtB66xGBmkQDjH81BCPX36GCsXTAsimqwrwHg4/k pV9KZSfSutCFZKua1VigQmucDMboI7HlYYGEEa90vuB1tsEqlevd6Pqa9UoQscwSaNeR 59YQIcDJrEoxICgZCYpBLabINh61SkOrxIPXTdMDac8Qj9eUUMoxbm+++ivVWV2kyMa9 VLvA8zm9FVa90CngfH5YpdvtPUvELASoy71KKLLpVvDZdmxABjM/0T/jlpy8I5jYlB18 7orabovXQY9UNTXTZ/PGKdTIAZv/WN53RwW9S9XwAqqyhfKdzPqxT43JjiPATFXywqoB CIjA== 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=5yuBY8XhniW5U3BckTrWu3/MUge9sIzVNIAB45zhSUM=; b=ruc7U/rGeQ3LaEfMCNE7uKnVfJ05CDCOWGUeU4PMbU3WsSL+lYaB9aM7/CZudh5YwW lFzOJyWGhEgbfqfL0IL/jOqhgV7VVmAn4cEaWWVIrnK0dtXAJjOsKFU+L14e1lq0tiZj VU1nf2w4AGghpLj80/yg9fnxj+23IsfTHWWxZDX1iHBZLNvrStcfQDteOvha9fDa1udV XtqkuZWHVb7iD8uiMd1YReAUl+WwkJYHAmMU+gotxtSyZcQ/WqHbglqKToe5r8qtI1y9 QrPWeFEShWQ87e0Tr1Hva1XlxOY7HEtRTvprSJC93AZwgEYUbeHYTCHWxgusavxJEOCI h45g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aYHkGrAW; 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 j7-20020a05620a410700b006b53fe19c44si12092205qko.494.2022.07.26.12.57.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:57:18 -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=aYHkGrAW; 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]:51676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQgA-0000Mi-HT for patch@linaro.org; Tue, 26 Jul 2022 15:57:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQ8F-0003No-P4 for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:16 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:40548) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQ8E-0002Gz-4p for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:15 -0400 Received: by mail-wr1-x431.google.com with SMTP id m17so21167266wrw.7 for ; Tue, 26 Jul 2022 12:22:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5yuBY8XhniW5U3BckTrWu3/MUge9sIzVNIAB45zhSUM=; b=aYHkGrAWWbmJzOEvdL6EsWf5rY3TvU1X5EE6dpqIPsw47NhrxzW/yzy9XPfdW3C8b6 dP72QJZGdWh1xuBDci+l80i8/QXQCO6JkA7hq16xQqNgyNaB3Cj6W4VipNxIg7FLdFI+ 3jY3kWIrecnk0MPCT2SE/wOliO6lJx77Pgs5Li2E+t+dMIvQ+H2YRxaviWEdBminb3op PvQ/GWI6aneYOkszsPNdUJhb8P4L7Rr95fUVt9AEcym/lRKPZa5ysYcaedzEXCWVNMRo 8Qe9Cisb+P8iVMuCmqnUiBXXGa2D9Ksbtj3HXV9RuqB5yWf25F09SSpHTNKFJBCpM82E 87gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5yuBY8XhniW5U3BckTrWu3/MUge9sIzVNIAB45zhSUM=; b=tefjm0eNX1ke9k+y16cPVzS8IrBan5/k40fJvJnSfkBozqH41O2vQAkh+BHvBmgBlF Q4E0FhqX1ER9p/mqZtMl3WpNYclD71eqYE5T4zC5MkNgoEowNgrhrh8QM5EDi5RUSYXo WwvsDrNwg/mU2POl6wKAiSnywkJXnXHsAPy0rRC44g0oljsdZc86ipQuyRR/pRF7AJHk RqmbbK+pqd+lhWFFD22yT650K1AK3mSnCZ00JXA1/kqTYOUmv45ZouiD+U3yfc3QHnpu 4u2bfppLj/SrKzodzqgk7IhqozjQnxA2kESecek1uQ2TKy+pFDV5AdlqONftAJVADSws AJAg== X-Gm-Message-State: AJIora+Y04BCQPzjqPlWyCtIDjVVRY3YSFMe8m1hqFkdKYB6Ue4A0IxA 8rxjVRFcD7dCXPYBz1Q5axzdrcP8RHwbig== X-Received: by 2002:adf:ed8d:0:b0:21e:c7fb:7945 with SMTP id c13-20020adfed8d000000b0021ec7fb7945mr158066wro.353.1658863332721; Tue, 26 Jul 2022 12:22:12 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id y2-20020a5d6142000000b0021d70a871cbsm15306184wrt.32.2022.07.26.12.21.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:22:07 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 053CF1FFCC; Tue, 26 Jul 2022 20:21:52 +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, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v3 20/21] tests/qtest: add a get_features op to vhost-user-test Date: Tue, 26 Jul 2022 20:21:49 +0100 Message-Id: <20220726192150.2435175-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x431.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 d546721f5d..28b4cf28ec 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: @@ -990,8 +993,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) { @@ -1020,6 +1036,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, };