Index: client/tests/kvm/tests/pci_hotplug.py |
diff --git a/client/tests/kvm/tests/pci_hotplug.py b/client/tests/kvm/tests/pci_hotplug.py |
index c85ff62d3a23b0fb926eb0192302f5227cc0977c..55cf66680bfdd9ddfc37bdbcd91bd3f23f77a498 100644 |
--- a/client/tests/kvm/tests/pci_hotplug.py |
+++ b/client/tests/kvm/tests/pci_hotplug.py |
@@ -26,13 +26,14 @@ def run_pci_hotplug(test, params, env): |
# Modprobe the module if specified in config file |
module = params.get("modprobe_module") |
if module: |
- session.cmd("modprobe %s" % module) |
+ if session.get_command_status("modprobe %s" % module): |
+ raise error.TestError("Modprobe module '%s' failed" % module) |
# Get output of command 'info pci' as reference |
info_pci_ref = vm.monitor.info("pci") |
# Get output of command as reference |
- reference = session.cmd_output(params.get("reference_cmd")) |
+ reference = session.get_command_output(params.get("reference_cmd")) |
tested_model = params.get("pci_model") |
test_type = params.get("pci_type") |
@@ -47,24 +48,11 @@ def run_pci_hotplug(test, params, env): |
else: |
raise error.TestError("Unknow version of qemu") |
- # Determine syntax of drive hotplug |
- # __com.redhat_drive_add == qemu-kvm-0.12 on RHEL 6 |
- if len(re.findall("\n__com.redhat_drive_add", cmd_output)) > 0: |
- drive_cmd_type = "__com.redhat_drive_add" |
- # drive_add == qemu-kvm-0.13 onwards |
- elif len(re.findall("\ndrive_add", cmd_output)) > 0: |
- drive_cmd_type = "drive_add" |
- 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 |
elif test_type == "block": |
- image_params = params.object_params("stg") |
+ image_params = kvm_utils.get_sub_dict(params, "stg") |
image_filename = kvm_vm.get_image_filename(image_params, |
test.bindir) |
pci_add_cmd = ("pci_add pci_addr=auto storage file=%s,if=%s" % |
@@ -86,40 +74,24 @@ def run_pci_hotplug(test, params, env): |
pci_add_cmd = "device_add id=%s,driver=%s" % (id, tested_model) |
elif test_type == "block": |
- image_params = params.object_params("stg") |
+ image_params = kvm_utils.get_sub_dict(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" % |
- (image_filename, driver_id, image_format)) |
- elif drive_cmd_type == "__com.redhat_drive_add": |
- driver_add_cmd = ("__com.redhat_drive_add " |
- "file=%s,format=%s,id=%s" % |
- (image_filename, image_format, driver_id)) |
+ driver_add_cmd = (" __com.redhat_drive_add " |
+ "file=%s,format=%s,id=%s" % |
+ (image_filename, image_format, driver_id)) |
pci_add_cmd = ("device_add id=%s,driver=%s,drive=%s" % |
(id, tested_model, driver_id)) |
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: |
@@ -134,12 +106,8 @@ def run_pci_hotplug(test, params, env): |
# Define a helper function to delete the device |
def pci_del(ignore_failure=False): |
if cmd_type == "pci_add": |
- result_domain, bus, slot, function = add_output.split(',') |
- domain = int(result_domain.split()[2]) |
- bus = int(bus.split()[1]) |
- slot = int(slot.split()[1]) |
- pci_addr = "%x:%x:%x" % (domain, bus, slot) |
- cmd = "pci_del pci_addr=%s" % pci_addr |
+ slot_id = "0" + add_output.split(",")[2].split()[1] |
+ cmd = "pci_del pci_addr=%s" % slot_id |
elif cmd_type == "device_add": |
cmd = "device_del %s" % id |
# This should be replaced by a proper monitor method call |
@@ -163,7 +131,7 @@ def run_pci_hotplug(test, params, env): |
# Define a helper function to compare the output |
def new_shown(): |
- o = session.cmd_output(params.get("reference_cmd")) |
+ o = session.get_command_output(params.get("reference_cmd")) |
return o != reference |
secs = int(params.get("wait_secs_for_hook_up")) |
@@ -174,7 +142,7 @@ def run_pci_hotplug(test, params, env): |
# Define a helper function to catch PCI device string |
def find_pci(): |
- o = session.cmd_output(params.get("find_pci_cmd")) |
+ o = session.get_command_output(params.get("find_pci_cmd")) |
return params.get("match_string") in o |
if not kvm_utils.wait_for(find_pci, 30, 3, 3): |
@@ -184,11 +152,10 @@ def run_pci_hotplug(test, params, env): |
params.get("find_pci_cmd"))) |
# Test the newly added device |
- try: |
- session.cmd(params.get("pci_test_cmd")) |
- except kvm_subprocess.ShellError, e: |
+ s, o = session.get_command_status_output(params.get("pci_test_cmd")) |
+ if s != 0: |
raise error.TestFail("Check for %s device failed after PCI " |
- "hotplug. Output: %r" % (test_type, e.output)) |
+ "hotplug. Output: %r" % (test_type, o)) |
session.close() |