This patch adds tests for scsi hostdev.
Signed-off-by: Han Cheng <hanc.fnst(a)cn.fujitsu.com>
---
.../qemuxml2argv-hostdev-scsi-boot.args | 10 ++++++
.../qemuxml2argv-hostdev-scsi-boot.xml | 34 +++++++++++++++++++
.../qemuxml2argv-hostdev-scsi-readonly.args | 10 ++++++
.../qemuxml2argv-hostdev-scsi-readonly.xml | 35 ++++++++++++++++++++
tests/qemuxml2argvtest.c | 9 +++++
tests/qemuxml2xmltest.c | 3 ++
6 files changed, 101 insertions(+), 0 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-boot.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-boot.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-readonly.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-readonly.xml
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-boot.args
b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-boot.args
new file mode 100644
index 0000000..470bd78
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-boot.args
@@ -0,0 +1,10 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
+pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor \
+unix:/tmp/test-monitor,server,nowait -no-acpi -device \
+virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 -usb -drive \
+file=/dev/HostVG/QEMUGuest2,if=none,id=drive-ide0-0-0 -device \
+ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -drive \
+file=/dev/sg0,if=none,id=drive-hostdev-scsi_host0-0-0-0 -device \
+scsi-generic,bus=scsi0.0,channel=0,scsi-id=4,lun=8,\
+drive=drive-hostdev-scsi_host0-0-0-0,id=hostdev-scsi_host0-0-0-0,bootindex=1 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-boot.xml
b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-boot.xml
new file mode 100644
index 0000000..e3de719
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-boot.xml
@@ -0,0 +1,34 @@
+<domain type='qemu'>
+ <name>QEMUGuest2</name>
+ <uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ </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>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0'
target='0' unit='0'/>
+ </disk>
+ <controller type='scsi' index='0'
model='virtio-scsi'/>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host0'/>
+ <address bus='0' target='0' unit='0'/>
+ </source>
+ <boot order='1'/>
+ <address type='drive' controller='0' bus='0'
target='4' unit='8'/>
+ </hostdev>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-readonly.args
b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-readonly.args
new file mode 100644
index 0000000..da74789
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-readonly.args
@@ -0,0 +1,10 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc \
+-m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor \
+unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device \
+virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 -usb -drive \
+file=/dev/HostVG/QEMUGuest2,if=none,id=drive-ide0-0-0 -device \
+ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -drive \
+file=/dev/sg0,if=none,id=drive-hostdev-scsi_host0-0-0-0,readonly=on -device \
+scsi-generic,bus=scsi0.0,channel=0,scsi-id=4,lun=8,\
+drive=drive-hostdev-scsi_host0-0-0-0,id=hostdev-scsi_host0-0-0-0 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-readonly.xml
b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-readonly.xml
new file mode 100644
index 0000000..11d1712
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-readonly.xml
@@ -0,0 +1,35 @@
+<domain type='qemu'>
+ <name>QEMUGuest2</name>
+ <uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' 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>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0'
target='0' unit='0'/>
+ </disk>
+ <controller type='scsi' index='0'
model='virtio-scsi'/>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host0'/>
+ <address bus='0' target='0' unit='0'/>
+ </source>
+ <readonly/>
+ <address type='drive' controller='0' bus='0'
target='4' unit='8'/>
+ </hostdev>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index d6575e7..7087bc4 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -935,6 +935,15 @@ mymain(void)
DO_TEST("ppc-dtb", QEMU_CAPS_KVM, QEMU_CAPS_DTB);
+ DO_TEST("hostdev-scsi-boot",
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
+ QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_GENERIC,
+ QEMU_CAPS_BOOTINDEX, QEMU_CAPS_SCSI_GENERIC_BOOTINDEX);
+ DO_TEST("hostdev-scsi-readonly",
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_READONLY,
+ QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
+ QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_GENERIC);
+
virObjectUnref(driver.config);
virObjectUnref(driver.caps);
virObjectUnref(driver.xmlopt);
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 200d41a..7b8501a 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -274,6 +274,9 @@ mymain(void)
DO_TEST_DIFFERENT("metadata");
+ DO_TEST("hostdev-scsi-boot");
+ DO_TEST("hostdev-scsi-readonly");
+
virObjectUnref(driver.caps);
virObjectUnref(driver.xmlopt);
--
1.7.1