[libvirt] [PATCH v1 5/6] tests: Add tests for ivshmem device handling

Martin Kletzander mkletzan at redhat.com
Tue Aug 26 09:02:56 UTC 2014


On Fri, Aug 22, 2014 at 12:47:04PM +0200, Maxime Leroy wrote:
>Add XML parsing and qemu command line tests for the ivshmem
>device support.
>
>Signed-off-by: Maxime Leroy <maxime.leroy at 6wind.com>
>---
> tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args | 10 +++++++
> tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml  | 35 ++++++++++++++++++++++++
> tests/qemuxml2argvtest.c                         |  3 ++
> tests/qemuxml2xmltest.c                          |  2 ++
> 4 files changed, 50 insertions(+)
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml
>
>diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args b/tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args
>new file mode 100644
>index 0000000..8a5cc0f
>--- /dev/null
>+++ b/tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args
>@@ -0,0 +1,10 @@
>+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
>+/usr/bin/qemu -S \
>+-M pc -m 214 -smp 1 -nographic -nodefaults \
>+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
>+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \
>+-device ivshmem,chardev=charshmem0,msi=on,vectors=32,ioeventfd=on \
>+-chardev socket,id=charshmem0,path=/tmp/socket-shmem0 \
>+-device ivshmem,size=32m,chardev=charshmem1,msi=on,vectors=32 \
>+-chardev socket,id=charshmem1,path=/tmp/socket-shmem1 \
>+-device ivshmem,size=32m,shm=shmem2,bus=pci.0,addr=0x8
>diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml b/tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml
>new file mode 100644
>index 0000000..7177612
>--- /dev/null
>+++ b/tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml
>@@ -0,0 +1,35 @@
>+<domain type='qemu'>
>+  <name>QEMUGuest1</name>
>+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
>+  <memory unit='KiB'>219100</memory>
>+  <currentMemory unit='KiB'>219100</currentMemory>
>+  <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
>+  <os>
>+    <type arch='x86_64' machine='pc'>hvm</type>
>+    <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</emulator>
>+    <controller type='usb' index='0'/>
>+    <controller type='ide' index='0'/>
>+    <controller type='pci' index='0' model='pci-root'/>
>+    <memballoon model='virtio'/>
>+    <shmem name='shmem0' model='ivshmem'>
>+      <server path='/tmp/socket-shmem0'/>
>+      <msi vectors='32' ioeventfd='on'/>
>+    </shmem>
>+    <shmem name='shmem1' model='ivshmem'>
>+      <server path='/tmp/socket-shmem1'/>
>+      <size unit='M'>32</size>
>+      <msi vectors='32'/>

The qemuxml2xmltest didn't faile with this xml, which means we are not
allocating addresses for shmem devices.  We have to do that and put it
in the XML so (a) the address won't change and (b) that we know which
address is occupied by that in case we'll want to attach something to
the VM.

And xml2xml (and PARSE_ERROR xml2argv) tests can be squashed into the patch
with documentation and parsing.  Other xml2argv tests can be squashed
into the patch where qemu formats the command-line.

Martin

>+    </shmem>
>+    <shmem name='shmem2' model='ivshmem'>
>+      <size unit='M'>32</size>
>+      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
>+    </shmem>
>+  </devices>
>+</domain>
>diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
>index 65dc9c7..f91ac36 100644
>--- a/tests/qemuxml2argvtest.c
>+++ b/tests/qemuxml2argvtest.c
>@@ -1431,6 +1431,9 @@ mymain(void)
>     DO_TEST("panic", QEMU_CAPS_DEVICE_PANIC,
>             QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
>
>+    DO_TEST("ivshmem", QEMU_CAPS_PCIDEVICE,
>+            QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_IVSHMEM);
>+
>     virObjectUnref(driver.config);
>     virObjectUnref(driver.caps);
>     virObjectUnref(driver.xmlopt);
>diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
>index 5941323..4e62fe9 100644
>--- a/tests/qemuxml2xmltest.c
>+++ b/tests/qemuxml2xmltest.c
>@@ -388,6 +388,8 @@ mymain(void)
>     DO_TEST_DIFFERENT("numatune-memnode");
>     DO_TEST("numatune-memnode-no-memory");
>
>+    DO_TEST("ivshmem");
>+
>     virObjectUnref(driver.caps);
>     virObjectUnref(driver.xmlopt);
>
>--
>1.9.3
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140826/ffb79402/attachment-0001.sig>


More information about the libvir-list mailing list