[libvirt] [PATCH v2 10/11] tests/qemuxml2argvtest: test RISC-V virt machine arguments

Lubomir Rintel posted 11 patches 7 years ago
Only 10 patches received!
There is a newer version of this series
[libvirt] [PATCH v2 10/11] tests/qemuxml2argvtest: test RISC-V virt machine arguments
Posted by Lubomir Rintel 7 years ago
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 tests/qemuxml2argvdata/riscv64-virt.args      | 31 +++++++++++++++
 tests/qemuxml2argvdata/riscv64-virt.xml       | 32 +++++++++++++++
 tests/qemuxml2argvtest.c                      |  3 ++
 .../riscv64-virt.xml                          | 39 +++++++++++++++++++
 4 files changed, 105 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/riscv64-virt.args
 create mode 100644 tests/qemuxml2argvdata/riscv64-virt.xml
 create mode 100644 tests/qemuxml2startupxmloutdata/riscv64-virt.xml

diff --git a/tests/qemuxml2argvdata/riscv64-virt.args b/tests/qemuxml2argvdata/riscv64-virt.args
new file mode 100644
index 0000000000..1833242753
--- /dev/null
+++ b/tests/qemuxml2argvdata/riscv64-virt.args
@@ -0,0 +1,31 @@
+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 \
+-boot c \
+-kernel /var/lib/libvirt/images/bbl \
+-append 'console=ttyS0 ro root=/dev/vda' \
+-usb \
+-drive file=/var/lib/libvirt/images/stage4-disk.img,format=raw,if=none,\
+id=drive-virtio-disk0 \
+-device virtio-blk-device,drive=drive-virtio-disk0,id=virtio-disk0 \
+-chardev pty,id=charserial0 \
+-serial chardev:charserial0 \
+-device virtio-balloon-device,id=balloon0
diff --git a/tests/qemuxml2argvdata/riscv64-virt.xml b/tests/qemuxml2argvdata/riscv64-virt.xml
new file mode 100644
index 0000000000..6a2d072d3c
--- /dev/null
+++ b/tests/qemuxml2argvdata/riscv64-virt.xml
@@ -0,0 +1,32 @@
+<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/bbl</kernel>
+    <cmdline>console=ttyS0 ro 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='raw'/>
+      <source file='/var/lib/libvirt/images/stage4-disk.img'/>
+      <target dev='vda' bus='virtio'/>
+      <address type='virtio-mmio'/>
+    </disk>
+    <serial type='pty'>
+      <target port='0'/>
+    </serial>
+    <console type='pty'>
+      <target type='serial' port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index f44cac9fef..9c4cf1bb37 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -2903,6 +2903,9 @@ mymain(void)
             QEMU_CAPS_KVM,
             QEMU_CAPS_SEV_GUEST);
 
+    DO_TEST("riscv64-virt",
+            QEMU_CAPS_DEVICE_VIRTIO_MMIO);
+
     if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
         virFileDeleteTree(fakerootdir);
 
diff --git a/tests/qemuxml2startupxmloutdata/riscv64-virt.xml b/tests/qemuxml2startupxmloutdata/riscv64-virt.xml
new file mode 100644
index 0000000000..e23b3ffbad
--- /dev/null
+++ b/tests/qemuxml2startupxmloutdata/riscv64-virt.xml
@@ -0,0 +1,39 @@
+<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/bbl</kernel>
+    <cmdline>console=ttyS0 ro 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='raw'/>
+      <source file='/var/lib/libvirt/images/stage4-disk.img'/>
+      <target dev='vda' bus='virtio'/>
+      <alias name='virtio-disk0'/>
+      <address type='virtio-mmio'/>
+    </disk>
+    <serial type='pty'>
+      <target port='0'/>
+      <alias name='serial0'/>
+    </serial>
+    <console type='pty'>
+      <target type='serial' port='0'/>
+      <alias name='serial0'/>
+    </console>
+    <memballoon model='virtio'>
+      <alias name='balloon0'/>
+      <address type='virtio-mmio'/>
+    </memballoon>
+  </devices>
+</domain>
-- 
2.17.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 10/11] tests/qemuxml2argvtest: test RISC-V virt machine arguments
Posted by Andrea Bolognani 7 years ago
On Thu, 2018-06-14 at 22:32 +0200, Lubomir Rintel wrote:
[...]
> +++ b/tests/qemuxml2argvdata/riscv64-virt.xml
> @@ -0,0 +1,32 @@
> +<domain type='qemu'>
> +  <name>riscv64</name>
> +  <uuid>fd65fc03-8838-4c4d-9d8d-395802488790</uuid>

A lot of the information you included in this file can be omitted,
and doing so not only highlights which parts actually matter, but
also ensures that libvirt is able to fill in the blanks on its own
as you would expect it to.

  <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/bbl</kernel>
      <cmdline>console=ttyS0 ro root=/dev/vda</cmdline>
    </os>
    <devices>
      <emulator>/usr/bin/qemu-system-riscv64</emulator>
      <disk type='file'>
        <source file='/var/lib/libvirt/images/stage4-disk.img'/>
        <target dev='vda' bus='virtio'/>
      </disk>
      <serial type='pty'/>
    </devices>
  </domain>

The above is all you need.

[...]
> +++ b/tests/qemuxml2argvtest.c
> @@ -2903,6 +2903,9 @@ mymain(void)
>              QEMU_CAPS_KVM,
>              QEMU_CAPS_SEV_GUEST);
>  
> +    DO_TEST("riscv64-virt",
> +            QEMU_CAPS_DEVICE_VIRTIO_MMIO);

You forgot to add the same snippet to tests/qemuxml2xmltest.c, and
without that XML round-trip will not actually be tested :)


With the above addressed,

  Reviewed-by: Andrea Bolognani <abologna@redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list