From nobody Mon Feb 9 16:12:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1618489612; cv=none; d=zohomail.com; s=zohoarc; b=Dab9xvoO5394Ls8JBWROV6x6AiWQsvlhLNgaa4Gcgrws4D16kZxcCNfQOa0kn/TF9W2iQr0WkXw5J36lwZIvrbmnRgcCH167ZYcfTiNBVmV/+t11ubPmXlieqcW253nPyEtApsYVo5RwDPP581u1NKUUEb7wTAK8rSxFKsD4q6M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618489612; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=WU1rsuPZSbiXCb5ZUrh9An1Xj0dCMP/3YS/3/3XzJFk=; b=AHQ6EX+c76K1nd4JWbMmyKvMaXOYUSIl6lXiG49/z27rHvqMB5OS0OhOK2tKrjl5ErELv20oW0mxnFyKAOaKThtiYq8WF7cT46vDt879zA749aNf2QqM2suFMq5uDTecDCyHvooCbuut1GhVsLmkLBDnCvz5Sueq8OsE4GAwU0A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1618489612394669.5998368940806; Thu, 15 Apr 2021 05:26:52 -0700 (PDT) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-64-yFYepM-ZOua0VOq6l65ikw-1; Thu, 15 Apr 2021 08:26:47 -0400 Received: by mail-wr1-f69.google.com with SMTP id l18-20020a0560000232b02901026f4b8548so2689061wrz.10 for ; Thu, 15 Apr 2021 05:26:47 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (39.red-81-40-121.staticip.rima-tde.net. [81.40.121.39]) by smtp.gmail.com with ESMTPSA id x17sm1399684wmi.46.2021.04.15.05.26.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Apr 2021 05:26:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618489611; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WU1rsuPZSbiXCb5ZUrh9An1Xj0dCMP/3YS/3/3XzJFk=; b=NMH9F2XzumnaE3zEHUYPvf3o5kkJ8g0XsbXA/4csCYVfnvFy2m1cKaJDEVYvsVtMRFVOQp 1WjcqIM1BYC1VO0Bz2KgTaoL6d0ByXUi2rpUlER0acV5F9VykJ8GbIlrGa+BRAwhyfJ3yA BgtJHStPqplCxmSxDH396pg/iqISKmQ= X-MC-Unique: yFYepM-ZOua0VOq6l65ikw-1 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=WU1rsuPZSbiXCb5ZUrh9An1Xj0dCMP/3YS/3/3XzJFk=; b=FVyftt7GJxSxdKPQR3SCaYn1nB3XGHrt6+Uo5lHc3ppqaB5Hrf0q41tNz/zjKoZOl9 uHAIgNIn67h7MYq6wisBVoaeExHyr/++dHFG2gMLUX30KswGLiC+C9z2ejTQJxCVYcvS BFOQ3ltucVe/jOQU5/6DZ4omSF8ceDP/i7m7GHu0TVTpGym53ZZdEmZ/Gydtvirhyh17 RRqhZ3UhC0JXfjt3qDrAEakdt1Q1gP8+YruDDuJzkYDV52kNOBcthwRsxkxTy662klPu zH8lBMMg88293mQxPRxjUXBAD+QJLwzUSulnn1OQl+tBoJ/iBQvL2L09Yj6tfc/gDAYY GAlg== X-Gm-Message-State: AOAM530qNygFJgeOysiTz9TROaO5EdQttuJ0DAYE5xRlF8VFb1gNFFHS tJKYd4Hu9Kxq5P3xUPNdasF4dQbQ4k0lOWuwHQxGV5fftfsSzGO2f37oTO3MMDa1fb0H5OoOGX2 fcKEI8v1DxISzWg== X-Received: by 2002:adf:d1ce:: with SMTP id b14mr2619748wrd.159.1618489606358; Thu, 15 Apr 2021 05:26:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzB90NWbYaE7b8Gf0ZunPtbrJC+NSXfcFzScvhaN2FMv+oN+b1BXp3u+mFGGp9PD013jpJoIg== X-Received: by 2002:adf:d1ce:: with SMTP id b14mr2619727wrd.159.1618489606241; Thu, 15 Apr 2021 05:26:46 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Igor Mammedov , Markus Armbruster , Thomas Huth , Andrew Jones , qemu-arm@nongnu.org, "Michael S. Tsirkin" , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Claudio Fontana , Eric Blake , Richard Henderson , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 2/6] tests/qtest: Add qtest_has_accel() method Date: Thu, 15 Apr 2021 14:26:29 +0200 Message-Id: <20210415122633.4054644-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210415122633.4054644-1-philmd@redhat.com> References: <20210415122633.4054644-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- Since v2: - reworded (Eric) Since v1: - rename qtest_probe_accel() -> qtest_has_accel() - run with -machine none before creating QTestState --- 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 a68dcd79d44..d80c618c18d 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); =20 +/** + * 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 71e359efcd3..2156b7e3972 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -393,6 +393,35 @@ QTestState *qtest_init_with_serial(const char *extra_a= rgs, int *sock_fd) return qts; } =20 +bool qtest_has_accel(const char *accel_name) +{ + bool has_accel =3D false; + QDict *response; + QList *accels; + QListEntry *accel; + QTestState *qts; + + qts =3D qtest_initf("-accel qtest -machine none"); + response =3D qtest_qmp(qts, "{'execute': 'query-accels'}"); + accels =3D qdict_get_qlist(response, "return"); + + QLIST_FOREACH_ENTRY(accels, accel) { + QDict *accel_dict =3D qobject_to(QDict, qlist_entry_obj(accel)); + const char *name =3D qdict_get_str(accel_dict, "name"); + + if (g_str_equal(name, accel_name)) { + has_accel =3D true; + break; + } + } + qobject_unref(response); + + qtest_quit(qts); + + return has_accel; +} + + void qtest_quit(QTestState *s) { qtest_remove_abrt_handler(s); --=20 2.26.3