From: Cornelia Huck <cohuck@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
kvm@vger.kernel.org, "Paul Durrant" <paul@xen.org>,
"David Hildenbrand" <david@redhat.com>,
qemu-devel@nongnu.org,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Huacai Chen" <chenhuacai@kernel.org>,
"Halil Pasic" <pasic@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@de.ibm.com>,
"Hervé Poussineau" <hpoussin@reactos.org>,
"Anthony Perard" <anthony.perard@citrix.com>,
xen-devel@lists.xenproject.org,
"Leif Lindholm" <leif@nuviainc.com>,
"Thomas Huth" <thuth@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Alistair Francis" <alistair@alistair23.me>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Greg Kurz" <groug@kaod.org>,
qemu-s390x@nongnu.org, qemu-arm@nongnu.org,
"David Gibson" <david@gibson.dropbear.id.au>,
"Radoslaw Biernacki" <rad@semihalf.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
qemu-ppc@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Aleksandar Rikalo" <aleksandar.rikalo@syrmia.com>,
"Aurelien Jarno" <aurelien@aurel32.net>
Subject: Re: [PATCH v2 11/11] softmmu/vl: Exit gracefully when accelerator is not supported
Date: Mon, 22 Feb 2021 18:46:20 +0100 [thread overview]
Message-ID: <20210222184620.57119057.cohuck@redhat.com> (raw)
In-Reply-To: <20210219173847.2054123-12-philmd@redhat.com>
On Fri, 19 Feb 2021 18:38:47 +0100
Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
> Before configuring an accelerator, check it is valid for
> the current machine. Doing so we can return a simple error
> message instead of criptic one.
s/criptic/cryptic/
>
> Before:
>
> $ qemu-system-arm -M raspi2b -enable-kvm
> qemu-system-arm: /build/qemu-ETIdrs/qemu-4.2/exec.c:865: cpu_address_space_init: Assertion `asidx == 0 || !kvm_enabled()' failed.
> Aborted
>
> $ qemu-system-aarch64 -M xlnx-zcu102 -enable-kvm -smp 6
> qemu-system-aarch64: kvm_init_vcpu: kvm_arch_init_vcpu failed (0): Invalid argument
>
> After:
>
> $ qemu-system-arm -M raspi2b -enable-kvm
> qemu-system-aarch64: invalid accelerator 'kvm' for machine raspi2b
>
> $ qemu-system-aarch64 -M xlnx-zcu102 -enable-kvm -smp 6
> qemu-system-aarch64: -accel kvm: invalid accelerator 'kvm' for machine xlnx-zcu102
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> softmmu/vl.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/softmmu/vl.c b/softmmu/vl.c
> index b219ce1f357..f2c4074310b 100644
> --- a/softmmu/vl.c
> +++ b/softmmu/vl.c
> @@ -2133,6 +2133,7 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp)
> const char *acc = qemu_opt_get(opts, "accel");
> AccelClass *ac = accel_find(acc);
> AccelState *accel;
> + MachineClass *mc;
> int ret;
> bool qtest_with_kvm;
>
> @@ -2145,6 +2146,12 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp)
> }
> return 0;
> }
> + mc = MACHINE_GET_CLASS(current_machine);
> + if (!qtest_chrdev && !machine_class_valid_for_accelerator(mc, ac->name)) {
Shouldn't qtest be already allowed in any case in the checking function?
> + *p_init_failed = true;
> + error_report("invalid accelerator '%s' for machine %s", acc, mc->name);
> + return 0;
> + }
> accel = ACCEL(object_new_with_class(OBJECT_CLASS(ac)));
> object_apply_compat_props(OBJECT(accel));
> qemu_opt_foreach(opts, accelerator_set_property,
prev parent reply other threads:[~2021-02-22 17:56 UTC|newest]
Thread overview: 32+ 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
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é
2021-02-20 4:56 ` Jiaxun Yang
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 [this message]
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=20210222184620.57119057.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=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=kvm@vger.kernel.org \
--cc=leif@nuviainc.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).