From nobody Mon Feb 9 09:53:01 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1615915509; cv=none; d=zohomail.com; s=zohoarc; b=VGL/fjonsFyyY0NTfV04AQ325zA0+BG+G3xi8boib+ii1wLC6kDbDjrygQJOVxn2D4JNJgsxsvf0SSeT62eCTMUXQ1pYPNSECEv+wfNf9/tv8n+8hBZY6mmqlXcku05ABU52M8yf5jfR2uxXWz5OLbzmtJsdlROEd19DRAfXzyw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615915509; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=n83T+8pJtXHVyLWFyezdG65ds62knC/7EziKXgLHqlc=; b=b0pfzP/pjL5mo19dxeg/EyEt/yTuqB1XDCOtVLWvkh6xqwIhL7rgwHdUQmt1CeIbG6UpHRr2MYKq63wYKPgIxNABwndo/toOeGLMDmZQvQ7Sy43f3VnlCryXoLgxydU28kdxEx8olj3Ql6Xa1LkLzDnEUiT8d8uJE1a2S7Ndi0s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 161591550919387.67830440506486; Tue, 16 Mar 2021 10:25:09 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-480-ktN2DBgQOBCWmxBNGunMMw-1; Tue, 16 Mar 2021 13:25:04 -0400 Received: by mail-wr1-f72.google.com with SMTP id p12so14426642wrn.18 for ; Tue, 16 Mar 2021 10:25:04 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id g9sm23621457wrp.14.2021.03.16.10.25.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 10:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615915506; 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=n83T+8pJtXHVyLWFyezdG65ds62knC/7EziKXgLHqlc=; b=YrbKZUrlgIowjiG144OP4fisi3jIb1//aYAbuJ7lT1kI0vUXvl4Nk7hQ5U0O2p+ZTSJFHx UL/An0CHQEYzTsSXc9M4FK2DMxj63/WLU5Cz5PpjFzkW+icW8vIUwup+H/qz0OsGCuxf4d RZVFIWQWeC1Le49jIix61cnFvQoxgS4= X-MC-Unique: ktN2DBgQOBCWmxBNGunMMw-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=n83T+8pJtXHVyLWFyezdG65ds62knC/7EziKXgLHqlc=; b=PkvyDqwD1Y/4PJ1aytnW6dtJYvGpd3KBJNyLNDhox05BKJGrYHDHXZc2J1p77F+NZm a+h9NdrR/QEjdBwwb3p0ZKsAp0p2D9a3lfZe/F85lK7ukfBeGQwiLNwCSdXc06nNAQaf Jqmc/54eQhRLUey/clWvxRRRQ4Jr8jWcmEVuG1TSLz71yzabIhL7Q/iQULdWcHJBTaEv IwoDQfionkM+1nKJRZ5u0aDpHozGEK7xC7rAWSxb2wcAKzFlTcw4nyMuJk/wzl7xIfov XRnzCfoYo7JTzWdFI9pz3zfPSfcQd2j+jEHOPm+MmmpXH2fDCCND2M3fbCP5gBOiQMfn URpQ== X-Gm-Message-State: AOAM533H/HtTaC2g+y9dFjDWvo1pCPrrFX9StMLZXpbfavigXmUEiZrH 7jArNK73l13C3F9f73BvjLr13IfdhzLzzYC5RWiKtRL5Udjo1gvEPiKrglTZH+o98NhfSItrPtQ FbtK6sRKCQZ6C8Q== X-Received: by 2002:a5d:67cf:: with SMTP id n15mr72678wrw.95.1615915503232; Tue, 16 Mar 2021 10:25:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUELAEUWvF83uk7TuLD0mvkv57jXQUtCUcv67bs/lra0Zwjchk66YQ/qVdJgkhlD/1Mki0eg== X-Received: by 2002:a5d:67cf:: with SMTP id n15mr72658wrw.95.1615915503118; Tue, 16 Mar 2021 10:25:03 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Igor Mammedov , Laurent Vivier , Marcel Apfelbaum , Claudio Fontana , Thomas Huth , Markus Armbruster , Richard Henderson , qemu-arm@nongnu.org, Andrew Jones , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , "Michael S. Tsirkin" , Eduardo Habkost , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 2/4] tests/qtest: Add qtest_has_accel() method Date: Tue, 16 Mar 2021 18:24:47 +0100 Message-Id: <20210316172449.3148634-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210316172449.3148634-1-philmd@redhat.com> References: <20210316172449.3148634-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 to query at runtime if a QEMU instance has an accelerator built-in. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Eric Blake --- 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.2