This patch fixes SCSI disks hotplug tests, by adding a SCSI controller
in addition to the other two devices (drive and device). Hosts
featuring qemu versions without SCSI support fail with a more
clear explanation.

The tests_base.cfg.sample file is also updated to better identify
the emulated LSI SCSI controller, since VirtIO disks are also
identified as SCSI disks (at least on current hwdata/lspci).

The tested guest OS (F14) did not need to have its bus explicitly
scanned for the new disk, but that might be necessary on other Linux
variants.

Signed-off-by: Cleber Rosa <[email protected]>
---
 client/tests/kvm/tests/pci_hotplug.py  |   16 +++++++++++++++-
 client/tests/kvm/tests_base.cfg.sample |    2 +-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/client/tests/kvm/tests/pci_hotplug.py 
b/client/tests/kvm/tests/pci_hotplug.py
index 0663a81..c85ff62 100644
--- a/client/tests/kvm/tests/pci_hotplug.py
+++ b/client/tests/kvm/tests/pci_hotplug.py
@@ -57,6 +57,9 @@ def run_pci_hotplug(test, params, env):
     else:
         raise error.TestError("Unknow version of qemu")
 
+    # Probe qemu for a list of supported devices
+    devices_support = vm.monitor.cmd("%s ?" % cmd_type)
+
     if cmd_type == "pci_add":
         if test_type == "nic":
             pci_add_cmd = "pci_add pci_addr=auto nic model=%s" % tested_model
@@ -86,11 +89,23 @@ def run_pci_hotplug(test, params, env):
             image_params = params.object_params("stg")
             image_filename = kvm_vm.get_image_filename(image_params,
                                                        test.bindir)
+            controller_model = None
             if tested_model == "virtio":
                 tested_model = "virtio-blk-pci"
 
             if tested_model == "scsi":
                 tested_model = "scsi-disk"
+                controller_model = "lsi53c895a"
+                if len(re.findall(controller_model, devices_support)) == 0:
+                    raise error.TestError("scsi controller device (%s) not "
+                                          "supported by qemu" %
+                                          controller_model)
+
+            if controller_model is not None:
+                controller_id = "controller-" + id
+                controller_add_cmd = ("device_add %s,id=%s" %
+                                      (controller_model, controller_id))
+                controller_output = vm.monitor.cmd(controller_add_cmd)
 
             if drive_cmd_type == "drive_add":
                 driver_add_cmd = ("drive_add auto 
file=%s,if=none,id=%s,format=%s" %
@@ -105,7 +120,6 @@ def run_pci_hotplug(test, params, env):
             driver_output = vm.monitor.cmd(driver_add_cmd)
 
         # Check if the device is support in qemu
-        devices_support = vm.monitor.cmd("%s ?" % cmd_type)
         if len(re.findall(tested_model, devices_support)) > 0:
             add_output = vm.monitor.cmd(pci_add_cmd)
         else:
diff --git a/client/tests/kvm/tests_base.cfg.sample 
b/client/tests/kvm/tests_base.cfg.sample
index 1a260b4..c5cb907 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -565,7 +565,7 @@ variants:
                 match_string = "Virtio block device"
             - block_scsi:
                 pci_model = scsi
-                match_string = "SCSI"
+                match_string = "LSI Logic"
         variants:
             - fmt_qcow2:
                 image_format_stg = qcow2
-- 
1.7.1

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to