[libvirt] [PATCH v2 10/10] tests: tests for scsi hostdev

Osier Yang jyang at redhat.com
Wed Apr 3 10:26:31 UTC 2013


On 01/04/13 20:01, Han Cheng wrote:
> This patch add tests for scsi hostdev.

s/add/adds/

>
> Signed-off-by: Han Cheng <hanc.fnst at cn.fujitsu.com>
> ---
>   tests/qemuhelpdata/qemu-1.0-device                 |   10 ++++++
>   tests/qemuhelpdata/qemu-1.1.0-device               |   10 ++++++
>   tests/qemuhelpdata/qemu-1.2.0-device               |    5 +++
>   tests/qemuhelpdata/qemu-kvm-1.2.0-device           |    5 +++
>   tests/qemuhelptest.c                               |   19 ++++++++---
>   .../qemuxml2argv-hostdev-scsi-boot.args            |   10 ++++++
>   .../qemuxml2argv-hostdev-scsi-boot.xml             |   34 +++++++++++++++++++
>   .../qemuxml2argv-hostdev-scsi-readonly.args        |   10 ++++++
>   .../qemuxml2argv-hostdev-scsi-readonly.xml         |   35 ++++++++++++++++++++
>   .../qemuxml2argv-hostdev-scsi.args                 |   10 ++++++
>   .../qemuxml2argvdata/qemuxml2argv-hostdev-scsi.xml |   34 +++++++++++++++++++
>   tests/qemuxml2argvtest.c                           |   12 +++++++
>   tests/qemuxml2xmltest.c                            |    4 ++
>   13 files changed, 193 insertions(+), 5 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
>   create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi.args
>   create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi.xml
>
> diff --git a/tests/qemuhelpdata/qemu-1.0-device b/tests/qemuhelpdata/qemu-1.0-device
> index 0bdfbbd..d557f0e 100644
> --- a/tests/qemuhelpdata/qemu-1.0-device
> +++ b/tests/qemuhelpdata/qemu-1.0-device
> @@ -136,3 +136,13 @@ virtio-net-pci.romfile=string
>   virtio-net-pci.rombar=uint32
>   virtio-net-pci.multifunction=on/off
>   virtio-net-pci.command_serr_enable=on/off
> +scsi-generic.drive=drive
> +scsi-generic.logical_block_size=uint16
> +scsi-generic.physical_block_size=uint16
> +scsi-generic.min_io_size=uint16
> +scsi-generic.opt_io_size=uint32
> +scsi-generic.bootindex=int32

I might be wrong, but what I got is "bootindex" showed up since
qemu 1.2.

> +scsi-generic.discard_granularity=uint32
> +scsi-generic.channel=uint32
> +scsi-generic.scsi-id=uint32
> +scsi-generic.lun=uint32
> diff --git a/tests/qemuhelpdata/qemu-1.1.0-device b/tests/qemuhelpdata/qemu-1.1.0-device
> index abbf850..7313a34 100644
> --- a/tests/qemuhelpdata/qemu-1.1.0-device
> +++ b/tests/qemuhelpdata/qemu-1.1.0-device
> @@ -158,3 +158,13 @@ scsi-disk.dpofua=on/off
>   scsi-disk.channel=uint32
>   scsi-disk.scsi-id=uint32
>   scsi-disk.lun=uint32
> +scsi-generic.drive=drive
> +scsi-generic.logical_block_size=blocksize
> +scsi-generic.physical_block_size=blocksize
> +scsi-generic.min_io_size=uint16
> +scsi-generic.opt_io_size=uint32
> +scsi-generic.bootindex=int32
> +scsi-generic.discard_granularity=uint32
> +scsi-generic.channel=uint32
> +scsi-generic.scsi-id=uint32
> +scsi-generic.lun=uint32
> diff --git a/tests/qemuhelpdata/qemu-1.2.0-device b/tests/qemuhelpdata/qemu-1.2.0-device
> index 5613e00..40845e4 100644
> --- a/tests/qemuhelpdata/qemu-1.2.0-device
> +++ b/tests/qemuhelpdata/qemu-1.2.0-device
> @@ -208,3 +208,8 @@ usb-host.bootindex=int32
>   usb-host.pipeline=on/off
>   usb-host.port=string
>   usb-host.full-path=on/off
> +scsi-generic.drive=drive
> +scsi-generic.bootindex=int32
> +scsi-generic.channel=uint32
> +scsi-generic.scsi-id=uint32
> +scsi-generic.lun=uint32
> diff --git a/tests/qemuhelpdata/qemu-kvm-1.2.0-device b/tests/qemuhelpdata/qemu-kvm-1.2.0-device
> index 879a049..09e3ef7 100644
> --- a/tests/qemuhelpdata/qemu-kvm-1.2.0-device
> +++ b/tests/qemuhelpdata/qemu-kvm-1.2.0-device
> @@ -220,3 +220,8 @@ usb-host.bootindex=int32
>   usb-host.pipeline=on/off
>   usb-host.port=string
>   usb-host.full-path=on/off
> +scsi-generic.drive=drive
> +scsi-generic.bootindex=int32
> +scsi-generic.channel=uint32
> +scsi-generic.scsi-id=uint32
> +scsi-generic.lun=uint32
> diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
> index a28109a..156be16 100644
> --- a/tests/qemuhelptest.c
> +++ b/tests/qemuhelptest.c
> @@ -506,7 +506,8 @@ mymain(void)
>               QEMU_CAPS_DEVICE_CIRRUS_VGA,
>               QEMU_CAPS_DEVICE_VMWARE_SVGA,
>               QEMU_CAPS_DEVICE_USB_SERIAL,
> -            QEMU_CAPS_DEVICE_USB_NET);
> +            QEMU_CAPS_DEVICE_USB_NET,
> +            QEMU_CAPS_SCSI_GENERIC);
>       DO_TEST("qemu-kvm-0.12.1.2-rhel61", 12001, 1, 0,
>               QEMU_CAPS_VNC_COLON,
>               QEMU_CAPS_NO_REBOOT,
> @@ -723,7 +724,9 @@ mymain(void)
>               QEMU_CAPS_DEVICE_CIRRUS_VGA,
>               QEMU_CAPS_DEVICE_VMWARE_SVGA,
>               QEMU_CAPS_DEVICE_USB_SERIAL,
> -            QEMU_CAPS_DEVICE_USB_NET);
> +            QEMU_CAPS_DEVICE_USB_NET,
> +            QEMU_CAPS_SCSI_GENERIC,
> +            QEMU_CAPS_SCSI_GENERIC_BOOTINDEX);
>       DO_TEST("qemu-1.1.0", 1001000, 0, 0,
>               QEMU_CAPS_VNC_COLON,
>               QEMU_CAPS_NO_REBOOT,
> @@ -812,7 +815,9 @@ mymain(void)
>               QEMU_CAPS_DEVICE_VMWARE_SVGA,
>               QEMU_CAPS_DEVICE_USB_SERIAL,
>               QEMU_CAPS_DEVICE_USB_NET,
> -            QEMU_CAPS_DTB);
> +            QEMU_CAPS_DTB,
> +            QEMU_CAPS_SCSI_GENERIC,
> +            QEMU_CAPS_SCSI_GENERIC_BOOTINDEX);
>       DO_TEST("qemu-1.2.0", 1002000, 0, 0,
>               QEMU_CAPS_VNC_COLON,
>               QEMU_CAPS_NO_REBOOT,
> @@ -913,7 +918,9 @@ mymain(void)
>               QEMU_CAPS_DEVICE_USB_SERIAL,
>               QEMU_CAPS_DEVICE_USB_NET,
>               QEMU_CAPS_DTB,
> -            QEMU_CAPS_SCSI_MEGASAS);
> +            QEMU_CAPS_SCSI_MEGASAS,
> +            QEMU_CAPS_SCSI_GENERIC,
> +            QEMU_CAPS_SCSI_GENERIC_BOOTINDEX);
>       DO_TEST("qemu-kvm-1.2.0", 1002000, 1, 0,
>               QEMU_CAPS_VNC_COLON,
>               QEMU_CAPS_NO_REBOOT,
> @@ -1019,7 +1026,9 @@ mymain(void)
>               QEMU_CAPS_DEVICE_USB_SERIAL,
>               QEMU_CAPS_DEVICE_USB_NET,
>               QEMU_CAPS_DTB,
> -            QEMU_CAPS_SCSI_MEGASAS);
> +            QEMU_CAPS_SCSI_MEGASAS,
> +            QEMU_CAPS_SCSI_GENERIC,
> +            QEMU_CAPS_SCSI_GENERIC_BOOTINDEX);

As said in 4/10, this should be merged into 4/10.

>   
>       return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
>   }
> 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/qemuxml2argvdata/qemuxml2argv-hostdev-scsi.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi.args
> new file mode 100644
> index 0000000..4c09359
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi.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 -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.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi.xml
> new file mode 100644
> index 0000000..ccdbb0d
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi.xml

No need for this, as qemuxml2argv-hostdev-scsi-boot and

qemuxml2argv-hostdev-scsi-readonly already cover the required testing.

> @@ -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>
> +    <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>
> +      <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 38787ac..64a7540 100644
> --- a/tests/qemuxml2argvtest.c
> +++ b/tests/qemuxml2argvtest.c
> @@ -929,6 +929,18 @@ mymain(void)
>   
>       DO_TEST("ppc-dtb", QEMU_CAPS_KVM, QEMU_CAPS_DTB);
>   
> +    DO_TEST("hostdev-scsi",
> +            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
> +            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_GENERIC);
> +    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.xmlconf);
> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
> index ba9aa96..106ebe8 100644
> --- a/tests/qemuxml2xmltest.c
> +++ b/tests/qemuxml2xmltest.c
> @@ -272,6 +272,10 @@ mymain(void)
>   
>       DO_TEST_DIFFERENT("metadata");
>   
> +    DO_TEST("hostdev-scsi");
> +    DO_TEST("hostdev-scsi-boot");
> +    DO_TEST("hostdev-scsi-readonly");
> +
>       virObjectUnref(driver.caps);
>       virObjectUnref(driver.xmlconf);
>   




More information about the libvir-list mailing list