From nobody Mon Feb 9 08:57:42 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=1620076236; cv=none; d=zohomail.com; s=zohoarc; b=eIhpd15zpuOuai/qcEWBHJpXLtLbQ+U3gLTACKgUUoz87HRpoFmrKO5KC351j0ACrX6fzSvSl0SBmSnHh/+lIObA+WOtLP/8Q+KQhjIfRvm5VdM6x28w5mI2schE1DeMluOYTbIaoIoBjy07krisfKpAsAKW8UrtPN596GhS/Gc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620076236; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=P/JwIaYRijlIKIuvZy1yv4gicsUV0JiEB0BppIoUwQc=; b=fYAPsz0tR/n+WesZDcuBsCt/B+r4kFqssl1jdotMvECMW+tYw6nzlVhWog3w9KePosfK8I/SuQhKhBEGLu5kx7Ex3uI3eJ22ZlDUHE8PvRORuUWlnKzUJKO3vqROhwOgKME+aVWjNMzF3dl5VXz1vwfltwyS07qNQ424Z/5nbVI= 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 1620076236795560.7026194303029; Mon, 3 May 2021 14:10:36 -0700 (PDT) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-36-FPJF3F1_MlGujLu5yO756Q-1; Mon, 03 May 2021 17:10:34 -0400 Received: by mail-wr1-f71.google.com with SMTP id v2-20020a0560001622b0290106e28f8af8so4625579wrb.9 for ; Mon, 03 May 2021 14:10:34 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (anancy-651-1-208-144.w109-217.abo.wanadoo.fr. [109.217.237.144]) by smtp.gmail.com with ESMTPSA id o17sm14529602wrs.48.2021.05.03.14.10.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 14:10:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620076235; 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=P/JwIaYRijlIKIuvZy1yv4gicsUV0JiEB0BppIoUwQc=; b=SsRd0xJpSMuxl9QWf0XyYcqSzgL7Ou79kcuV/0x13y7MzLDF7vyGo2fALZX4gdVATjksxQ bM8awBfasp7uH0ydJeSTmKS92SsfccOPiEYp1XVry++AO3Er6aDTNJoWijJloKsUjauCUO OX3JJuHJfF3PGcwWSIiMBO0vZIdld7g= X-MC-Unique: FPJF3F1_MlGujLu5yO756Q-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=P/JwIaYRijlIKIuvZy1yv4gicsUV0JiEB0BppIoUwQc=; b=LwkEj3NJpXxOesSxZpkHoKD8c+zQQS2kqmJNjOSigDRU/t40HhnN1/Vh9qK1DNEMyM yr6uLLcpP34xaOHDQ8e90DRUeEuAKNbdLZywd+AK3U1IS2jvBEpIifcw28CAJgJNvigR bEVIHhL6MXKkrVZO8XEBAn+b1Q+87T7YljoisNFWPJrP7K2ev7AcyLV/8PJMvkwQVIB9 7lYUXM4pXEUJjWMwFEjPhWFqDedmniJnBHnHOlm5aT8FYFXIAAaUgpNBKzHxt19LNgbn vM4bYcVaP2D/bIva3BohT3AEHs4R3/Mf5LPWkNMNu2vlvrnQuW99QOZEeS3Un5rDKGuq YB6g== X-Gm-Message-State: AOAM532MT5xv69wRntEl7jKRJTqRyRaVq0YaAkFBzQMKN9GLVMSdJXYs cxGJRyhCHl3zciRkYhh1b3GQCjPbwwCgYIAr+1oVw+d1XH1N6MnsINg5hxURt+e448PiQBwwrjg V6eXiJjzoJfZ1Qw== X-Received: by 2002:a05:600c:4f4d:: with SMTP id m13mr504238wmq.133.1620076233049; Mon, 03 May 2021 14:10:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfC74+KBGj0iZP4yjF1Dlg6WZlocMh6ZsUPwF8xTZut77i2zQIa8DTsdf5gINFQkwHobpJQw== X-Received: by 2002:a05:600c:4f4d:: with SMTP id m13mr504226wmq.133.1620076232859; Mon, 03 May 2021 14:10:32 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Thomas Huth , Markus Armbruster , Eric Blake , Paolo Bonzini , qemu-arm@nongnu.org, Igor Mammedov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PATCH v6 02/12] accel: Introduce 'query-accels' QMP command Date: Mon, 3 May 2021 23:10:10 +0200 Message-Id: <20210503211020.894589-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210503211020.894589-1-philmd@redhat.com> References: <20210503211020.894589-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 Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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..6dd3b765248 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 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