[libvirt] [PATCH 0/4] qemu: Add PCI support for RISC-V guests

Now that the QEMU part has been merged, it's time to make the feature available to libvirt users as well. Andrea Bolognani (4): tests: Add capabilities data for QEMU 4.0.0 on RISC-V qemu: Add PCI support for RISC-V guests tests: Add test for PCI usage on RISC-V news: Update for PCI support on RISC-V docs/news.xml | 10 + src/qemu/qemu_capabilities.c | 4 +- src/qemu/qemu_domain.c | 2 + src/qemu/qemu_domain_address.c | 3 +- .../caps_4.0.0.riscv32.replies | 17625 ++++++++++++++++ .../caps_4.0.0.riscv32.xml | 180 + .../caps_4.0.0.riscv64.replies | 17625 ++++++++++++++++ .../caps_4.0.0.riscv64.xml | 180 + tests/qemucapabilitiestest.c | 2 + .../caps_4.0.0.riscv32.xml | 25 + .../caps_4.0.0.riscv64.xml | 25 + tests/qemucaps2xmltest.c | 2 + .../riscv64-virt-headless.riscv64-latest.args | 3 +- tests/qemuxml2argvdata/riscv64-virt-pci.args | 27 + tests/qemuxml2argvdata/riscv64-virt-pci.xml | 24 + tests/qemuxml2argvtest.c | 2 + tests/qemuxml2xmloutdata/riscv64-virt-pci.xml | 28 + tests/qemuxml2xmltest.c | 2 + 18 files changed, 35766 insertions(+), 3 deletions(-) create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.riscv32.replies create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.riscv64.replies create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml create mode 100644 tests/qemucaps2xmloutdata/caps_4.0.0.riscv32.xml create mode 100644 tests/qemucaps2xmloutdata/caps_4.0.0.riscv64.xml create mode 100644 tests/qemuxml2argvdata/riscv64-virt-pci.args create mode 100644 tests/qemuxml2argvdata/riscv64-virt-pci.xml create mode 100644 tests/qemuxml2xmloutdata/riscv64-virt-pci.xml -- 2.20.1

Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- Aggressively snipped to avoid ending up in the moderation queue. Director's Cut available at https://github.com/andreabolognani/libvirt/tree/riscv-pci .../caps_4.0.0.riscv32.replies | 17625 ++++++++++++++++ .../caps_4.0.0.riscv32.xml | 180 + .../caps_4.0.0.riscv64.replies | 17625 ++++++++++++++++ .../caps_4.0.0.riscv64.xml | 180 + tests/qemucapabilitiestest.c | 2 + .../caps_4.0.0.riscv32.xml | 25 + .../caps_4.0.0.riscv64.xml | 25 + tests/qemucaps2xmltest.c | 2 + .../riscv64-virt-headless.riscv64-latest.args | 3 +- 9 files changed, 35666 insertions(+), 1 deletion(-) create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.riscv32.replies create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.riscv64.replies create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml create mode 100644 tests/qemucaps2xmloutdata/caps_4.0.0.riscv32.xml create mode 100644 tests/qemucaps2xmloutdata/caps_4.0.0.riscv64.xml diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.replies b/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.replies new file mode 100644 index 0000000000..2d3f2fbcc6 --- /dev/null +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.replies @@ -0,0 +1,17625 @@ +{ + "execute": "qmp_capabilities", + "id": "libvirt-1" +} + +{ + "return": { + }, + "id": "libvirt-1" +} + +{ + "execute": "query-version", + "id": "libvirt-2" +} + +{ + "return": { + "qemu": { + "micro": 50, + "minor": 1, + "major": 3 + }, + "package": "v3.1.0-1281-g006dce5f8f" + }, + "id": "libvirt-2" +} [...] diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml b/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml new file mode 100644 index 0000000000..15e447742d --- /dev/null +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml @@ -0,0 +1,180 @@ +<qemuCaps> [...] + <version>3001050</version> + <kvmVersion>0</kvmVersion> + <microcodeVersion>0</microcodeVersion> + <package>v3.1.0-1281-g006dce5f8f</package> + <arch>riscv32</arch> + <machine name='spike_v1.10' maxCpus='1' default='yes'/> + <machine name='virt' maxCpus='8'/> + <machine name='sifive_u' maxCpus='1'/> + <machine name='sifive_e' maxCpus='1'/> + <machine name='spike_v1.9.1' maxCpus='1'/> +</qemuCaps> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.replies b/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.replies new file mode 100644 index 0000000000..97d92290f6 --- /dev/null +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.replies @@ -0,0 +1,17625 @@ +{ + "execute": "qmp_capabilities", + "id": "libvirt-1" +} + +{ + "return": { + }, + "id": "libvirt-1" +} + +{ + "execute": "query-version", + "id": "libvirt-2" +} + +{ + "return": { + "qemu": { + "micro": 50, + "minor": 1, + "major": 3 + }, + "package": "v3.1.0-1281-g006dce5f8f" + }, + "id": "libvirt-2" +} [...] diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml new file mode 100644 index 0000000000..066c892eaa --- /dev/null +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml @@ -0,0 +1,180 @@ +<qemuCaps> [...] + <version>3001050</version> + <kvmVersion>0</kvmVersion> + <microcodeVersion>0</microcodeVersion> + <package>v3.1.0-1281-g006dce5f8f</package> + <arch>riscv64</arch> + <machine name='spike_v1.10' maxCpus='1' default='yes'/> + <machine name='virt' maxCpus='8'/> + <machine name='sifive_u' maxCpus='1'/> + <machine name='sifive_e' maxCpus='1'/> + <machine name='spike_v1.9.1' maxCpus='1'/> +</qemuCaps> diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c index 00137bb415..379a0986a6 100644 --- a/tests/qemucapabilitiestest.c +++ b/tests/qemucapabilitiestest.c @@ -197,7 +197,9 @@ mymain(void) DO_TEST("s390x", "caps_2.12.0"); DO_TEST("s390x", "caps_3.0.0"); DO_TEST("riscv32", "caps_3.0.0"); + DO_TEST("riscv32", "caps_4.0.0"); DO_TEST("riscv64", "caps_3.0.0"); + DO_TEST("riscv64", "caps_4.0.0"); /* * Run "tests/qemucapsprobe /path/to/qemu/binary >foo.replies" diff --git a/tests/qemucaps2xmloutdata/caps_4.0.0.riscv32.xml b/tests/qemucaps2xmloutdata/caps_4.0.0.riscv32.xml new file mode 100644 index 0000000000..63c374da7f --- /dev/null +++ b/tests/qemucaps2xmloutdata/caps_4.0.0.riscv32.xml @@ -0,0 +1,25 @@ +<capabilities> + + <host> + <cpu> + <arch>riscv32</arch> + </cpu> + <power_management/> + <iommu support='no'/> + </host> + + <guest> + <os_type>hvm</os_type> + <arch name='riscv32'> + <wordsize>32</wordsize> + <emulator>/usr/bin/qemu-system-riscv32</emulator> + <domain type='qemu'/> + </arch> + <features> + <cpuselection/> + <deviceboot/> + <disksnapshot default='on' toggle='no'/> + </features> + </guest> + +</capabilities> diff --git a/tests/qemucaps2xmloutdata/caps_4.0.0.riscv64.xml b/tests/qemucaps2xmloutdata/caps_4.0.0.riscv64.xml new file mode 100644 index 0000000000..09b7eb7f2f --- /dev/null +++ b/tests/qemucaps2xmloutdata/caps_4.0.0.riscv64.xml @@ -0,0 +1,25 @@ +<capabilities> + + <host> + <cpu> + <arch>riscv64</arch> + </cpu> + <power_management/> + <iommu support='no'/> + </host> + + <guest> + <os_type>hvm</os_type> + <arch name='riscv64'> + <wordsize>64</wordsize> + <emulator>/usr/bin/qemu-system-riscv64</emulator> + <domain type='qemu'/> + </arch> + <features> + <cpuselection/> + <deviceboot/> + <disksnapshot default='on' toggle='no'/> + </features> + </guest> + +</capabilities> diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c index dd9fc6917a..150273f67a 100644 --- a/tests/qemucaps2xmltest.c +++ b/tests/qemucaps2xmltest.c @@ -215,7 +215,9 @@ mymain(void) DO_TEST("s390x", "caps_2.12.0"); DO_TEST("s390x", "caps_3.0.0"); DO_TEST("riscv32", "caps_3.0.0"); + DO_TEST("riscv32", "caps_4.0.0"); DO_TEST("riscv64", "caps_3.0.0"); + DO_TEST("riscv64", "caps_4.0.0"); return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemuxml2argvdata/riscv64-virt-headless.riscv64-latest.args b/tests/qemuxml2argvdata/riscv64-virt-headless.riscv64-latest.args index 191550e36b..8a28c035d7 100644 --- a/tests/qemuxml2argvdata/riscv64-virt-headless.riscv64-latest.args +++ b/tests/qemuxml2argvdata/riscv64-virt-headless.riscv64-latest.args @@ -25,7 +25,8 @@ file=/tmp/lib/domain--1-guest/master-key.aes \ -device virtio-serial-device,id=virtio-serial0 \ -drive file=/var/lib/libvirt/images/guest.qcow2,format=qcow2,if=none,\ id=drive-virtio-disk0 \ --device virtio-blk-device,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ +-device virtio-blk-device,scsi=off,drive=drive-virtio-disk0,id=virtio-disk0,\ +bootindex=1 \ -netdev user,id=hostnet0 \ -device virtio-net-device,netdev=hostnet0,id=net0,mac=52:54:00:09:a4:37 \ -chardev pty,id=charserial0 \ -- 2.20.1

On Thu, Jan 31, 2019 at 03:34:18PM +0100, Andrea Bolognani wrote:
Signed-off-by: Andrea Bolognani <abologna@redhat.com> ---
Aggressively snipped to avoid ending up in the moderation queue.
Director's Cut available at
PG-13
.../caps_4.0.0.riscv32.replies | 17625 ++++++++++++++++ .../caps_4.0.0.riscv32.xml | 180 + .../caps_4.0.0.riscv64.replies | 17625 ++++++++++++++++ .../caps_4.0.0.riscv64.xml | 180 + tests/qemucapabilitiestest.c | 2 + .../caps_4.0.0.riscv32.xml | 25 + .../caps_4.0.0.riscv64.xml | 25 + tests/qemucaps2xmltest.c | 2 + .../riscv64-virt-headless.riscv64-latest.args | 3 +- 9 files changed, 35666 insertions(+), 1 deletion(-) create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.riscv32.replies create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.riscv64.replies create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml create mode 100644 tests/qemucaps2xmloutdata/caps_4.0.0.riscv32.xml create mode 100644 tests/qemucaps2xmloutdata/caps_4.0.0.riscv64.xml
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

virtio-mmio is still used by default, so if PCI is desired it's necessary to explicitly opt-in by adding an appropriate <address type='pci' domain='0x0000' ... /> element to the corresponding device. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/qemu/qemu_capabilities.c | 4 +++- src/qemu/qemu_domain.c | 2 ++ src/qemu/qemu_domain_address.c | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index f504db7d05..6fe8693170 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1741,8 +1741,10 @@ bool virQEMUCapsHasPCIMultiBus(virQEMUCapsPtr qemuCaps, /* If ARM 'virt' supports PCI, it supports multibus. * No extra conditions here for simplicity. */ - if (qemuDomainIsARMVirt(def)) + if (qemuDomainIsARMVirt(def) || + qemuDomainIsRISCVVirt(def)) { return true; + } return false; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5bfe4fe14e..0b8e6fa011 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3380,6 +3380,8 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, case VIR_ARCH_RISCV32: case VIR_ARCH_RISCV64: addDefaultUSB = false; + if (qemuDomainIsRISCVVirt(def)) + addPCIeRoot = virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_GPEX); break; case VIR_ARCH_S390: diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index c376f3f897..c35ecd8585 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -2369,7 +2369,8 @@ qemuDomainSupportsPCI(virDomainDefPtr def, if (STREQ(def->os.machine, "versatilepb")) return true; - if (qemuDomainIsARMVirt(def) && + if ((qemuDomainIsARMVirt(def) || + qemuDomainIsRISCVVirt(def)) && virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_GPEX)) return true; -- 2.20.1

On Thu, Jan 31, 2019 at 03:34:19PM +0100, Andrea Bolognani wrote:
virtio-mmio is still used by default, so if PCI is desired it's necessary to explicitly opt-in by adding an appropriate
<address type='pci' domain='0x0000' ... />
element to the corresponding device.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/qemu/qemu_capabilities.c | 4 +++- src/qemu/qemu_domain.c | 2 ++ src/qemu/qemu_domain_address.c | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index f504db7d05..6fe8693170 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1741,8 +1741,10 @@ bool virQEMUCapsHasPCIMultiBus(virQEMUCapsPtr qemuCaps, /* If ARM 'virt' supports PCI, it supports multibus. * No extra conditions here for simplicity. */ - if (qemuDomainIsARMVirt(def)) + if (qemuDomainIsARMVirt(def) || + qemuDomainIsRISCVVirt(def)) { return true; + }
The comment above only mentions arm. Either decouple the conditions or remove the comment. For simplicity.
return false; }
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

On Thu, 2019-01-31 at 17:31 +0100, Ján Tomko wrote:
On Thu, Jan 31, 2019 at 03:34:19PM +0100, Andrea Bolognani wrote:
/* If ARM 'virt' supports PCI, it supports multibus. * No extra conditions here for simplicity. */ - if (qemuDomainIsARMVirt(def)) + if (qemuDomainIsARMVirt(def) || + qemuDomainIsRISCVVirt(def)) { return true; + }
The comment above only mentions arm. Either decouple the conditions or remove the comment. For simplicity.
Good catch, I'll take care of it. -- Andrea Bolognani / Red Hat / Virtualization

This shows users can now use PCI for RISC-V guests, as long as they opt into it by manually assigning addresses. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- tests/qemuxml2argvdata/riscv64-virt-pci.args | 27 ++++++++++++++++++ tests/qemuxml2argvdata/riscv64-virt-pci.xml | 24 ++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ tests/qemuxml2xmloutdata/riscv64-virt-pci.xml | 28 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 ++ 5 files changed, 83 insertions(+) create mode 100644 tests/qemuxml2argvdata/riscv64-virt-pci.args create mode 100644 tests/qemuxml2argvdata/riscv64-virt-pci.xml create mode 100644 tests/qemuxml2xmloutdata/riscv64-virt-pci.xml diff --git a/tests/qemuxml2argvdata/riscv64-virt-pci.args b/tests/qemuxml2argvdata/riscv64-virt-pci.args new file mode 100644 index 0000000000..6fc3316125 --- /dev/null +++ b/tests/qemuxml2argvdata/riscv64-virt-pci.args @@ -0,0 +1,27 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-riscv64 \ +-name riscv64 \ +-S \ +-machine virt,accel=tcg,usb=off,dump-guest-core=off \ +-m 2048 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid fd65fc03-8838-4c4d-9d8d-395802488790 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-riscv64/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-kernel /var/lib/libvirt/images/riscv64.bbl \ +-append root=/dev/vda \ +-drive file=/var/lib/libvirt/images/riscv64.qcow2,format=qcow2,if=none,\ +id=drive-virtio-disk0 \ +-device virtio-blk-pci,bus=pcie.0,addr=0x1,drive=drive-virtio-disk0,\ +id=virtio-disk0,bootindex=1 diff --git a/tests/qemuxml2argvdata/riscv64-virt-pci.xml b/tests/qemuxml2argvdata/riscv64-virt-pci.xml new file mode 100644 index 0000000000..c72cd58086 --- /dev/null +++ b/tests/qemuxml2argvdata/riscv64-virt-pci.xml @@ -0,0 +1,24 @@ +<domain type='qemu'> + <name>riscv64</name> + <uuid>fd65fc03-8838-4c4d-9d8d-395802488790</uuid> + <memory unit='KiB'>2097152</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='riscv64' machine='virt'>hvm</type> + <kernel>/var/lib/libvirt/images/riscv64.bbl</kernel> + <cmdline>root=/dev/vda</cmdline> + </os> + <devices> + <emulator>/usr/bin/qemu-system-riscv64</emulator> + <disk type='file'> + <driver name='qemu' type='qcow2'/> + <source file='/var/lib/libvirt/images/riscv64.qcow2'/> + <target dev='vda' bus='virtio'/> + <!-- We need to manually pick an address on pcie.0 because otherwise + libvirt would try to add pcie-root-ports, and QEMU doesn't support + PCIe controllers for RISC-V guests yet --> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/> + </disk> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index ba6fd4db35..6dc05c347f 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3072,6 +3072,8 @@ mymain(void) DO_TEST("riscv64-virt", QEMU_CAPS_DEVICE_VIRTIO_MMIO); + DO_TEST("riscv64-virt-pci", + QEMU_CAPS_OBJECT_GPEX); /* Simple headless guests for various architectures */ DO_TEST_CAPS_ARCH_LATEST("aarch64-virt-headless", "aarch64"); diff --git a/tests/qemuxml2xmloutdata/riscv64-virt-pci.xml b/tests/qemuxml2xmloutdata/riscv64-virt-pci.xml new file mode 100644 index 0000000000..163dc0a530 --- /dev/null +++ b/tests/qemuxml2xmloutdata/riscv64-virt-pci.xml @@ -0,0 +1,28 @@ +<domain type='qemu'> + <name>riscv64</name> + <uuid>fd65fc03-8838-4c4d-9d8d-395802488790</uuid> + <memory unit='KiB'>2097152</memory> + <currentMemory unit='KiB'>2097152</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='riscv64' machine='virt'>hvm</type> + <kernel>/var/lib/libvirt/images/riscv64.bbl</kernel> + <cmdline>root=/dev/vda</cmdline> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-riscv64</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2'/> + <source file='/var/lib/libvirt/images/riscv64.qcow2'/> + <target dev='vda' bus='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/> + </disk> + <controller type='pci' index='0' model='pcie-root'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index b2c0c8505d..85261cb2e0 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1267,6 +1267,8 @@ mymain(void) DO_TEST("riscv64-virt", QEMU_CAPS_DEVICE_VIRTIO_MMIO); + DO_TEST("riscv64-virt-pci", + QEMU_CAPS_OBJECT_GPEX); if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL) virFileDeleteTree(fakerootdir); -- 2.20.1

On Thu, Jan 31, 2019 at 03:34:20PM +0100, Andrea Bolognani wrote:
This shows users can now use PCI for RISC-V guests, as long as they opt into it by manually assigning addresses.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- tests/qemuxml2argvdata/riscv64-virt-pci.args | 27 ++++++++++++++++++ tests/qemuxml2argvdata/riscv64-virt-pci.xml | 24 ++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ tests/qemuxml2xmloutdata/riscv64-virt-pci.xml | 28 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 ++ 5 files changed, 83 insertions(+) create mode 100644 tests/qemuxml2argvdata/riscv64-virt-pci.args create mode 100644 tests/qemuxml2argvdata/riscv64-virt-pci.xml create mode 100644 tests/qemuxml2xmloutdata/riscv64-virt-pci.xml
diff --git a/tests/qemuxml2argvdata/riscv64-virt-pci.args b/tests/qemuxml2argvdata/riscv64-virt-pci.args new file mode 100644 index 0000000000..6fc3316125 --- /dev/null +++ b/tests/qemuxml2argvdata/riscv64-virt-pci.args @@ -0,0 +1,27 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-riscv64 \ +-name riscv64 \ +-S \ +-machine virt,accel=tcg,usb=off,dump-guest-core=off \ +-m 2048 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid fd65fc03-8838-4c4d-9d8d-395802488790 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-riscv64/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-kernel /var/lib/libvirt/images/riscv64.bbl \ +-append root=/dev/vda \ +-drive file=/var/lib/libvirt/images/riscv64.qcow2,format=qcow2,if=none,\ +id=drive-virtio-disk0 \ +-device virtio-blk-pci,bus=pcie.0,addr=0x1,drive=drive-virtio-disk0,\ +id=virtio-disk0,bootindex=1 diff --git a/tests/qemuxml2argvdata/riscv64-virt-pci.xml b/tests/qemuxml2argvdata/riscv64-virt-pci.xml new file mode 100644 index 0000000000..c72cd58086 --- /dev/null +++ b/tests/qemuxml2argvdata/riscv64-virt-pci.xml @@ -0,0 +1,24 @@ +<domain type='qemu'> + <name>riscv64</name> + <uuid>fd65fc03-8838-4c4d-9d8d-395802488790</uuid> + <memory unit='KiB'>2097152</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='riscv64' machine='virt'>hvm</type> + <kernel>/var/lib/libvirt/images/riscv64.bbl</kernel> + <cmdline>root=/dev/vda</cmdline> + </os> + <devices> + <emulator>/usr/bin/qemu-system-riscv64</emulator> + <disk type='file'> + <driver name='qemu' type='qcow2'/> + <source file='/var/lib/libvirt/images/riscv64.qcow2'/> + <target dev='vda' bus='virtio'/> + <!-- We need to manually pick an address on pcie.0 because otherwise + libvirt would try to add pcie-root-ports, and QEMU doesn't support + PCIe controllers for RISC-V guests yet --> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/> + </disk> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index ba6fd4db35..6dc05c347f 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3072,6 +3072,8 @@ mymain(void)
DO_TEST("riscv64-virt", QEMU_CAPS_DEVICE_VIRTIO_MMIO); + DO_TEST("riscv64-virt-pci", + QEMU_CAPS_OBJECT_GPEX);
Consider giving DO_TEST_CAPS_ARCH_LATEST a chance, for more faithful viewer experience. Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

On Thu, 2019-01-31 at 17:32 +0100, Ján Tomko wrote:
On Thu, Jan 31, 2019 at 03:34:20PM +0100, Andrea Bolognani wrote:
+++ b/tests/qemuxml2argvtest.c @@ -3072,6 +3072,8 @@ mymain(void)
DO_TEST("riscv64-virt", QEMU_CAPS_DEVICE_VIRTIO_MMIO); + DO_TEST("riscv64-virt-pci", + QEMU_CAPS_OBJECT_GPEX);
Consider giving DO_TEST_CAPS_ARCH_LATEST a chance, for more faithful viewer experience.
I would have used it, but that would have resulted in the qemuxml2xml version being different because the macro is not available in that test program. Cole has taken a stab at implementing it there too a couple of weeks ago, but ultimately shelved the attempt to avoid getting the rest of the (non-)transitional VirtIO work blocked on it. Since I have a few more or less related gripes about the test suite, I might end up picking up where he left and address those as well. -- Andrea Bolognani / Red Hat / Virtualization

Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- docs/news.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 2aa4ed25d6..55d6a3926b 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -61,6 +61,16 @@ the options added are "nosuid, noexec". </description> </change> + <change> + <summary> + qemu: Allow use of PCI for RISC-V guests + </summary> + <description> + This works with QEMU 4.0.0+ only and is opt-in at the moment, since + it requires users to manually assign PCI addresses, but is otherwise + fully functional. + </description> + </change> </section> </release> <release version="v5.0.0" date="2019-01-15"> -- 2.20.1

On Thu, Jan 31, 2019 at 03:34:21PM +0100, Andrea Bolognani wrote:
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- docs/news.xml | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/docs/news.xml b/docs/news.xml index 2aa4ed25d6..55d6a3926b 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -61,6 +61,16 @@ the options added are "nosuid, noexec". </description> </change> + <change> + <summary> + qemu: Allow use of PCI for RISC-V guests + </summary> + <description> + This works with QEMU 4.0.0+ only and is opt-in at the moment, since + it requires users to manually assign PCI addresses,
but is otherwise + fully functional.
Claim. Bold claim. Regardless: Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Andrea Bolognani
-
Ján Tomko