[PATCH RFC 1/2] qemu: use "-accel" option to specify accelerator instead of "-machine"

Paolo Bonzini pbonzini at redhat.com
Mon Jan 11 09:14:58 UTC 2021

On 11/01/21 09:35, Ján Tomko wrote:
>> This unfortunately cannot be done unconditionally.  You need to probe 
>> for the availability of -accel, using something like
> What are we probing for?

Existence of "-accel".  "-accel" allows configuration of 
accelerator-specific, machine-independent properties.  In the past they 
went in -machine but the two have been separate since 5.0 (with 
backwards-compatible glue).

There were two phases of -accel support in QEMU:

- 2.9 to 4.2: only one -accel option supported; specifying a fallback 
couldn't be done with -accel and required the older "-machine 
accel=tcg:kvm" instead

- 5.0 or newer: multiple -accel options supported, e.g. "-accel tcg 
-accel kvm"

and it would be possible to distinguish them, for example using QOM 
properties. However Libvirt only ever specifies one accelerator so it 
makes no difference.

That said, my example patch was wrong.  It's

+    { "accel", NULL, QEMU_CAPS_ACCEL },


> The minimal QEMU version supported by libvirt is 1.5.3 and I'm seeing
> some test cases using -machine pc-i440fx-1.5,accel=tcg in our test
> suite.

Indeed a fallback is needed, that was my review remark. :)

> And I don't see any explicit use of -accel in this patch.

It's right in qemuBuildAccelCommandLine:

>>> +    virCommandAddArg(cmd, "-accel");
>>> +
>>> +    switch ((virDomainVirtType)def->virtType) {
>>> +    case VIR_DOMAIN_VIRT_QEMU:
>>> +        virBufferAddLit(&buf, "tcg");
>>> +        break; 



More information about the libvir-list mailing list