From patchwork Fri Jun 4 15:51:35 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: 454050 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp535503jae; Fri, 4 Jun 2021 08:53:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzogB4Fe/oVdySPH17znqGx5fmF4btmh8KaYrJ9sIYusiZ27ddehZD/eO56iTzHwUdBQwcD X-Received: by 2002:a1f:260c:: with SMTP id m12mr2861831vkm.25.1622822018615; Fri, 04 Jun 2021 08:53:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622822018; cv=none; d=google.com; s=arc-20160816; b=tr1SxkcDmM49dyaFmACTKaDnJ32IOWLl0oEptZDIQOng8RZK1+JT+lte8FgPhnKeRQ XYUloUsl+vk5gPTMQaEfJCjjksq4t9oXhQo2Xu6gzdUFg1dVUiWBJ54beMMqrnHx2jgv WTCx6k8EpM51cNTOzYPyDN3C7uHWtbbwoKAfw2EXB0lvxQRnRTr8Bdm6wX4uZ320ro6T TqkHU113YMiL7oAX7WJdBntEwKKP+xEMc+Guoz5s2q9DlQwbilKPtbTwswN3eucuenkq k977bClY4wa35CAVvS/KrOLjEunCAoe63I9drJEF+11n/zZgy1PRUFkh0bFUd3aBTW8V sUEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=TfhBAPUGZRyh95qvT9iSddyRzYFalb2GCwwg+0epNlQ=; b=oERlfrCcoYb42IoWVgTFYzhKfLyrz8HmohPKzsKAOhN8u8Bs1VGsk5eoJvVZCeO4J7 8KxQo//5BtgmBIvn4nyjbyobJno3k485XVur8EXllMl+TV8s+ctVlfJNKdZUScZ/r3q7 4q8R0GMLKJvTG8OROp3VbG+grEJhk69aBWrST5Qtpwhs0Fu4oImhLWBfhZZMlkv9SOWI /xBta28fQ2HkcB9x6mu8iaoV2aecEdaJKctlYEql7gvATM51/j7iFNopE8mFUvzEol7K umYc4/yl/fa0wvaA45hqVRIv9jEV6FZm604QT5GSl+XkFJ6H/NK1e8LEBAHfHM1mFndT mm0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lU8Nth9h; 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=fail (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 b6si2935640vso.336.2021.06.04.08.53.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Jun 2021 08:53:38 -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=fail header.i=@linaro.org header.s=google header.b=lU8Nth9h; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpC8f-0002K7-Qz for patch@linaro.org; Fri, 04 Jun 2021 11:53:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpC8O-0002Gr-Qn for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:53:20 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:35604) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpC8L-0008MT-V1 for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:53:20 -0400 Received: by mail-wr1-x433.google.com with SMTP id m18so9807468wrv.2 for ; Fri, 04 Jun 2021 08:53:16 -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=TfhBAPUGZRyh95qvT9iSddyRzYFalb2GCwwg+0epNlQ=; b=lU8Nth9hhzn7DJhdY23Rq5zeLxg6bFeMjTebVFM98emHAVMYG5wBh4B/tPHZfURLUc Mc8sdBji7u80x4idaa6qtx0RtRejaBMxZ+IcgUm3tbcQ8/K9GLy6fV0B2kS5lV1jWBCV Bl/Dn1bYPaN07T1yiMargDzLatmDd5/CDWyfc+q0DkUA4xyHqIaCMbW4etIEF5DwhdSm FaArvVntjXGrt9Z2m7+NWy+JBI9IbrcfOxtpEsYMkmHQpYsxwcDQ5u4i2ioip4+W/yW4 kXQSEqFeBCxqU1vHqQ1vwjvNXILCt7BARH/Ar1cRjeKrkrpPfMHxBPMGr1bsObqkyJpT IgkA== 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=TfhBAPUGZRyh95qvT9iSddyRzYFalb2GCwwg+0epNlQ=; b=IT555olwQknDaSAKqgQTySeeC6OV/JCHwfjQDYyZzDUx6mWFi2qzUqMEMMyaaEGNP6 wSpAUuPissZhcbNdjCrrUx60SczPY2yIPLQ5kg7NFmjAYdtbObi1inPRPjHPp8lSPzYh d9Cdp9IwW+oIeht/aNp6L37rf0jGixk64vnDDXr3Q707fJb4aD9liP79SVZ4CFfYGCzy BOaDHVj6mjU5IXqkW6OliVzPRU9AG2hlvAGd0WuJW22BZqTxc8JkyGgrR27PemYk8vig rpo9sFJD1z2J1LACFn20FZmqTnineHI+bp7C/qfu89aY1dQGjezQnO4VBkye7HC1Vi59 Ll8w== X-Gm-Message-State: AOAM532b3ZqSpBJ/EdGfI1LpXgoFNq1EkgARXKeRNszlxXOffSQDq78Q BjxW6ut/iRhTlUuNmgTQy0f3dw== X-Received: by 2002:a5d:6e92:: with SMTP id k18mr4692302wrz.94.1622821995428; Fri, 04 Jun 2021 08:53:15 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id j14sm9095407wmi.32.2021.06.04.08.53.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 08:53:13 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8A38D1FF8C; 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 02/99] accel: Introduce 'query-accels' QMP command Date: Fri, 4 Jun 2021 16:51:35 +0100 Message-Id: <20210604155312.15902-3-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::433; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x433.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: Eduardo Habkost , Richard Henderson , Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?b?ZMOp?= , qemu-arm@nongnu.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé 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 Reviewed-by: Alex Bennée Tested-by: Alex Bennée Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée Message-Id: <20210505125806.1263441-3-philmd@redhat.com> --- 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 -- 2.20.1 Reviewed-by: Thomas Huth diff --git a/qapi/machine.json b/qapi/machine.json index 58a9c86b36..79a0891793 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': [ 'hax', 'hvf', 'kvm', 'qtest', 'tcg', '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 0000000000..426737b3f9 --- /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] = { + [ACCELERATOR_QTEST] = true, +#ifdef CONFIG_TCG + [ACCELERATOR_TCG] = true, +#endif +#ifdef CONFIG_KVM + [ACCELERATOR_KVM] = true, +#endif +#ifdef CONFIG_HAX + [ACCELERATOR_HAX] = true, +#endif +#ifdef CONFIG_HVF + [ACCELERATOR_HVF] = true, +#endif +#ifdef CONFIG_WHPX + [ACCELERATOR_WHPX] = true, +#endif +#ifdef CONFIG_XEN_BACKEND + [ACCELERATOR_XEN] = true, +#endif +}; + +AcceleratorInfoList *qmp_query_accels(Error **errp) +{ + AcceleratorInfoList *list = NULL, **tail = &list; + + for (Accelerator accel = 0; accel < ACCELERATOR__MAX; accel++) { + if (accel_builtin_list[accel]) { + AcceleratorInfo *info = g_new0(AcceleratorInfo, 1); + + info->name = accel; + + QAPI_LIST_APPEND(tail, info); + } + } + + return list; +} diff --git a/accel/meson.build b/accel/meson.build index b44ba30c86..7a48f6d568 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'))