[libvirt] [PATCH 0/2] Add support for gic-version machine option

qemu now supports gic-version option for the virt machine. This patch allows to use it in libvirt. I decided not to add a new capability because qemu correctly complains by itself if it does not have this option. Pavel Fedin (2): qemu: Add support for gic-version machine option qemu: Add test case for gic-version option src/qemu/qemu_command.c | 22 ++++++++---------- .../qemuxml2argv-aarch64-gicv3.args | 6 +++++ .../qemuxml2argv-aarch64-gicv3.xml | 26 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 4 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gicv3.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gicv3.xml -- 2.1.4

Support for GICv3 has been recently introduced in qemu using gic-version option for the 'virt' machine. The option can actually take values of '2', '3' and 'host', however, since in libvirt this is a numeric parameter, we limit it only to 2 and 3. Value of 2 is not added to the command line in order to keep backward compatibility with older qemu versions. Signed-off-by: Pavel Fedin <p.fedin@samsung.com> --- src/qemu/qemu_command.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index bb1835c..eaefc1b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7702,19 +7702,6 @@ qemuBuildCpuArgStr(virQEMUDriverPtr driver, have_cpu = true; } - if (def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ON) { - if (def->gic_version && def->gic_version != 2) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("gic version '%u' is not supported"), - def->gic_version); - goto cleanup; - } - - /* There's no command line argument currently to turn on/off GIC. It's - * done automatically by qemu-system-aarch64. But if this changes, lets - * put the code here. */ - } - if (virBufferCheckError(&buf) < 0) goto cleanup; @@ -7931,6 +7918,15 @@ qemuBuildMachineArgStr(virCommandPtr cmd, return -1; } + if (def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ON) { + if (def->gic_version && (def->gic_version != 2)) { + /* 2 is the default, so we don't put it as option for + * backwards compatibility + */ + virBufferAsprintf(&buf, ",gic-version=%d", def->gic_version); + } + } + virCommandAddArgBuffer(cmd, &buf); } -- 2.1.4

Signed-off-by: Pavel Fedin <p.fedin@samsung.com> --- .../qemuxml2argv-aarch64-gicv3.args | 6 +++++ .../qemuxml2argv-aarch64-gicv3.xml | 26 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 3 files changed, 34 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gicv3.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gicv3.xml diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gicv3.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gicv3.args new file mode 100644 index 0000000..d697669 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gicv3.args @@ -0,0 +1,6 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-aarch64 -S -machine virt,accel=tcg,gic-version=3 -cpu cortex-a53 -m 1024 -smp 1 \ +-nographic -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -boot c \ +-kernel /aarch64.kernel -initrd /aarch64.initrd -append console=ttyAMA0 -usb \ +-net nic,macaddr=52:54:00:09:a4:37,vlan=0,model=virtio,name=net0 \ +-net user,vlan=0,name=hostnet0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gicv3.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gicv3.xml new file mode 100644 index 0000000..f8d63c3 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gicv3.xml @@ -0,0 +1,26 @@ +<domain type="qemu"> + <name>aarch64test</name> + <uuid>6ba410c5-1e5c-4d57-bee7-2228e7ffa32f</uuid> + <memory>1048576</memory> + <currentMemory>1048576</currentMemory> + <vcpu>1</vcpu> + <features> + <acpi/> + <gic version='3'/> + </features> + <cpu match='exact'> + <model>cortex-a53</model> + </cpu> + <os> + <type arch="aarch64" machine="virt">hvm</type> + <kernel>/aarch64.kernel</kernel> + <initrd>/aarch64.initrd</initrd> + <cmdline>console=ttyAMA0</cmdline> + </os> + <devices> + <emulator>/usr/bin/qemu-system-aarch64</emulator> + <interface type='user'> + <mac address='52:54:00:09:a4:37'/> + </interface> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index ae67779..a3926cf 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1644,6 +1644,8 @@ mymain(void) QEMU_CAPS_CPU_HOST, QEMU_CAPS_KVM); DO_TEST("aarch64-gic", QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, QEMU_CAPS_KVM); + DO_TEST("aarch64-gicv3", QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, + QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT); driver.caps->host.cpu->arch = VIR_ARCH_AARCH64; DO_TEST("aarch64-kvm-32-on-64", QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, -- 2.1.4

On Fri, Sep 25, 2015 at 05:46:22PM +0300, Pavel Fedin wrote:
qemu now supports gic-version option for the virt machine. This patch allows to use it in libvirt.
I decided not to add a new capability because qemu correctly complains by itself if it does not have this option.
It's nice that QEMU complains itself, but in a case where it is that easy to check the supportability I think it's worth adding because then at least we won't prepare all the stuff and can error out early.
Pavel Fedin (2): qemu: Add support for gic-version machine option qemu: Add test case for gic-version option
src/qemu/qemu_command.c | 22 ++++++++---------- .../qemuxml2argv-aarch64-gicv3.args | 6 +++++ .../qemuxml2argv-aarch64-gicv3.xml | 26 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 4 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gicv3.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gicv3.xml
-- 2.1.4
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Hello!
It's nice that QEMU complains itself, but in a case where it is that easy to check the supportability I think it's worth adding because then at least we won't prepare all the stuff and can error out early.
Huh... I am looking at it now, but looks like there's no support for getting machine properties in QMP. Or, at least, it's not documented. The easy way would be based on version number (actually we already do this with QEMU_CAPS_MACHINE_USB_OPT). Will it be OK? Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia

On Mon, Sep 28, 2015 at 08:26:22PM +0300, Pavel Fedin wrote:
Hello!
It's nice that QEMU complains itself, but in a case where it is that easy to check the supportability I think it's worth adding because then at least we won't prepare all the stuff and can error out early.
Huh... I am looking at it now, but looks like there's no support for getting machine properties in QMP. Or, at least, it's not documented. The easy way would be based on version number (actually we already do this with QEMU_CAPS_MACHINE_USB_OPT). Will it be OK?
If there is no other option, then we have nothing to choose from, so it's OK to have it checked by version in this particular case. Later on libvirt should support QEMU's QMP introspection from Markus, but that's a future thing. Thanks, Martin
Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia
participants (2)
-
Martin Kletzander
-
Pavel Fedin