From patchwork Thu Nov 5 10:01:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 57865 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 nA5A3qTd017001 for ; Thu, 5 Nov 2009 10:03:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753409AbZKEKDo (ORCPT ); Thu, 5 Nov 2009 05:03:44 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751252AbZKEKDn (ORCPT ); Thu, 5 Nov 2009 05:03:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40231 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752840AbZKEKDm (ORCPT ); Thu, 5 Nov 2009 05:03:42 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nA5A3kl4002747; Thu, 5 Nov 2009 05:03:46 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nA5A3kBo020766; Thu, 5 Nov 2009 05:03: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 nA5A3aFh017064; Thu, 5 Nov 2009 05:03:45 -0500 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 5/7] KVM test: minor pci_hotplug fixes Date: Thu, 5 Nov 2009 12:01:10 +0200 Message-Id: <1257415272-9423-5-git-send-email-mgoldish@redhat.com> In-Reply-To: <1257415272-9423-4-git-send-email-mgoldish@redhat.com> References: <1257415272-9423-1-git-send-email-mgoldish@redhat.com> <1257415272-9423-2-git-send-email-mgoldish@redhat.com> <1257415272-9423-3-git-send-email-mgoldish@redhat.com> <1257415272-9423-4-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 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..876d8b8 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,63 @@ 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' - 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() + "Output: %r" % (pci_add_cmd, add_output)) + + try: + # Compare the output of 'info pci' + 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 %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)) + + finally: + # 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()