From nobody Wed Nov 19 22:14:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1618504406; cv=none; d=zohomail.com; s=zohoarc; b=E7Ug80vfLi7HDMk1+CgDZak1wg4WuyY+hEzUiunyok7OOSaITh3luxx5JH5U1skddkxTKu9aZqAqewGHV3d0sA9VMXis0MR+Lv5kjKP+uiWYVZg9ZKYggp/XEPaNnfHMXCQsn30ZyJzCJRlM7yf/zWnQlBe/0+EX6w0e7z6Gflo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618504406; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=NxYz1h0hu+rZ/LwuHs61u9ZCcyihVB9Q3XHDDjiOe3s=; b=XeomCbhHivLXfpHzSpvanCb6BpH+JQGOXnFSZik1RPxfguHlSM6PtpETGhZn5iLPgFx9xoMObbbYX1FmudA81ExKo7D7d2/i0yoMzRsF+avmFwp1yvJmQd1Y1iVzp/TG92oflr6BKdspQ4fTpIYZWOhZEDO21P80SFx4jtVa97U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1618504406758472.73471266242336; Thu, 15 Apr 2021 09:33:26 -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-337-YWJtOwHsM3q6yeTh8J5xSg-1; Thu, 15 Apr 2021 12:33:24 -0400 Received: by mail-wr1-f69.google.com with SMTP id s9-20020a5d51090000b02901028ea30da6so2988848wrt.7 for ; Thu, 15 Apr 2021 09:33:23 -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 g3sm4369989wrp.46.2021.04.15.09.33.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Apr 2021 09:33:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618504405; 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=NxYz1h0hu+rZ/LwuHs61u9ZCcyihVB9Q3XHDDjiOe3s=; b=P3jqQsHkSVhQzGzwntqZAqbuH2tiJZXxfD9bqUWxoRCTLJqmcg4GHomdbpkyPRwGrwvRYc kdCLW1crLbIIGqEH+AO+ukjfkzA9qhXfiGZxbY1HvJNkNVfMsE0pJwQd5BA6JX8PC4mbBV UVhJqlhd3s2Bbxj9huD4PkgM6WdMTCo= X-MC-Unique: YWJtOwHsM3q6yeTh8J5xSg-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=NxYz1h0hu+rZ/LwuHs61u9ZCcyihVB9Q3XHDDjiOe3s=; b=M9/4rWU+C81/HqnRRl0VQ+i7qVA1mKQOsPJ3o4f5nkY3AI6M4SDzEUdYsWmz0ZbMQZ J1ZhjqOZR1KqF8lrt2N1hMRxke94D/jQXPFnpI1isfkL5UEH431Dc60lwn/9msCqVrPd h1ly3PcORq1s7BpQwYDZKgHnc2ORXSBsuucGCe8nILZrQDXaHOCgoliLaG7fsV1tQqvb MQwC72r8Bi6pzpxuFEf5ok9gfLbDGNFSBeg8iQZFyczUqw8hS1W/W9NkrjMZMJ8aE6KI SSdn/NWbHUa/ONCmhMhzW96PhrcmPq40sZTWOi0Mt8qN68nEA9Nzb7bdRcxVoTijeozu 7zIg== X-Gm-Message-State: AOAM5318h/EnfsyfZmjXbhtqXc7mHVT9maG1PNoR7Tn8DqWK9qHwR1n0 Vz0AjLKy5I5sg7IrWt5tVjwEWHhDvXzAL605O6Ee3gswB3Y4vbxTB9C/T+x5StemFxP1zEgmuBZ f3ervwapuLFF13Q== X-Received: by 2002:a5d:6410:: with SMTP id z16mr3523492wru.40.1618504402307; Thu, 15 Apr 2021 09:33:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7+/CDBXvuwvWMe/2DoJMFX9WGk+8Z0nFYJDUN1t/brTFYJbgMxtcWGJfKfOgm2qb32hIwlg== X-Received: by 2002:a5d:6410:: with SMTP id z16mr3523455wru.40.1618504402125; Thu, 15 Apr 2021 09:33:22 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Claudio Fontana , Igor Mammedov , Eduardo Habkost , qemu-arm@nongnu.org, Paolo Bonzini , Marcel Apfelbaum , Markus Armbruster , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Laurent Vivier , Andrew Jones , Richard Henderson , Juan Quintela , Thomas Huth , Peter Maydell , "Dr. David Alan Gilbert" , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 02/12] accel: Introduce 'query-accels' QMP command Date: Thu, 15 Apr 2021 18:32:54 +0200 Message-Id: <20210415163304.4120052-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210415163304.4120052-1-philmd@redhat.com> References: <20210415163304.4120052-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 'query-accels' QMP command which returns a list of built-in accelerator names. - Accelerator is a QAPI enum of all existing accelerators, - AcceleratorInfo is a QAPI structure providing accelerator specific information. Currently the common structure base provides the name of the accelerator, while the specific part is empty, but each accelerator can expand it. - 'query-accels' QMP command returns a list of @AcceleratorInfo For example on a KVM-only build we get: { "execute": "query-accels" } { "return": [ { "name": "qtest" }, { "name": "kvm" } ] } Note that we can't make the enum values or union branches conditional because of target-specific poisoning of accelerator definitions. Reviewed-by: Eric Blake Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- Since v3: Simplify over-engineered AcceleratorInfo (Markus, kept Eric R-b) Since v2: @since 6.0 -> 6.1, added note (Eric) Since v1: 'type' -> 'name' in comments --- qapi/machine.json | 47 +++++++++++++++++++++++++++++++++++++++++++++ accel/accel-qmp.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ accel/meson.build | 2 +- 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 accel/accel-qmp.c diff --git a/qapi/machine.json b/qapi/machine.json index 6e90d463fc9..1ef729f6f84 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1274,3 +1274,50 @@ ## { 'event': 'MEM_UNPLUG_ERROR', 'data': { 'device': 'str', 'msg': 'str' } } + +## +# @Accelerator: +# +# An enumeration of accelerator names. +# +# Since: 6.1 +## +{ 'enum': 'Accelerator', + 'data': [ 'qtest', 'tcg', 'kvm', 'hax', 'hvf', 'whpx', 'xen' ] } + +## +# @AcceleratorInfo: +# +# Accelerator information. +# +# @name: The accelerator name. +# +# Since: 6.1 +## +{ 'struct': 'AcceleratorInfo', + 'data': { 'name': 'Accelerator' } } + +## +# @query-accels: +# +# Get a list of AcceleratorInfo for all built-in accelerators. +# +# Returns: a list of @AcceleratorInfo describing each accelerator. +# +# Since: 6.1 +# +# Example: +# +# -> { "execute": "query-accels" } +# <- { "return": [ +# { +# "name": "qtest" +# }, +# { +# "name": "kvm" +# } +# ] } +# +## +{ 'command': 'query-accels', + 'returns': ['AcceleratorInfo'] } diff --git a/accel/accel-qmp.c b/accel/accel-qmp.c new file mode 100644 index 00000000000..426737b3f9a --- /dev/null +++ b/accel/accel-qmp.c @@ -0,0 +1,49 @@ +/* + * QEMU accelerators, QMP commands + * + * Copyright (c) 2021 Red Hat Inc. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/qapi-commands-machine.h" + +static const bool accel_builtin_list[ACCELERATOR__MAX] =3D { + [ACCELERATOR_QTEST] =3D true, +#ifdef CONFIG_TCG + [ACCELERATOR_TCG] =3D true, +#endif +#ifdef CONFIG_KVM + [ACCELERATOR_KVM] =3D true, +#endif +#ifdef CONFIG_HAX + [ACCELERATOR_HAX] =3D true, +#endif +#ifdef CONFIG_HVF + [ACCELERATOR_HVF] =3D true, +#endif +#ifdef CONFIG_WHPX + [ACCELERATOR_WHPX] =3D true, +#endif +#ifdef CONFIG_XEN_BACKEND + [ACCELERATOR_XEN] =3D true, +#endif +}; + +AcceleratorInfoList *qmp_query_accels(Error **errp) +{ + AcceleratorInfoList *list =3D NULL, **tail =3D &list; + + for (Accelerator accel =3D 0; accel < ACCELERATOR__MAX; accel++) { + if (accel_builtin_list[accel]) { + AcceleratorInfo *info =3D g_new0(AcceleratorInfo, 1); + + info->name =3D accel; + + QAPI_LIST_APPEND(tail, info); + } + } + + return list; +} diff --git a/accel/meson.build b/accel/meson.build index b44ba30c864..7a48f6d568d 100644 --- a/accel/meson.build +++ b/accel/meson.build @@ -1,4 +1,4 @@ -specific_ss.add(files('accel-common.c')) +specific_ss.add(files('accel-common.c', 'accel-qmp.c')) softmmu_ss.add(files('accel-softmmu.c')) user_ss.add(files('accel-user.c')) =20 --=20 2.26.3