From nobody Fri May 3 12:51:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522760268693446.279949233999; Tue, 3 Apr 2018 05:57:48 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D253F8123D; Tue, 3 Apr 2018 12:57:46 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 04CE117B66; Tue, 3 Apr 2018 12:57:46 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1C3F6180613A; Tue, 3 Apr 2018 12:57:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w33Cvhx9001760 for ; Tue, 3 Apr 2018 08:57:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id C1F232024CA2; Tue, 3 Apr 2018 12:57:43 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 685D52024CA1 for ; Tue, 3 Apr 2018 12:57:43 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Tue, 3 Apr 2018 14:57:39 +0200 Message-Id: <20180403125739.5586-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: Format gic-version=2 on the command line X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 03 Apr 2018 12:57:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Up until now we have only formatted non-default GIC versions on the command line, in order to maintain compatibility with older QEMU versions that didn't implement the gic-version option to begin with; however, doing so is entirely unnecessary for newer QEMU versions, where the option is available. Moreover, having the GIC version formatted on the command line at all times ensures that QEMU changing its own defaults doesn't affect the ABI of libvirt guests. A few test cases are removed to avoid extra churn. It doesn't matter for coverage, as those scenarios are already covered by other parts of the test suite. This patch is better viewed with 'git show -w'. Signed-off-by: Andrea Bolognani Reviewed-by: John Ferlan --- src/qemu/qemu_command.c | 44 +++++++++++++++++---= ---- tests/qemuxml2argvdata/aarch64-gic-none-tcg.args | 2 +- tests/qemuxml2argvdata/aarch64-gic-v2.args | 2 +- tests/qemuxml2argvtest.c | 6 ---- 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 682d714419..1ab1e1a285 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7299,21 +7299,39 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, goto cleanup; =20 if (def->features[VIR_DOMAIN_FEATURE_GIC] =3D=3D VIR_TRISTATE_SWIT= CH_ON) { - if (def->gic_version !=3D VIR_GIC_VERSION_NONE) { - /* The default GIC version (GICv2) should not be specified= on - * the QEMU commandline for backwards compatibility reason= s */ - if (def->gic_version !=3D VIR_GIC_VERSION_2) { - if (!virQEMUCapsGet(qemuCaps, - QEMU_CAPS_MACH_VIRT_GIC_VERSION)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("gic-version option is not availa= ble " - "with this QEMU binary")); - goto cleanup; - } + bool hasGICVersionOption =3D virQEMUCapsGet(qemuCaps, + QEMU_CAPS_MACH_VIRT_= GIC_VERSION); + + switch ((virGICVersion) def->gic_version) { + case VIR_GIC_VERSION_2: + if (!hasGICVersionOption) { + /* If the gic-version option is not available, we can't + * configure the GIC; however, we know that before the + * option was introduced the guests would always get a + * GICv2, so in order to maintain compatibility with + * those old QEMU versions all we need to do is stop + * early instead of erroring out */ + break; + } + ATTRIBUTE_FALLTHROUGH; =20 - virBufferAsprintf(&buf, ",gic-version=3D%s", - virGICVersionTypeToString(def->gic_v= ersion)); + case VIR_GIC_VERSION_3: + case VIR_GIC_VERSION_HOST: + if (!hasGICVersionOption) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("gic-version option is not available " + "with this QEMU binary")); + goto cleanup; } + + virBufferAsprintf(&buf, ",gic-version=3D%s", + virGICVersionTypeToString(def->gic_versi= on)); + break; + + case VIR_GIC_VERSION_NONE: + case VIR_GIC_VERSION_LAST: + default: + break; } } =20 diff --git a/tests/qemuxml2argvdata/aarch64-gic-none-tcg.args b/tests/qemux= ml2argvdata/aarch64-gic-none-tcg.args index 4e3c0eee2d..b766a821d5 100644 --- a/tests/qemuxml2argvdata/aarch64-gic-none-tcg.args +++ b/tests/qemuxml2argvdata/aarch64-gic-none-tcg.args @@ -7,7 +7,7 @@ QEMU_AUDIO_DRV=3Dnone \ /usr/bin/qemu-system-aarch64 \ -name guest \ -S \ --machine virt,accel=3Dtcg \ +-machine virt,accel=3Dtcg,gic-version=3D2 \ -cpu cortex-a57 \ -m 1024 \ -smp 1,sockets=3D1,cores=3D1,threads=3D1 \ diff --git a/tests/qemuxml2argvdata/aarch64-gic-v2.args b/tests/qemuxml2arg= vdata/aarch64-gic-v2.args index 7e88bbde3f..eec5c4a082 100644 --- a/tests/qemuxml2argvdata/aarch64-gic-v2.args +++ b/tests/qemuxml2argvdata/aarch64-gic-v2.args @@ -7,7 +7,7 @@ QEMU_AUDIO_DRV=3Dnone \ /usr/bin/qemu-system-aarch64 \ -name aarch64test \ -S \ --machine virt,accel=3Dkvm \ +-machine virt,accel=3Dkvm,gic-version=3D2 \ -cpu host \ -m 1024 \ -smp 1,sockets=3D1,cores=3D1,threads=3D1 \ diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 308d71f725..dee765d3dd 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2608,8 +2608,6 @@ mymain(void) DO_TEST("aarch64-cpu-passthrough", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIRTIO_MMIO, QEMU_CAPS_KVM); - DO_TEST_GIC("aarch64-gic-none", GIC_NONE, - QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT); DO_TEST_GIC("aarch64-gic-none", GIC_NONE, QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MACH_VIRT_GIC_VERSION); @@ -2625,8 +2623,6 @@ mymain(void) DO_TEST_GIC("aarch64-gic-none-tcg", GIC_BOTH, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MACH_VIRT_GIC_VERSION); - DO_TEST_GIC("aarch64-gic-default", GIC_NONE, - QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT); DO_TEST_GIC("aarch64-gic-default", GIC_NONE, QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MACH_VIRT_GIC_VERSION); @@ -2639,8 +2635,6 @@ mymain(void) DO_TEST_GIC("aarch64-gic-default-both", GIC_BOTH, QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MACH_VIRT_GIC_VERSION); - DO_TEST_GIC("aarch64-gic-v2", GIC_NONE, - QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT); DO_TEST_GIC("aarch64-gic-v2", GIC_NONE, QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MACH_VIRT_GIC_VERSION); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list