From patchwork Thu Jan 28 21:14:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 60768 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp726536lbb; Thu, 28 Jan 2016 13:17:48 -0800 (PST) X-Received: by 10.140.162.2 with SMTP id i2mr3791522qhi.44.1454015868877; Thu, 28 Jan 2016 13:17:48 -0800 (PST) Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com. [209.132.183.39]) by mx.google.com with ESMTPS id d126si11549365qkb.84.2016.01.28.13.17.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jan 2016 13:17:48 -0800 (PST) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0SLEkcc001714; Thu, 28 Jan 2016 16:14:46 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u0SLEUG8003625 for ; Thu, 28 Jan 2016 16:14:30 -0500 Received: from colepc.redhat.com (ovpn-113-198.phx2.redhat.com [10.3.113.198]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0SLEQmb014718; Thu, 28 Jan 2016 16:14:29 -0500 From: Cole Robinson To: libvirt-list@redhat.com Date: Thu, 28 Jan 2016 16:14:21 -0500 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Andrea Bolognani , Laine Stump Subject: [libvirt] [PATCH 2/2] HACK: qemu: aarch64: Use virtio-pci if user specifies PCI controller 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 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com If a user manually specifies this XML snippet for aarch64 machvirt: Libvirt will interpret this to mean that the OS supports virtio-pci, and will allocate PCI addresses (instead of virtio-mmio) for virtio devices. This is a giant hack. Trying to improve it led me into the maze of PCI address code and I gave up for now. Here are the issues: * I'd prefer that to be model='pcie-root' which matches what qemu-system-aarch64 -M virt actually provides by default... however libvirt isn't happy with a single pcie-root specified by the user, it will error with: error: unsupported configuration: failed to create PCI bridge on bus 1: too many devices with fixed addresses Instead this patch uses hacks to make pci-root use the pcie.0 bus for aarch64, since that code path already works. * It may even be nice to make specifying map to 'give me the recommended PCI setup for this VM'... then we could adjust what that default means in the future, maybe switching to something like what q35 uses. This would make apps lives easier. But presently that violates the XML schema, and libvirt can't handle lack of model= anyways: error: internal error: Invalid PCI controller model -1 --- src/qemu/qemu_command.c | 34 ++++++++---- ...l2argv-aarch64-pci-manual-nocontroller-fail.xml | 43 ++++++++++++++++ ...l2argv-aarch64-virtio-pci-manual-addresses.args | 2 - ...ml2argv-aarch64-virtio-pci-manual-addresses.xml | 1 + ...2argv-aarch64-virtio-pci-manual-controller.args | 36 +++++++++++++ ...l2argv-aarch64-virtio-pci-manual-controller.xml | 50 ++++++++++++++++++ tests/qemuxml2argvtest.c | 20 ++++++-- ...2xmlout-aarch64-virtio-pci-manual-addresses.xml | 11 +--- ...xmlout-aarch64-virtio-pci-manual-controller.xml | 60 ++++++++++++++++++++++ tests/qemuxml2xmltest.c | 8 ++- 10 files changed, 239 insertions(+), 26 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-pci-manual-nocontroller-fail.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-controller.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-controller.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-controller.xml -- 2.5.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8943270..4b0f070 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1064,7 +1064,10 @@ qemuAssignDeviceControllerAlias(virDomainDefPtr domainDef, * (including the hardcoded pci-root controller on * multibus-capable qemus). */ - return virAsprintf(&controller->info.alias, "pci.%d", controller->idx); + if (domainDef->os.arch == VIR_ARCH_AARCH64) + return virAsprintf(&controller->info.alias, "pcie.%d", controller->idx); + else + return virAsprintf(&controller->info.alias, "pci.%d", controller->idx); } else if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE) { /* for any machine based on e.g. I440FX or G3Beige, the * first (and currently only) IDE controller is an integrated @@ -1393,15 +1396,28 @@ static int qemuDomainAssignARMVirtioMMIOAddresses(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) { - if (((def->os.arch == VIR_ARCH_ARMV7L) || - (def->os.arch == VIR_ARCH_AARCH64)) && - (STRPREFIX(def->os.machine, "vexpress-") || - STREQ(def->os.machine, "virt") || - STRPREFIX(def->os.machine, "virt-")) && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MMIO)) { - qemuDomainPrimeVirtioDeviceAddresses( - def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO); + size_t i; + + if ((def->os.arch != VIR_ARCH_ARMV7L) && + (def->os.arch != VIR_ARCH_AARCH64)) + return 0; + + if (!(STRPREFIX(def->os.machine, "vexpress-") || + STREQ(def->os.machine, "virt") || + STRPREFIX(def->os.machine, "virt-"))) + return 0; + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MMIO)) + return 0; + + /* If there's a PCIe controller in the XML, we will use PCI virtio */ + for (i = 0; i < def->ncontrollers; i++) { + if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) + return 0; } + + qemuDomainPrimeVirtioDeviceAddresses( + def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO); return 0; } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-pci-manual-nocontroller-fail.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-pci-manual-nocontroller-fail.xml new file mode 100644 index 0000000..6a44f19 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-pci-manual-nocontroller-fail.xml @@ -0,0 +1,43 @@ + + aarch64test + 496d7ea8-9739-544b-4ebd-ef08be936e8b + 1048576 + 1048576 + 1 + + hvm + /aarch64.kernel + /aarch64.initrd + earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait + /aarch64.dtb + + + + + + + + + cortex-a53 + + + destroy + restart + restart + + /usr/bin/qemu-system-aarch64 + + + +
+ + +
+ + + + +
+ + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.args index 142fd5b..f091c89 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.args @@ -21,8 +21,6 @@ QEMU_AUDIO_DRV=none \ -initrd /aarch64.initrd \ -append 'earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait' \ -dtb /aarch64.dtb \ --device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1 \ --device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x1 \ -device virtio-scsi-pci,id=scsi0,bus=pcie.0,addr=0x3 \ -usb \ -drive file=/aarch64.raw,format=raw,if=none,id=drive-scsi0-0-0-0 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.xml index 6a44f19..80a6592 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.xml @@ -31,6 +31,7 @@
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-controller.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-controller.args new file mode 100644 index 0000000..dfa07da --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-controller.args @@ -0,0 +1,36 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-aarch64 \ +-name aarch64test \ +-S \ +-M virt \ +-cpu cortex-a53 \ +-m 1024 \ +-smp 1 \ +-uuid 496d7ea8-9739-544b-4ebd-ef08be936e8b \ +-nographic \ +-nodefconfig \ +-nodefaults \ +-monitor unix:/tmp/test-monitor,server,nowait \ +-boot c \ +-kernel /aarch64.kernel \ +-initrd /aarch64.initrd \ +-append 'earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait' \ +-dtb /aarch64.dtb \ +-device virtio-serial-pci,id=virtio-serial0,bus=pcie.0,addr=0x2 \ +-usb \ +-drive file=/aarch64.raw,format=raw,if=none,id=drive-virtio-disk0 \ +-device virtio-blk-pci,bus=pcie.0,addr=0x3,drive=drive-virtio-disk0,\ +id=virtio-disk0 \ +-device virtio-net-pci,vlan=0,id=net0,mac=52:54:00:09:a4:37,bus=pcie.0,addr=0x1 \ +-net user,vlan=0,name=hostnet0 \ +-serial pty \ +-chardev pty,id=charconsole1 \ +-device virtconsole,chardev=charconsole1,id=console1 \ +-device virtio-balloon-pci,id=balloon0,bus=pcie.0,addr=0x4 \ +-object rng-random,id=objrng0,filename=/dev/random \ +-device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0,addr=0x5 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-controller.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-controller.xml new file mode 100644 index 0000000..c5ea728 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-controller.xml @@ -0,0 +1,50 @@ + + aarch64test + 496d7ea8-9739-544b-4ebd-ef08be936e8b + 1048576 + 1048576 + 1 + + hvm + /aarch64.kernel + /aarch64.initrd + earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait + /aarch64.dtb + + + + + + + + + cortex-a53 + + + destroy + restart + restart + + /usr/bin/qemu-system-aarch64 + + + + + + + + + + + + + + + + + /dev/random + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index b2f636e..6c5a8ab 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1649,9 +1649,23 @@ mymain(void) QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM, QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE); - /* Example of using virtio-pci with no explicit PCI controller - but with manual PCI addresses */ - DO_TEST_PARSE_ERROR("aarch64-virtio-pci-manual-addresses", + /* Example of using virtio-pci with manual PCIe controller and auto + allocated addresses */ + DO_TEST("aarch64-virtio-pci-manual-controller", + QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB, + QEMU_CAPS_DEVICE_VIRTIO_MMIO, + QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM, + QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE, + QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_VIRTIO_SCSI); + /* Example of using virtio-pci with manual PCIe controller and + manual PCI addresses */ + DO_TEST("aarch64-virtio-pci-manual-addresses", + QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB, + QEMU_CAPS_DEVICE_VIRTIO_MMIO, + QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM, + QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE, + QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_VIRTIO_SCSI); + DO_TEST_PARSE_ERROR("aarch64-pci-manual-nocontroller-fail", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB, QEMU_CAPS_DEVICE_VIRTIO_MMIO, QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM, diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml index 4add271..80a6592 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml @@ -31,19 +31,10 @@
+
- - - -
- - - - -
- diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-controller.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-controller.xml new file mode 100644 index 0000000..7be2cbd --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-controller.xml @@ -0,0 +1,60 @@ + + aarch64test + 496d7ea8-9739-544b-4ebd-ef08be936e8b + 1048576 + 1048576 + 1 + + hvm + /aarch64.kernel + /aarch64.initrd + earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait + /aarch64.dtb + + + + + + + + + cortex-a53 + + + destroy + restart + restart + + /usr/bin/qemu-system-aarch64 + + + +
+ + + +
+ + + + +
+ + + + + + + + + + + +
+ + + /dev/random +
+ + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index cac401c..e7f8845 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -731,14 +731,18 @@ mymain(void) QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM, QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_VIRTIO_SCSI); - /* + DO_TEST_FULL("aarch64-virtio-pci-manual-controller", WHEN_ACTIVE, + QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB, + QEMU_CAPS_DEVICE_VIRTIO_MMIO, + QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM, + QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE, + QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_VIRTIO_SCSI); DO_TEST_FULL("aarch64-virtio-pci-manual-addresses", WHEN_ACTIVE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB, QEMU_CAPS_DEVICE_VIRTIO_MMIO, QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM, QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_VIRTIO_SCSI); - */ DO_TEST("aarch64-gic"); DO_TEST("aarch64-gicv3");