From patchwork Fri Jun 4 15:51:36 2021 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: 12299971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29F3CC07E94 for ; Fri, 4 Jun 2021 15:55:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E21CE613F1 for ; Fri, 4 Jun 2021 15:55:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E21CE613F1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpCA5-0006Ja-Qx for qemu-devel@archiver.kernel.org; Fri, 04 Jun 2021 11:55:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpC8R-0002Kw-14 for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:53:23 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:35599) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpC8N-0008O5-5g for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:53:22 -0400 Received: by mail-wr1-x42d.google.com with SMTP id m18so9807582wrv.2 for ; Fri, 04 Jun 2021 08:53:18 -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=TvyIlJW3PO7q09G/gvxhFxBVndq7M4s8XzLxW3dgEK0=; b=WYwIOaaIjE19ZhMLtM5SnbB16XfCcI1pHVrnlhT2fH6VApU3pTTbmhEv5Hnt+Vl/wL fifSxS9u1dpXVPAVzXQUsjsZ3DODWwGmkJU0/fT0FoaeHOKuU8bmnCrNW9JHAkGzcRRI qkZgVB9Zlatrkfp1mmUsZC6w9IlWpcaz3+O/LaIXgWysj3Ub75+wpYnDGp2uys3y8B/X gZwoKtc/1J8VyVn0/qKPiUTJmIHGxkyfbDC/iAkYz6oBlYWvJ7X/C2dTf/fAJfumqTdf /AuzUO9YYnSBiCZJFB0SlEepfQLRZ93IOULZngHbt9ignJTL+83PPV3GKYZz00opX1/6 ZxFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TvyIlJW3PO7q09G/gvxhFxBVndq7M4s8XzLxW3dgEK0=; b=CPFxquhAGFr4F/gqkimBxX8KYjx9cAYiitd5aXwOpEd+s43B8EULGTaFe3qR8omF8M Z8GOdatQBQPYmboWku/sh07q5ucGiyMGyXOzz/dyFyhG1qfDxRkRTD+pA+ApAwzsJ3Pi RyEPviVK0HeNeiZlxw51vEb0RUXm8RRpImA0w5eBqY27JmzV9xz09NeLG7Ei2P/tm3qz kCBzMi4D6gMz72n+FNlinTZsEZp5G+9bsUiqwVBgEDnDc9MQ7bzPctgz0OV406NPKt1A +RR3yggwGJ2BNWEOmFiy+KRAt1AFUGRQCXXTlh2GNZ7DtO9kRpDjHmbgRVemtdejOOH6 aC2w== X-Gm-Message-State: AOAM5334f+U7E4zJhxFLRMasQ3qOwVdl+vImEEKNWAlICcEbeWwZNOHf ZLIYfzRV6qFfwT7mESJR/O3QQA== X-Google-Smtp-Source: ABdhPJwLkU+psoJMTHeG9YajGsIX8seZ7zn7gLKg5Ih4dUVq0yaBKpbD/BShRRbSD2gFVJp5bmwh2Q== X-Received: by 2002:a5d:6b0b:: with SMTP id v11mr4489637wrw.339.1622821997592; Fri, 04 Jun 2021 08:53:17 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id m37sm482577wms.46.2021.06.04.08.53.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 08:53:14 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A239D1FF8F; Fri, 4 Jun 2021 16:53:12 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v16 03/99] qtest: Add qtest_has_accel() method Date: Fri, 4 Jun 2021 16:51:36 +0100 Message-Id: <20210604155312.15902-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210604155312.15902-1-alex.bennee@linaro.org> References: <20210604155312.15902-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42d.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Paolo Bonzini , =?utf-8?q?Alex_Be?= =?utf-8?q?nn=C3=A9e?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Introduce the qtest_has_accel() method which allows a runtime query on whether a QEMU instance has an accelerator built-in. Reviewed-by: Eric Blake Reviewed-by: Alex Bennée Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée Message-Id: <20210505125806.1263441-4-philmd@redhat.com> --- tests/qtest/libqos/libqtest.h | 8 ++++++++ tests/qtest/libqtest.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/tests/qtest/libqos/libqtest.h b/tests/qtest/libqos/libqtest.h index a68dcd79d4..d80c618c18 100644 --- a/tests/qtest/libqos/libqtest.h +++ b/tests/qtest/libqos/libqtest.h @@ -763,6 +763,14 @@ void qmp_expect_error_and_unref(QDict *rsp, const char *class); */ bool qtest_probe_child(QTestState *s); +/** + * qtest_has_accel: + * @accel_name: Accelerator name to check for. + * + * Returns: true if the accelerator is built in. + */ +bool qtest_has_accel(const char *accel_name); + /** * qtest_set_expected_status: * @s: QTestState instance to operate on. diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 825b13a44c..6bda6e1f33 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -393,6 +393,35 @@ QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd) return qts; } +bool qtest_has_accel(const char *accel_name) +{ + bool has_accel = false; + QDict *response; + QList *accels; + QListEntry *accel; + QTestState *qts; + + qts = qtest_initf("-accel qtest -machine none"); + response = qtest_qmp(qts, "{'execute': 'query-accels'}"); + accels = qdict_get_qlist(response, "return"); + + QLIST_FOREACH_ENTRY(accels, accel) { + QDict *accel_dict = qobject_to(QDict, qlist_entry_obj(accel)); + const char *name = qdict_get_str(accel_dict, "name"); + + if (g_str_equal(name, accel_name)) { + has_accel = true; + break; + } + } + qobject_unref(response); + + qtest_quit(qts); + + return has_accel; +} + + void qtest_quit(QTestState *s) { qtest_remove_abrt_handler(s);