[libvirt] [PATCH v2] qemuhotplugtest: Add tests for ccw devices

These are a few simple and one complex testcases. The simple ones test attaching and detaching ccw devices with both implicitly and explicitly stated addresses. In the complex one, attaching and detaching a device should make the address free to reuse. I have plan to rework the address handling, so testcases that verify hotplugging ccw devices will help in avoiding regression. In this commit, some device files are duplicated because of the way qemuhotplug.c calculates the expected xml filenames. I plan on changing that to explicitly stating the basis domain xml, the device xml, and the expected xml. --- Changed in v2: * Add a newline to the end of qemuhotplug-ccw-virtio-2-explicit.xml, so that syntax-check doesn't complain. * Rename two files: remove the "explicit" word where the address is actually implicit. Link to the previous patch: https://www.redhat.com/archives/libvir-list/2016-July/msg00264.html tests/qemuhotplugtest.c | 37 +++++++++++ .../qemuhotplug-ccw-virtio-1-explicit.xml | 8 +++ .../qemuhotplug-ccw-virtio-1-reverse.xml | 8 +++ .../qemuhotplug-ccw-virtio-2-explicit.xml | 8 +++ .../qemuhotplug-ccw-virtio-2.xml | 8 +++ .../qemuhotplug-ccw-virtio.xml | 8 +++ .../qemuhotplug-base-ccw-live+ccw-virtio.xml | 63 +++++++++++++++++++ ...ive-with-2-ccw-virtio+ccw-virtio-1-explicit.xml | 73 ++++++++++++++++++++++ ...live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml | 73 ++++++++++++++++++++++ ...qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml | 63 +++++++++++++++++++ ...-live-with-ccw-virtio+ccw-virtio-2-explicit.xml | 73 ++++++++++++++++++++++ ...-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml | 73 ++++++++++++++++++++++ .../qemuhotplug-base-ccw-live-with-ccw-virtio.xml | 63 +++++++++++++++++++ .../qemuhotplug-base-ccw-live.xml | 53 ++++++++++++++++ 14 files changed, 611 insertions(+) create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-1-explicit.xml create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-1-reverse.xml create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-2-explicit.xml create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-2.xml create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio.xml create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-explicit.xml create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio.xml create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index f2e7567..0a5f068 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -73,6 +73,7 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_VIRTIO_SCSI); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_USB_STORAGE); + virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW); if (event) virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT); @@ -523,6 +524,42 @@ mymain(void) "device_del", QMP_OK, "chardev-remove", QMP_OK); + DO_TEST_ATTACH("base-ccw-live", "ccw-virtio", false, true, + "human-monitor-command", HMP("OK\\r\\n"), + "device_add", QMP_OK); + DO_TEST_DETACH("base-ccw-live", "ccw-virtio", false, false, + "device_del", QMP_OK, + "human-monitor-command", HMP("")); + + DO_TEST_ATTACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2", false, true, + "human-monitor-command", HMP("OK\\r\\n"), + "device_add", QMP_OK); + + DO_TEST_DETACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2", false, false, + "device_del", QMP_OK, + "human-monitor-command", HMP("")); + + DO_TEST_ATTACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2-explicit", false, true, + "human-monitor-command", HMP("OK\\r\\n"), + "device_add", QMP_OK); + + DO_TEST_DETACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2-explicit", false, false, + "device_del", QMP_OK, + "human-monitor-command", HMP("")); + + /* Attach a second device, then detach the first one. Then attach the first one again. */ + DO_TEST_ATTACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2-explicit", false, true, + "human-monitor-command", HMP("OK\\r\\n"), + "device_add", QMP_OK); + + DO_TEST_DETACH("base-ccw-live-with-2-ccw-virtio", "ccw-virtio-1-explicit", false, true, + "device_del", QMP_OK, + "human-monitor-command", HMP("")); + + DO_TEST_ATTACH("base-ccw-live-with-2-ccw-virtio", "ccw-virtio-1-reverse", false, false, + "human-monitor-command", HMP("OK\\r\\n"), + "device_add", QMP_OK); + qemuTestDriverFree(&driver); return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-1-explicit.xml b/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-1-explicit.xml new file mode 100644 index 0000000..74bd6a9 --- /dev/null +++ b/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-1-explicit.xml @@ -0,0 +1,8 @@ +<disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <target dev='vde' bus='virtio'/> + <readonly/> + <shareable/> + <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/> +</disk> diff --git a/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-1-reverse.xml b/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-1-reverse.xml new file mode 100644 index 0000000..7cf469e --- /dev/null +++ b/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-1-reverse.xml @@ -0,0 +1,8 @@ +<disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <target dev='vde' bus='virtio'/> + <readonly/> + <shareable/> + <address type='ccw'/> +</disk> diff --git a/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-2-explicit.xml b/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-2-explicit.xml new file mode 100644 index 0000000..b2cb161 --- /dev/null +++ b/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-2-explicit.xml @@ -0,0 +1,8 @@ +<disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <target dev='vde2' bus='virtio'/> + <readonly/> + <shareable/> + <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/> +</disk> diff --git a/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-2.xml b/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-2.xml new file mode 100644 index 0000000..ebcbfa0 --- /dev/null +++ b/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-2.xml @@ -0,0 +1,8 @@ +<disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <target dev='vde2' bus='virtio'/> + <readonly/> + <shareable/> + <address type='ccw'/> +</disk> diff --git a/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio.xml b/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio.xml new file mode 100644 index 0000000..7cf469e --- /dev/null +++ b/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio.xml @@ -0,0 +1,8 @@ +<disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <target dev='vde' bus='virtio'/> + <readonly/> + <shareable/> + <address type='ccw'/> +</disk> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml new file mode 100644 index 0000000..2a27e11 --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml @@ -0,0 +1,63 @@ +<domain type='kvm' id='7'> + <name>hotplug</name> + <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid> + <memory unit='KiB'>4194304</memory> + <currentMemory unit='KiB'>4194304</currentMemory> + <vcpu placement='static'>4</vcpu> + <os> + <type arch='s390x' machine='s390-ccw'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/libexec/qemu-kvm</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <backingStore/> + <target dev='vde' bus='virtio'/> + <readonly/> + <shareable/> + <alias name='virtio-disk4'/> + <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/> + </disk> + <controller type='usb' index='0'> + <alias name='usb'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <alias name='ide0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='scsi' index='0' model='virtio-scsi'> + <alias name='scsi0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </controller> + <controller type='pci' index='0' model='pci-root'> + <alias name='pci'/> + </controller> + <controller type='virtio-serial' index='0'> + <alias name='virtio-serial0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </controller> + <input type='mouse' bus='ps2'> + <alias name='input0'/> + </input> + <input type='keyboard' bus='ps2'> + <alias name='input1'/> + </input> + <memballoon model='none'> + <alias name='balloon0'/> + </memballoon> + <panic model='s390'/> + </devices> + <seclabel type='none' model='none'/> +</domain> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-explicit.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-explicit.xml new file mode 100644 index 0000000..ff94b6c --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-explicit.xml @@ -0,0 +1,73 @@ +<domain type='kvm' id='7'> + <name>hotplug</name> + <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid> + <memory unit='KiB'>4194304</memory> + <currentMemory unit='KiB'>4194304</currentMemory> + <vcpu placement='static'>4</vcpu> + <os> + <type arch='s390x' machine='s390-ccw'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/libexec/qemu-kvm</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <backingStore/> + <target dev='vde' bus='virtio'/> + <readonly/> + <shareable/> + <alias name='virtio-disk4'/> + <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/> + </disk> + <disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <backingStore/> + <target dev='vde2' bus='virtio'/> + <readonly/> + <shareable/> + <alias name='virtio-disk4'/> + <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/> + </disk> + <controller type='usb' index='0'> + <alias name='usb'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <alias name='ide0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='scsi' index='0' model='virtio-scsi'> + <alias name='scsi0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </controller> + <controller type='pci' index='0' model='pci-root'> + <alias name='pci'/> + </controller> + <controller type='virtio-serial' index='0'> + <alias name='virtio-serial0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </controller> + <input type='mouse' bus='ps2'> + <alias name='input0'/> + </input> + <input type='keyboard' bus='ps2'> + <alias name='input1'/> + </input> + <memballoon model='none'> + <alias name='balloon0'/> + </memballoon> + <panic model='s390'/> + </devices> + <seclabel type='none' model='none'/> +</domain> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml new file mode 100644 index 0000000..e03473c --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml @@ -0,0 +1,73 @@ +<domain type='kvm' id='7'> + <name>hotplug</name> + <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid> + <memory unit='KiB'>4194304</memory> + <currentMemory unit='KiB'>4194304</currentMemory> + <vcpu placement='static'>4</vcpu> + <os> + <type arch='s390x' machine='s390-ccw'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/libexec/qemu-kvm</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <backingStore/> + <target dev='vde2' bus='virtio'/> + <readonly/> + <shareable/> + <alias name='virtio-disk4'/> + <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/> + </disk> + <disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <backingStore/> + <target dev='vde' bus='virtio'/> + <readonly/> + <shareable/> + <alias name='virtio-disk4'/> + <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/> + </disk> + <controller type='usb' index='0'> + <alias name='usb'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <alias name='ide0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='scsi' index='0' model='virtio-scsi'> + <alias name='scsi0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </controller> + <controller type='pci' index='0' model='pci-root'> + <alias name='pci'/> + </controller> + <controller type='virtio-serial' index='0'> + <alias name='virtio-serial0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </controller> + <input type='mouse' bus='ps2'> + <alias name='input0'/> + </input> + <input type='keyboard' bus='ps2'> + <alias name='input1'/> + </input> + <memballoon model='none'> + <alias name='balloon0'/> + </memballoon> + <panic model='s390'/> + </devices> + <seclabel type='none' model='none'/> +</domain> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml new file mode 100644 index 0000000..8aff8e6 --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml @@ -0,0 +1,63 @@ +<domain type='kvm' id='7'> + <name>hotplug</name> + <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid> + <memory unit='KiB'>4194304</memory> + <currentMemory unit='KiB'>4194304</currentMemory> + <vcpu placement='static'>4</vcpu> + <os> + <type arch='s390x' machine='s390-ccw'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/libexec/qemu-kvm</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <backingStore/> + <target dev='vde2' bus='virtio'/> + <readonly/> + <shareable/> + <alias name='virtio-disk4'/> + <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/> + </disk> + <controller type='usb' index='0'> + <alias name='usb'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <alias name='ide0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='scsi' index='0' model='virtio-scsi'> + <alias name='scsi0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </controller> + <controller type='pci' index='0' model='pci-root'> + <alias name='pci'/> + </controller> + <controller type='virtio-serial' index='0'> + <alias name='virtio-serial0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </controller> + <input type='mouse' bus='ps2'> + <alias name='input0'/> + </input> + <input type='keyboard' bus='ps2'> + <alias name='input1'/> + </input> + <memballoon model='none'> + <alias name='balloon0'/> + </memballoon> + <panic model='s390'/> + </devices> + <seclabel type='none' model='none'/> +</domain> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml new file mode 100644 index 0000000..ff94b6c --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml @@ -0,0 +1,73 @@ +<domain type='kvm' id='7'> + <name>hotplug</name> + <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid> + <memory unit='KiB'>4194304</memory> + <currentMemory unit='KiB'>4194304</currentMemory> + <vcpu placement='static'>4</vcpu> + <os> + <type arch='s390x' machine='s390-ccw'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/libexec/qemu-kvm</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <backingStore/> + <target dev='vde' bus='virtio'/> + <readonly/> + <shareable/> + <alias name='virtio-disk4'/> + <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/> + </disk> + <disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <backingStore/> + <target dev='vde2' bus='virtio'/> + <readonly/> + <shareable/> + <alias name='virtio-disk4'/> + <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/> + </disk> + <controller type='usb' index='0'> + <alias name='usb'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <alias name='ide0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='scsi' index='0' model='virtio-scsi'> + <alias name='scsi0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </controller> + <controller type='pci' index='0' model='pci-root'> + <alias name='pci'/> + </controller> + <controller type='virtio-serial' index='0'> + <alias name='virtio-serial0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </controller> + <input type='mouse' bus='ps2'> + <alias name='input0'/> + </input> + <input type='keyboard' bus='ps2'> + <alias name='input1'/> + </input> + <memballoon model='none'> + <alias name='balloon0'/> + </memballoon> + <panic model='s390'/> + </devices> + <seclabel type='none' model='none'/> +</domain> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml new file mode 100644 index 0000000..ff94b6c --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml @@ -0,0 +1,73 @@ +<domain type='kvm' id='7'> + <name>hotplug</name> + <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid> + <memory unit='KiB'>4194304</memory> + <currentMemory unit='KiB'>4194304</currentMemory> + <vcpu placement='static'>4</vcpu> + <os> + <type arch='s390x' machine='s390-ccw'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/libexec/qemu-kvm</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <backingStore/> + <target dev='vde' bus='virtio'/> + <readonly/> + <shareable/> + <alias name='virtio-disk4'/> + <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/> + </disk> + <disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <backingStore/> + <target dev='vde2' bus='virtio'/> + <readonly/> + <shareable/> + <alias name='virtio-disk4'/> + <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/> + </disk> + <controller type='usb' index='0'> + <alias name='usb'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <alias name='ide0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='scsi' index='0' model='virtio-scsi'> + <alias name='scsi0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </controller> + <controller type='pci' index='0' model='pci-root'> + <alias name='pci'/> + </controller> + <controller type='virtio-serial' index='0'> + <alias name='virtio-serial0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </controller> + <input type='mouse' bus='ps2'> + <alias name='input0'/> + </input> + <input type='keyboard' bus='ps2'> + <alias name='input1'/> + </input> + <memballoon model='none'> + <alias name='balloon0'/> + </memballoon> + <panic model='s390'/> + </devices> + <seclabel type='none' model='none'/> +</domain> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio.xml new file mode 100644 index 0000000..2a27e11 --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio.xml @@ -0,0 +1,63 @@ +<domain type='kvm' id='7'> + <name>hotplug</name> + <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid> + <memory unit='KiB'>4194304</memory> + <currentMemory unit='KiB'>4194304</currentMemory> + <vcpu placement='static'>4</vcpu> + <os> + <type arch='s390x' machine='s390-ccw'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/libexec/qemu-kvm</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <backingStore/> + <target dev='vde' bus='virtio'/> + <readonly/> + <shareable/> + <alias name='virtio-disk4'/> + <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/> + </disk> + <controller type='usb' index='0'> + <alias name='usb'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <alias name='ide0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='scsi' index='0' model='virtio-scsi'> + <alias name='scsi0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </controller> + <controller type='pci' index='0' model='pci-root'> + <alias name='pci'/> + </controller> + <controller type='virtio-serial' index='0'> + <alias name='virtio-serial0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </controller> + <input type='mouse' bus='ps2'> + <alias name='input0'/> + </input> + <input type='keyboard' bus='ps2'> + <alias name='input1'/> + </input> + <memballoon model='none'> + <alias name='balloon0'/> + </memballoon> + <panic model='s390'/> + </devices> + <seclabel type='none' model='none'/> +</domain> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml new file mode 100644 index 0000000..17a0dc2 --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml @@ -0,0 +1,53 @@ +<domain type='kvm' id='7'> + <name>hotplug</name> + <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid> + <memory unit='KiB'>4194304</memory> + <currentMemory unit='KiB'>4194304</currentMemory> + <vcpu placement='static'>4</vcpu> + <os> + <type arch='s390x' machine='s390-ccw'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/libexec/qemu-kvm</emulator> + <controller type='usb' index='0'> + <alias name='usb'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <alias name='ide0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='scsi' index='0' model='virtio-scsi'> + <alias name='scsi0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </controller> + <controller type='pci' index='0' model='pci-root'> + <alias name='pci'/> + </controller> + <controller type='virtio-serial' index='0'> + <alias name='virtio-serial0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </controller> + <input type='mouse' bus='ps2'> + <alias name='input0'/> + </input> + <input type='keyboard' bus='ps2'> + <alias name='input1'/> + </input> + <memballoon model='none'> + <alias name='balloon0'/> + </memballoon> + <panic model='s390'/> + </devices> + <seclabel type='none' model='none'/> +</domain> -- 1.9.1

On Tue, Jul 12, 2016 at 03:08:22PM +0200, Tomasz Flendrich wrote:
These are a few simple and one complex testcases. The simple ones test attaching and detaching ccw devices with both implicitly and explicitly stated addresses. In the complex one, attaching and detaching a device should make the address free to reuse.
I have plan to rework the address handling, so testcases that verify hotplugging ccw devices will help in avoiding regression.
In this commit, some device files are duplicated because of the way qemuhotplug.c calculates the expected xml filenames. I plan on changing that to explicitly stating the basis domain xml, the device xml, and the expected xml. ---
Changed in v2: * Add a newline to the end of qemuhotplug-ccw-virtio-2-explicit.xml, so that syntax-check doesn't complain. * Rename two files: remove the "explicit" word where the address is actually implicit.
Link to the previous patch: https://www.redhat.com/archives/libvir-list/2016-July/msg00264.html
[...]
diff --git a/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-1-explicit.xml b/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-1-explicit.xml new file mode 100644 index 0000000..74bd6a9 --- /dev/null +++ b/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-1-explicit.xml @@ -0,0 +1,8 @@ +<disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <target dev='vde' bus='virtio'/> + <readonly/> + <shareable/> + <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/> +</disk>
I know you weren't aiming for that, but this got me thinking, are we checking that unplug works with not fully specified XML? I mean that when unplugging, you don't need to specify everything. Whatever uniquely identifies the device should be enough. So for example just address or target, definitely no need for the readonly and shareable flags. But as said, that's not meant to be part of this patch. [...]
diff --git a/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-2-explicit.xml b/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-2-explicit.xml new file mode 100644 index 0000000..b2cb161 --- /dev/null +++ b/tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-2-explicit.xml @@ -0,0 +1,8 @@ +<disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <target dev='vde2' bus='virtio'/>
vde2 is an address for a partition. This works? I don't think it should. [...]
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-explicit.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-explicit.xml new file mode 100644 index 0000000..ff94b6c --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-explicit.xml @@ -0,0 +1,73 @@ +<domain type='kvm' id='7'> + <name>hotplug</name> + <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid> + <memory unit='KiB'>4194304</memory> + <currentMemory unit='KiB'>4194304</currentMemory> + <vcpu placement='static'>4</vcpu> + <os> + <type arch='s390x' machine='s390-ccw'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/libexec/qemu-kvm</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <backingStore/> + <target dev='vde' bus='virtio'/> + <readonly/> + <shareable/> + <alias name='virtio-disk4'/>
This ...
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/> + </disk> + <disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='none'/> + <source file='/dev/null'/> + <backingStore/> + <target dev='vde2' bus='virtio'/> + <readonly/> + <shareable/> + <alias name='virtio-disk4'/>
... and this? This will never work, so that's another bug right here.
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
By the way, attaching a device without explicit address and without target dev= specified (only bus='virtio') Should work and that would actually test address allocation. By allocating disk with target dev='XX' the address gets calculated from that device, so no allocation is being tested. Other than these problems the approach is fine. Martin

I know you weren't aiming for that, but this got me thinking, are we checking that unplug works with not fully specified XML? I mean that when unplugging, you don't need to specify everything. Whatever uniquely identifies the device should be enough. So for example just address or target, definitely no need for the readonly and shareable flags. But as said, that's not meant to be part of this patch. I have thought about that before and I agree that a few tests for this would be useful. I decided not to add them yet, because of the issue I explained in another patch: So far, there is only one test for persistent attachment. I will add more testcases as soon as I hear some feedback on these changes. qemuhotplugtest.c should first be modified anyway, so that the three xmls's filenames (basis domain xml, device xml, expected xml) are stated explicitly instead of being calculated. This will allow for more flexibility in testing and less xml files duplicates.
Thank you for your reply! link to that patch: https://www.redhat.com/archives/libvir-list/2016-July/msg00595.html Adding tests will be a lot easier and without xml files duplication. I can implement it now, but should I do it on top of the patch “Test persistent device attachment”, parallelly to it, or wait for the feedback?
[…]
vde2 is an address for a partition. This works? I don't think it should.
[...]
[…]
This ...
[…]
... and this? This will never work, so that's another bug right here. Yay, I am very happy that my tests proved to be useful so fast :)
What exactly is the problem with “vde2”? And is it working properly if we change “vde2” to “vdea”? The second problem is that the device aliases are the same for two different devices. Am I correct?
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
By the way, attaching a device without explicit address and without target dev= specified (only bus='virtio') Should work and that would actually test address allocation. By allocating disk with target dev='XX' the address gets calculated from that device, so no allocation is being tested. I consider reserving/validating addresses as a part of address allocation, because they are connected to each other: if some address is reserved, it can’t be automatically allocated for another device, and vice versa. So I want to test both of them. But you are totally right and thank you :)
In this patch I added a test for both of these mixed together: please, take a look at the last three DO_TEST_* in my patch. The first two actions (an attachment and a detachment) are with explicit addresses, and the last action (an attachment) is with an implicit address. There are a lot of possibilities to test, for example the first attachment could also be done with an implicit address. I will write tests for more cases with pleasure. Tomasz

On Mon, Jul 18, 2016 at 08:25:40PM +0200, Tomasz Flendrich wrote:
Thank you for your reply!
I know you weren't aiming for that, but this got me thinking, are we checking that unplug works with not fully specified XML? I mean that when unplugging, you don't need to specify everything. Whatever uniquely identifies the device should be enough. So for example just address or target, definitely no need for the readonly and shareable flags. But as said, that's not meant to be part of this patch. I have thought about that before and I agree that a few tests for this would be useful. I decided not to add them yet, because of the issue I explained in another patch: So far, there is only one test for persistent attachment. I will add more testcases as soon as I hear some feedback on these changes. qemuhotplugtest.c should first be modified anyway, so that the three xmls's filenames (basis domain xml, device xml, expected xml) are stated explicitly instead of being calculated. This will allow for more flexibility in testing and less xml files duplicates. link to that patch: https://www.redhat.com/archives/libvir-list/2016-July/msg00595.html
Adding tests will be a lot easier and without xml files duplication. I can implement it now, but should I do it on top of the patch “Test persistent device attachment”, parallelly to it, or wait for the feedback?
[…]
vde2 is an address for a partition. This works? I don't think it should.
[...]
[…]
This ...
[…]
... and this? This will never work, so that's another bug right here. Yay, I am very happy that my tests proved to be useful so fast :)
What exactly is the problem with “vde2”? And is it working properly if we change “vde2” to “vdea”?
The vde2 is second partition on disk vde. We just use the vde part. I guess we support it just because reasons.
The second problem is that the device aliases are the same for two different devices. Am I correct?
Yes, no hypervisor will probably allow you to do that.
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
By the way, attaching a device without explicit address and without target dev= specified (only bus='virtio') Should work and that would actually test address allocation. By allocating disk with target dev='XX' the address gets calculated from that device, so no allocation is being tested. I consider reserving/validating addresses as a part of address allocation, because they are connected to each other: if some address is reserved, it can’t be automatically allocated for another device, and vice versa. So I want to test both of them. But you are totally right and thank you :)
In this patch I added a test for both of these mixed together: please, take a look at the last three DO_TEST_* in my patch. The first two actions (an attachment and a detachment) are with explicit addresses, and the last action (an attachment) is with an implicit address.
But the problem is that you are not checking any assignment. The code is not executed at all. That's because you specify 'target dev=' from which we're trying to guess the right address. Because virDomainDeviceDefPostParseInternal() is ran for the device definition and it calls virDomainDiskDefAssignAddress() which in turn calls virDiskNameToIndex().
There are a lot of possibilities to test, for example the first attachment could also be done with an implicit address. I will write tests for more cases with pleasure.
We don't need to test every single thing, we should keep in mind that most of the things will be caught anyway and (hopefully) every developer is running all of them every now and then so it consumes time as well... Few parts could get a good scrub, actually. Anyway, as I said, there is no need to test every possible combination, I just wanted to mention that so that you know. Sorry for the late review, I need to get up to speed.
Tomasz

[…]
But the problem is that you are not checking any assignment. The code is not executed at all. That's because you specify 'target dev=' from which we're trying to guess the right address.
Because virDomainDeviceDefPostParseInternal() is ran for the device definition and it calls virDomainDiskDefAssignAddress() which in turn calls virDiskNameToIndex().
virDomainDiskDefAssignAddress() is called only when disk->info.type is VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE, and in my testcases, disk->info.type is equal to VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW, so this function isn’t even executed. Besides even if it went inside that function, this device’s bus is set to VIR_DOMAIN_DISK_BUS_VIRTIO, so this function wouldn’t do anything, because it deals only with buses that are controller-based. To make sure, I confirmed that it is virDomainCCWAddressAssign() that assigns addresses in my testcases. I checked that the parameters are correct (autoassign is false when the address is explicit etc), and this is what I wanted to test. Thanks for the heads up though! Tomasz

On Thu, Jul 21, 2016 at 08:38:17PM +0200, Tomasz Flendrich wrote:
[…]
But the problem is that you are not checking any assignment. The code is not executed at all. That's because you specify 'target dev=' from which we're trying to guess the right address.
Because virDomainDeviceDefPostParseInternal() is ran for the device definition and it calls virDomainDiskDefAssignAddress() which in turn calls virDiskNameToIndex().
virDomainDiskDefAssignAddress() is called only when disk->info.type is VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE, and in my testcases, disk->info.type is equal to VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW,
Oh, that's right. I'm sorry for the confusion. I'll go through that again and review it asap.
so this function isn’t even executed. Besides even if it went inside that function, this device’s bus is set to VIR_DOMAIN_DISK_BUS_VIRTIO, so this function wouldn’t do anything, because it deals only with buses that are controller-based.
Those damn ccw addresses =) I need to forget what I know about other ones for a while.
To make sure, I confirmed that it is virDomainCCWAddressAssign() that assigns addresses in my testcases. I checked that the parameters are correct (autoassign is false when the address is explicit etc), and this is what I wanted to test. Thanks for the heads up though!
Tomasz
participants (2)
-
Martin Kletzander
-
Tomasz Flendrich