From: Cornelia Huck <cohuck@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: qemu-devel@nongnu.org, "Aurelien Jarno" <aurelien@aurel32.net>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Anthony Perard" <anthony.perard@citrix.com>,
qemu-ppc@nongnu.org, qemu-s390x@nongnu.org,
"Halil Pasic" <pasic@linux.ibm.com>,
"Huacai Chen" <chenhuacai@kernel.org>,
xen-devel@lists.xenproject.org,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"David Gibson" <david@gibson.dropbear.id.au>,
qemu-arm@nongnu.org,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
kvm@vger.kernel.org, "BALATON Zoltan" <balaton@eik.bme.hu>,
"Leif Lindholm" <leif@nuviainc.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Radoslaw Biernacki" <rad@semihalf.com>,
"Alistair Francis" <alistair@alistair23.me>,
"Paul Durrant" <paul@xen.org>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
"Hervé Poussineau" <hpoussin@reactos.org>,
"Greg Kurz" <groug@kaod.org>,
"Christian Borntraeger" <borntraeger@de.ibm.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"David Hildenbrand" <david@redhat.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Aleksandar Rikalo" <aleksandar.rikalo@syrmia.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: Re: [PATCH v2 02/11] hw/boards: Introduce machine_class_valid_for_accelerator()
Date: Mon, 22 Feb 2021 18:34:00 +0100 [thread overview]
Message-ID: <20210222183400.0c151d46.cohuck@redhat.com> (raw)
In-Reply-To: <20210219173847.2054123-3-philmd@redhat.com>
On Fri, 19 Feb 2021 18:38:38 +0100
Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
> Introduce the valid_accelerators[] field to express the list
> of valid accelators a machine can use, and add the
> machine_class_valid_for_current_accelerator() and
> machine_class_valid_for_accelerator() methods.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> include/hw/boards.h | 24 ++++++++++++++++++++++++
> hw/core/machine.c | 26 ++++++++++++++++++++++++++
> 2 files changed, 50 insertions(+)
>
> diff --git a/include/hw/boards.h b/include/hw/boards.h
> index 68d3d10f6b0..4d08bc12093 100644
> --- a/include/hw/boards.h
> +++ b/include/hw/boards.h
> @@ -36,6 +36,24 @@ void machine_set_cpu_numa_node(MachineState *machine,
> const CpuInstanceProperties *props,
> Error **errp);
>
> +/**
> + * machine_class_valid_for_accelerator:
> + * @mc: the machine class
> + * @acc_name: accelerator name
> + *
> + * Returns %true if the accelerator is valid for the machine, %false
> + * otherwise. See #MachineClass.valid_accelerators.
Naming confusion: is the machine class valid for the accelerator, or
the accelerator valid for the machine class? Or either? :)
> + */
> +bool machine_class_valid_for_accelerator(MachineClass *mc, const char *acc_name);
> +/**
> + * machine_class_valid_for_current_accelerator:
> + * @mc: the machine class
> + *
> + * Returns %true if the accelerator is valid for the current machine,
> + * %false otherwise. See #MachineClass.valid_accelerators.
Same here: current accelerator vs. current machine.
> + */
> +bool machine_class_valid_for_current_accelerator(MachineClass *mc);
> +
> void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type);
> /*
> * Checks that backend isn't used, preps it for exclusive usage and
> @@ -125,6 +143,11 @@ typedef struct {
> * should instead use "unimplemented-device" for all memory ranges where
> * the guest will attempt to probe for a device that QEMU doesn't
> * implement and a stub device is required.
> + * @valid_accelerators:
> + * If this machine supports a specific set of virtualization accelerators,
> + * this contains a NULL-terminated list of the accelerators that can be
> + * used. If this field is not set, any accelerator is valid. The QTest
> + * accelerator is always valid.
> * @kvm_type:
> * Return the type of KVM corresponding to the kvm-type string option or
> * computed based on other criteria such as the host kernel capabilities
> @@ -166,6 +189,7 @@ struct MachineClass {
> const char *alias;
> const char *desc;
> const char *deprecation_reason;
> + const char *const *valid_accelerators;
>
> void (*init)(MachineState *state);
> void (*reset)(MachineState *state);
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index 970046f4388..c42d8e382b1 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -518,6 +518,32 @@ static void machine_set_nvdimm_persistence(Object *obj, const char *value,
> nvdimms_state->persistence_string = g_strdup(value);
> }
>
> +bool machine_class_valid_for_accelerator(MachineClass *mc, const char *acc_name)
> +{
> + const char *const *name = mc->valid_accelerators;
> +
> + if (!name) {
> + return true;
> + }
> + if (strcmp(acc_name, "qtest") == 0) {
> + return true;
> + }
> +
> + for (unsigned i = 0; name[i]; i++) {
> + if (strcasecmp(acc_name, name[i]) == 0) {
> + return true;
> + }
> + }
> + return false;
> +}
> +
> +bool machine_class_valid_for_current_accelerator(MachineClass *mc)
> +{
> + AccelClass *ac = ACCEL_GET_CLASS(current_accel());
> +
> + return machine_class_valid_for_accelerator(mc, ac->name);
> +}
The implementation of the function tests for the current accelerator,
so I think you need to tweak the description above?
> +
> void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type)
> {
> QAPI_LIST_PREPEND(mc->allowed_dynamic_sysbus_devices, g_strdup(type));
next prev parent reply other threads:[~2021-02-22 17:35 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-19 17:38 [PATCH v2 00/11] hw/accel: Exit gracefully when accelerator is invalid Philippe Mathieu-Daudé
2021-02-19 17:38 ` [PATCH v2 01/11] accel/kvm: Check MachineClass kvm_type() return value Philippe Mathieu-Daudé
2021-02-22 17:24 ` Cornelia Huck
2021-02-22 17:41 ` Philippe Mathieu-Daudé
2021-02-22 17:50 ` Cornelia Huck
2021-02-22 18:04 ` Philippe Mathieu-Daudé
2021-02-22 23:33 ` David Gibson
2021-02-22 23:37 ` David Gibson
2021-02-23 10:36 ` Cornelia Huck
2021-02-23 11:23 ` Philippe Mathieu-Daudé
2021-02-19 17:38 ` [PATCH v2 02/11] hw/boards: Introduce machine_class_valid_for_accelerator() Philippe Mathieu-Daudé
2021-02-22 17:34 ` Cornelia Huck [this message]
2021-02-22 17:46 ` Philippe Mathieu-Daudé
2021-02-22 17:59 ` Cornelia Huck
2021-02-19 17:38 ` [PATCH v2 03/11] hw/core: Restrict 'query-machines' to those supported by current accel Philippe Mathieu-Daudé
2021-02-22 17:42 ` Cornelia Huck
2021-02-19 17:38 ` [PATCH v2 04/11] hw/arm: Restrit KVM to the virt & versal machines Philippe Mathieu-Daudé
2021-02-22 20:03 ` BALATON Zoltan
2021-02-19 17:38 ` [PATCH v2 05/11] hw/mips: Restrict KVM to the malta & virt machines Philippe Mathieu-Daudé
[not found] ` <31a32613-2a61-7cd2-582a-4e6d10949436@flygoat.com>
2021-02-20 6:02 ` Huacai Chen
2021-02-19 17:38 ` [RFC PATCH v2 06/11] hw/ppc: Restrict KVM to various PPC machines Philippe Mathieu-Daudé
2021-02-22 5:59 ` David Gibson
2021-02-22 13:19 ` Philippe Mathieu-Daudé
2021-02-19 17:38 ` [PATCH v2 07/11] hw/s390x: Explicit the s390-ccw-virtio machines support TCG and KVM Philippe Mathieu-Daudé
2021-02-22 17:37 ` Cornelia Huck
2021-02-19 17:38 ` [RFC PATCH v2 08/11] hw/i386: Explicit x86 machines support all current accelerators Philippe Mathieu-Daudé
2021-02-19 17:38 ` [PATCH v2 09/11] hw/xenpv: Restrict Xen Para-virtualized machine to Xen accelerator Philippe Mathieu-Daudé
2021-02-19 18:20 ` Paul Durrant
2021-02-19 17:38 ` [PATCH v2 10/11] hw/board: Only allow TCG accelerator by default Philippe Mathieu-Daudé
2021-02-19 17:38 ` [PATCH v2 11/11] softmmu/vl: Exit gracefully when accelerator is not supported Philippe Mathieu-Daudé
2021-02-22 17:46 ` Cornelia Huck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210222183400.0c151d46.cohuck@redhat.com \
--to=cohuck@redhat.com \
--cc=aleksandar.rikalo@syrmia.com \
--cc=alistair@alistair23.me \
--cc=anthony.perard@citrix.com \
--cc=aurelien@aurel32.net \
--cc=balaton@eik.bme.hu \
--cc=borntraeger@de.ibm.com \
--cc=chenhuacai@kernel.org \
--cc=david@gibson.dropbear.id.au \
--cc=david@redhat.com \
--cc=edgar.iglesias@gmail.com \
--cc=ehabkost@redhat.com \
--cc=f4bug@amsat.org \
--cc=groug@kaod.org \
--cc=hpoussin@reactos.org \
--cc=jiaxun.yang@flygoat.com \
--cc=kvm@vger.kernel.org \
--cc=leif@nuviainc.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mst@redhat.com \
--cc=pasic@linux.ibm.com \
--cc=paul@xen.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=rad@semihalf.com \
--cc=richard.henderson@linaro.org \
--cc=sstabellini@kernel.org \
--cc=thuth@redhat.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).