From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34C6BC433B4 for ; Sat, 1 May 2021 22:40:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8CADF61221 for ; Sat, 1 May 2021 22:40:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8CADF61221 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcyHT-0008Gb-KW for qemu-devel@archiver.kernel.org; Sat, 01 May 2021 18:40:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcyEK-0004Ih-AW for qemu-devel@nongnu.org; Sat, 01 May 2021 18:36:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30622) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcyEI-0008Dq-EN for qemu-devel@nongnu.org; Sat, 01 May 2021 18:36:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619908613; 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=hD8/sTsMzM6w6BlcGs9qHF6TQ10h9/8DIKCBiTVJ+gejDaToRxU/Xrpk6ZARAxHtq2eIx6 xlCIQH+Iz4qSGlrx6eX8ntudxjvxKDTXVFwz409UYIVIXwJKEB5zFudW4f2yDKt/OoWRiQ YdMjlizht0kToQjeVpvpyn/f/QgOTW0= 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-528-2Lsiqz24MWqJ0t-ss1OorQ-1; Sat, 01 May 2021 18:36:52 -0400 X-MC-Unique: 2Lsiqz24MWqJ0t-ss1OorQ-1 Received: by mail-wr1-f72.google.com with SMTP id i32-20020adf90a30000b029010d9e6b3833so1278814wri.18 for ; Sat, 01 May 2021 15:36:52 -0700 (PDT) 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=cSrdL6yXQh/RF0jd4WCs4dtmB3keVKgVgY4vlbFQQXBQ6cBVm0IFVzFsgfrJHeezJ5 4V8nNboaDblxwTbcsvZQ4HuUjW87wpIdecaamZM0dYUENLzy5KVAzy3Pp2g7kv28QB+r vw0xtE3tNazwR0VNSDoN1gV5Uct/iuwJ37ytsL+0Vkg1FCg9wAXYSQtfHtcsGSWXdma2 uWet5FGR8UyUxwtytW4kOZq3eT8tUlNakjfQzSm1eA33PDaBROO9tmiRwjIJVPtFoZDW LobkSvSUYb/NCNa6E5duiDoUdUuVQZWG9L3lBv/voDkLw7X1UQfVhLZVdeI4o8/OGMU7 sQkQ== X-Gm-Message-State: AOAM532EWwoCG1Dx0WvbAkWhxrpr2HitOQDV/3BKNj6CAU2jpOeY9uq+ UVlwzB2YFDxp7U9EohwNLl24Tdn96wp/aW9O7Q+5zUxyVBItCWOSoH5Ff4p+lbVBsz6CGiWj6EW gMAm9DlcBkdfEluc5u+UT6dHdtCi+cs9w4bCt1fia5JRn1YYpuaV12zPMsQLgOdXC X-Received: by 2002:adf:e412:: with SMTP id g18mr16077769wrm.205.1619908611221; Sat, 01 May 2021 15:36:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzM4BHt2yyU8i4o9rA/zpuVv9duUDrB5qs1XT5dWGU9kZEph9GZHIhMZGhXT7DqSFr7rZ4t6A== X-Received: by 2002:adf:e412:: with SMTP id g18mr16077724wrm.205.1619908610815; Sat, 01 May 2021 15:36:50 -0700 (PDT) Received: from localhost.localdomain (anancy-651-1-208-144.w109-217.abo.wanadoo.fr. [109.217.237.144]) by smtp.gmail.com with ESMTPSA id l14sm6220149wmq.4.2021.05.01.15.36.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 May 2021 15:36:50 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 02/10] accel: Introduce 'query-accels' QMP command Date: Sun, 2 May 2021 00:36:30 +0200 Message-Id: <20210501223638.510712-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210501223638.510712-1-philmd@redhat.com> References: <20210501223638.510712-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: 8bit Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: Andrew Jones , Eduardo Habkost , Juan Quintela , Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Thomas Huth , "Dr. David Alan Gilbert" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-arm@nongnu.org, Claudio Fontana , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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] = { + [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 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')) -- 2.26.3