From patchwork Fri Nov 6 16:32:22 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 58066 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nA6GYoJg018898 for ; Fri, 6 Nov 2009 16:34:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758625AbZKFQen (ORCPT ); Fri, 6 Nov 2009 11:34:43 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757262AbZKFQen (ORCPT ); Fri, 6 Nov 2009 11:34:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:30814 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758625AbZKFQem (ORCPT ); Fri, 6 Nov 2009 11:34:42 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nA6GYkUJ023830; Fri, 6 Nov 2009 11:34:46 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nA6GYk1Z006644; Fri, 6 Nov 2009 11:34:46 -0500 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id nA6GYipV003056; Fri, 6 Nov 2009 11:34:44 -0500 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH v2] KVM test: minor pci_hotplug fixes Date: Fri, 6 Nov 2009 18:32:22 +0200 Message-Id: <1257525142-17795-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample index f271a09..326ae20 100644 --- a/client/tests/kvm/kvm_tests.cfg.sample +++ b/client/tests/kvm/kvm_tests.cfg.sample @@ -181,7 +181,6 @@ variants: - nic_hotplug: install setup unattended_install type = pci_hotplug pci_type = nic - modprobe_acpiphp = no reference_cmd = lspci find_pci_cmd = 'lspci | tail -n1' pci_test_cmd = 'nslookup www.redhat.com' @@ -223,7 +222,6 @@ variants: image_format_stg = qcow2 - fmt_raw: image_format_stg = raw - only Fedora Ubuntu Windows - system_reset: install setup unattended_install type = boot @@ -538,13 +536,10 @@ variants: nic_virtio: match_string = "VirtIO Ethernet" block_hotplug: - use_telnet = yes - ssh_port = 23 - guest_port_ssh = 23 wait_secs_for_hook_up = 10 reference_cmd = wmic diskdrive list brief find_pci_cmd = wmic diskdrive list brief - pci_test_cmd = echo select disk 1 > dt && echo online disk >> dt && echo detail disk >> dt && echo exit >> dt && diskpart /s dt + pci_test_cmd = echo select disk 1 > dt && echo online >> dt && echo detail disk >> dt && echo exit >> dt && diskpart /s dt variants: - Win2000: diff --git a/client/tests/kvm/tests/pci_hotplug.py b/client/tests/kvm/tests/pci_hotplug.py index 3ad9ea2..d8f34f8 100644 --- a/client/tests/kvm/tests/pci_hotplug.py +++ b/client/tests/kvm/tests/pci_hotplug.py @@ -1,6 +1,6 @@ import logging, os from autotest_lib.client.common_lib import error -import kvm_subprocess, kvm_test_utils, kvm_utils +import kvm_subprocess, kvm_test_utils, kvm_utils, kvm_vm def run_pci_hotplug(test, params, env): @@ -21,8 +21,8 @@ def run_pci_hotplug(test, params, env): session = kvm_test_utils.wait_for_login(vm) # Modprobe the module if specified in config file - if params.get("modprobe_module"): - module = params.get("modprobe_module") + module = params.get("modprobe_module") + if module: if session.get_command_status("modprobe %s" % module): raise error.TestError("Modprobe module '%s' failed" % module) @@ -38,61 +38,73 @@ def run_pci_hotplug(test, params, env): if test_type == "nic": pci_add_cmd = "pci_add pci_addr=auto nic model=%s" % tested_model elif test_type == "block": - image_name = params.get("image_name_stg") - image_filename = "%s.%s" % (image_name, params.get("image_format_stg")) - image_dir = os.path.join(test.bindir, "images") - storage_name = os.path.join(image_dir, image_filename) + 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" % - (storage_name, tested_model)) + (image_filename, tested_model)) # Implement pci_add s, add_output = vm.send_monitor_cmd(pci_add_cmd) if not "OK domain" in add_output: raise error.TestFail("Add device failed. Hypervisor command is: %s. " - "Output: %s" % (pci_add_cmd, add_output)) - - # Compare the output of 'info pci' + "Output: %r" % (pci_add_cmd, add_output)) s, after_add = vm.send_monitor_cmd("info pci") - if after_add == info_pci_ref: - raise error.TestFail("No new PCI device shown after executing " - "hypervisor command: 'info pci'") - - # Define a helper function to compare the output - def new_shown(): - o = session.get_command_output(params.get("reference_cmd")) - if reference == o: - return False - return True - - secs = int(params.get("wait_secs_for_hook_up")) - if not kvm_utils.wait_for(new_shown, 30, secs, 3): - raise error.TestFail("No new device shown in output of command " - "executed inside the guest: %s" % - params.get("reference_cmd")) - - # Define a helper function to catch PCI device string - def find_pci(): - output = session.get_command_output(params.get("find_pci_cmd")) - if not params.get("match_string") in output: - return False - return True - - if not kvm_utils.wait_for(find_pci, 30, 3, 3): - raise error.TestFail("PCI model not found: %s. Command is: %s" % - (tested_model, params.get("find_pci_cmd"))) - - # Test the newly added device - 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: %s" % (test_type, o)) - - # Delete the added pci device - slot_id = "0" + add_output.split(",")[2].split()[1] - cmd = "pci_del pci_addr=%s" % slot_id - s, after_del = vm.send_monitor_cmd(cmd) - if after_del == after_add: - raise error.TestFail("Failed to hot remove PCI device: %s. " - "Hypervisor command: %s" % (tested_model, cmd)) - - session.close() + + # Define a helper function to delete the device + def pci_del(ignore_failure=False): + slot_id = "0" + add_output.split(",")[2].split()[1] + cmd = "pci_del pci_addr=%s" % slot_id + vm.send_monitor_cmd(cmd) + + def device_removed(): + s, after_del = vm.send_monitor_cmd("info pci") + return after_del != after_add + + if (not kvm_utils.wait_for(device_removed, 10, 0, 1) + and not ignore_failure): + raise error.TestFail("Failed to hot remove PCI device: %s. " + "Hypervisor command: %s" % (tested_model, + cmd)) + + try: + # Compare the output of 'info pci' + if after_add == info_pci_ref: + raise error.TestFail("No new PCI device shown after executing " + "hypervisor command: 'info pci'") + + # Define a helper function to compare the output + def new_shown(): + o = session.get_command_output(params.get("reference_cmd")) + return o != reference + + secs = int(params.get("wait_secs_for_hook_up")) + if not kvm_utils.wait_for(new_shown, 30, secs, 3): + raise error.TestFail("No new device shown in output of command " + "executed inside the guest: %s" % + params.get("reference_cmd")) + + # Define a helper function to catch PCI device string + def find_pci(): + 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): + raise error.TestFail("PCI %s %s device not found in guest. " + "Command was: %s" % + (tested_model, test_type, + params.get("find_pci_cmd"))) + + # Test the newly added device + 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, o)) + + session.close() + + except: + pci_del(ignore_failure=True) + raise + + else: + pci_del()