mbox series

[0/2] system/vl.c: parse all '-accel' opts

Message ID 20240701133038.1489043-1-dbarboza@ventanamicro.com
Headers show
Series system/vl.c: parse all '-accel' opts | expand

Message

Daniel Henrique Barboza July 1, 2024, 1:30 p.m. UTC
Hi,

In the current handling of  '-accel' only the first instance is parsed.
All other instances (aside from a 'helper' command that triggers the
help text and exits) is ignored.

This also means that we can mix different accelerators in the same
command line. In fact we can do whatever we want as long as the first
instance of '-accel' is valid. E.g. this command line will boot a x86_64
KVM guest without problems:

qemu-system-x86_64 -accel kvm -accel tcg -accel not_an_accel (...)

And this will boot a KVM guest with kernel-irqchip=off because it will
ignore the second '-accel' that sets its back to 'on':

qemu-system-x86_64 -accel kvm,kernel-irqchip=off \
    -accel kvm,kernel-irqchip=on (...)

My initial intention was to fix a problem we're having with libvirt and
RISC-V where we can't set 'riscv-aia' by appending '-accel kvm,riscv-aia=val'
via <qemu:cmdline> in the domain XML. libvirt will add a leading
'-accel kvm' in the regular command line and ignore the second. But to
fix that (patch 2) we must first guarantee that we're not mixing different
accelerators.

Both patches can be squashed in a single patch if preferrable. I'm
sending in separate because I'm not fully confident in patch 1.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>

Daniel Henrique Barboza (2):
  system/vl.c: do not allow mixed -accel opts
  system/vl.c: parse all -accel options

 system/vl.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

Comments

Paolo Bonzini July 1, 2024, 4:31 p.m. UTC | #1
On Mon, Jul 1, 2024 at 3:30 PM Daniel Henrique Barboza
<dbarboza@ventanamicro.com> wrote:
> My initial intention was to fix a problem we're having with libvirt and
> RISC-V where we can't set 'riscv-aia' by appending '-accel kvm,riscv-aia=val'
> via <qemu:cmdline> in the domain XML. libvirt will add a leading
> '-accel kvm' in the regular command line and ignore the second. But to
> fix that (patch 2) we must first guarantee that we're not mixing different
> accelerators.

I think you can use -global, if you tweak qdev_prop_check_globals() to
also allow descendents of TYPE_ACCEL.

For example:

   ./qemu-system-x86_64 -accel kvm -global kvm-accel.kernel-irqchip=off

Paolo
Daniel Henrique Barboza July 1, 2024, 5:20 p.m. UTC | #2
On 7/1/24 1:31 PM, Paolo Bonzini wrote:
> On Mon, Jul 1, 2024 at 3:30 PM Daniel Henrique Barboza
> <dbarboza@ventanamicro.com> wrote:
>> My initial intention was to fix a problem we're having with libvirt and
>> RISC-V where we can't set 'riscv-aia' by appending '-accel kvm,riscv-aia=val'
>> via <qemu:cmdline> in the domain XML. libvirt will add a leading
>> '-accel kvm' in the regular command line and ignore the second. But to
>> fix that (patch 2) we must first guarantee that we're not mixing different
>> accelerators.
> 
> I think you can use -global, if you tweak qdev_prop_check_globals() to
> also allow descendents of TYPE_ACCEL.
> 
> For example:
> 
>     ./qemu-system-x86_64 -accel kvm -global kvm-accel.kernel-irqchip=off

I'll try it out! Thanks,


Daniel


> 
> Paolo
>