kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add a subtest pci_hotplug in kvm test
@ 2009-07-03  5:57 Yolkfull Chow
  2009-07-03  6:00 ` Yolkfull Chow
  0 siblings, 1 reply; 15+ messages in thread
From: Yolkfull Chow @ 2009-07-03  5:57 UTC (permalink / raw)
  To: kvm; +Cc: autotest, lmr, Yolkfull Chow


Signed-off-by: Yolkfull Chow <yzhou@redhat.com>
---
 client/tests/kvm/kvm.py               |    1 +
 client/tests/kvm/kvm_tests.cfg.sample |   65 ++++++++++++++++++++++-
 client/tests/kvm/kvm_tests.py         |   94 +++++++++++++++++++++++++++++++++
 client/tests/kvm/kvm_vm.py            |    2 +
 4 files changed, 161 insertions(+), 1 deletions(-)

diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
index b18b643..fc92e10 100644
--- a/client/tests/kvm/kvm.py
+++ b/client/tests/kvm/kvm.py
@@ -55,6 +55,7 @@ class kvm(test.test):
                 "kvm_install":  test_routine("kvm_install", "run_kvm_install"),
                 "linux_s3":     test_routine("kvm_tests", "run_linux_s3"),
                 "stress_boot":  test_routine("kvm_tests", "run_stress_boot"),
+                "pci_hotplug":  test_routine("kvm_tests", "run_pci_hotplug"),
                 }
 
         # Make it possible to import modules from the test's bindir
diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample
index 2f864de..a9e16d6 100644
--- a/client/tests/kvm/kvm_tests.cfg.sample
+++ b/client/tests/kvm/kvm_tests.cfg.sample
@@ -94,6 +94,53 @@ variants:
         max_vms = 5    
         alive_test_cmd = ps aux
 
+
+    - nic_hotplug:
+        type = pci_hotplug
+        pci_type = nic
+        modprobe_acpiphp = yes
+        reference_cmd = lspci
+        find_pci_cmd = 'lspci | tail -n1'
+        pci_test_cmd = 'nslookup www.redhat.com'
+        seconds_wait_for_device_install = 3
+        variants:
+            - @nic_8139:
+                pci_model = rtl8139
+                match_string = "8139"
+            - nic_virtio:
+                pci_model = virtio
+                match_string = "Virtio network device"
+            - nic_e1000:
+                pci_model = e1000
+                match_string = "Gigabit Ethernet Controller"
+
+    - block_hotplug:
+        type = pci_hotplug
+        pci_type = block
+        modprobe_acpiphp = yes
+        reference_cmd = lspci
+        find_pci_cmd = 'lspci | tail -n1'
+        images += " stg"
+        boot_drive_stg = no
+        image_name_stg = storage
+        image_size = 1G
+        force_create_image_stg = yes
+        pci_test_cmd = 'dir'
+        seconds_wait_for_device_install = 3
+        variants:
+            - block_virtio:
+                pci_model = virtio
+                match_string = "Virtio block device"
+            - block_scsi:
+                pci_model = scsi
+                match_string = "SCSI storage controller"
+        variants:
+            - fmt_qcow2:
+                image_format_stg = qcow2
+            - fmt_raw:
+                image_format_stg = raw
+
+
 # NICs
 variants:
     - @rtl8139:
@@ -306,6 +353,22 @@ variants:
             migration_test_command = ver && vol
         stress_boot:
             alive_test_cmd = systeminfo
+        nic_hotplug:
+            modprobe_acpiphp = no
+            reference_cmd = systeminfo
+            seconds_wait_for_device_install = 10
+            find_pci_cmd = ipconfig /all | find "Description"
+            nic_e1000:
+                match_string = "Intel(R) PRO/1000 MT Network Connection"
+        block_hotplug:
+            use_telnet = yes
+            modprobe_acpiphp = no
+            reference_cmd = wmic diskdrive
+            find_pci_cmd = wmic diskdrive | find "disk drives"
+            seconds_wait_for_device_install = 10
+            only block_scsi
+            block_scsi:
+                match_string = "SCSI"
 
         variants:
             - Win2000:
@@ -571,4 +634,4 @@ variants:
         only rtl8139
 
 # Choose your test list
-only fc8_quick
+#only fc8_quick
diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
index 2d11fed..230385a 100644
--- a/client/tests/kvm/kvm_tests.py
+++ b/client/tests/kvm/kvm_tests.py
@@ -585,3 +585,97 @@ def run_stress_boot(tests, params, env):
         for se in sessions:
             se.close()
         logging.info("Total number booted: %d" % (num -1))
+
+
+def run_pci_hotplug(test, params, env):
+    """
+    Test pci devices' hotplug
+    1) pci_add a deivce (nic or storage)
+    2) Compare 'info pci' output
+    3) Compare $reference_cmd output
+    4) Verify whether pci_model is shown in $pci_find_cmd
+    5) pci_del the device, verify whether could remove the pci device
+
+    @param test:   kvm test object
+    @param params: Dictionary with the test parameters
+    @param env:    Dictionary with test environment.
+    """
+    vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
+    if not vm:
+        raise error.TestError("VM object not found in environment")
+    if not vm.is_alive():
+        raise error.TestError("VM seems to be dead; Test requires a living VM")
+
+    logging.info("Waiting for guest to be up...")
+
+    session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
+    if not session:
+        raise error.TestFail("Could not log into guest")
+
+    logging.info("Logged in")
+
+    # modprobe the module that enable hotplug
+    if params.get("modprobe_acpiphp") == "yes":
+        if session.get_command_status("modprobe acpiphp"):
+            raise error.TestError("Modprobe module 'acpiphp' failed")
+
+    # get reference output
+    s, info_pci_ref = vm.send_monitor_cmd("info pci")
+
+    # compare the output of `reference_cmd`
+    ref_cmd = params.get("reference_cmd")
+    reference = session.get_command_output(ref_cmd)
+
+    # implement pci hotplug
+    tested_model = params.get("pci_model")
+    logging.info("Testing hotplug pci device:%s" % tested_model)
+
+    test_type = params.get("pci_type")
+    if test_type == "nic":
+        pci_add_cmd = "pci_add pci_addr=auto nic model=%s" % tested_model
+        s, add_output = vm.send_monitor_cmd(pci_add_cmd)
+
+    elif test_type == "block":
+        image_name = params.get("image_name_stg")
+        image_format = params.get("image_format_stg", "qcow2")
+        image_filename = "%s.%s" % (image_name, image_format)
+        image_dir = os.path.join(test.bindir, "images")
+        storage_name = os.path.join(image_dir, image_filename)
+        pci_add_cmd = "pci_add pci_addr=auto storage file=%s,if=%s" % \
+                                              (storage_name, tested_model)
+        s, add_output = vm.send_monitor_cmd(pci_add_cmd)
+
+    if not "OK domain" in add_output:
+        raise error.TestFail("Command failed: %s" % pci_add_cmd)
+
+    # 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 in 'info pci'")
+
+    time.sleep(int(params.get("seconds_wait_for_device_install")))
+   
+    o = session.get_command_output(ref_cmd)
+    if reference == o:
+        raise error.TestFail("No new device shown in cmd: %s" % ref_cmd)
+
+    cmd = params.get("find_pci_cmd")
+    output = session.get_command_output(cmd)
+    if not params.get("match_string") in output:
+        raise error.TestFail("Not found pci model: %s; Command is: %s" % 
+                                                    (tested_model, cmd))
+
+    # del 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; Command:%s" %
+                                                     (tested_model, cmd))
+
+    # check whether VM's network & disk work fine
+    if session.get_command_status(params.get("pci_test_cmd")):
+        raise error.TestFail("Check for %s device failed after PCI hotplug" % 
+                                                                 test_type)
+
+    session.close()
diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 503f636..95b55eb 100644
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -239,6 +239,8 @@ class VM:
 
         for image_name in kvm_utils.get_sub_dict_names(params, "images"):
             image_params = kvm_utils.get_sub_dict(params, image_name)
+            if image_params.get("boot_drive") == "no":
+                continue
             qemu_cmd += " -drive file=%s" % get_image_filename(image_params,
                                                                image_dir)
             if image_params.get("drive_format"):
-- 
1.6.2.5


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] Add a subtest pci_hotplug in kvm test
  2009-07-03  5:57 [PATCH] Add a subtest pci_hotplug in kvm test Yolkfull Chow
@ 2009-07-03  6:00 ` Yolkfull Chow
  2009-07-08  1:51   ` [Autotest] " Lucas Meneghel Rodrigues
  0 siblings, 1 reply; 15+ messages in thread
From: Yolkfull Chow @ 2009-07-03  6:00 UTC (permalink / raw)
  To: kvm; +Cc: autotest, lmr

On 07/03/2009 01:57 PM, Yolkfull Chow wrote:
> Signed-off-by: Yolkfull Chow<yzhou@redhat.com>
> ---
>   client/tests/kvm/kvm.py               |    1 +
>   client/tests/kvm/kvm_tests.cfg.sample |   65 ++++++++++++++++++++++-
>   client/tests/kvm/kvm_tests.py         |   94 +++++++++++++++++++++++++++++++++
>   client/tests/kvm/kvm_vm.py            |    2 +
>   4 files changed, 161 insertions(+), 1 deletions(-)
>
> diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
> index b18b643..fc92e10 100644
> --- a/client/tests/kvm/kvm.py
> +++ b/client/tests/kvm/kvm.py
> @@ -55,6 +55,7 @@ class kvm(test.test):
>                   "kvm_install":  test_routine("kvm_install", "run_kvm_install"),
>                   "linux_s3":     test_routine("kvm_tests", "run_linux_s3"),
>                   "stress_boot":  test_routine("kvm_tests", "run_stress_boot"),
> +                "pci_hotplug":  test_routine("kvm_tests", "run_pci_hotplug"),
>                   }
>
>           # Make it possible to import modules from the test's bindir
> diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample
> index 2f864de..a9e16d6 100644
> --- a/client/tests/kvm/kvm_tests.cfg.sample
> +++ b/client/tests/kvm/kvm_tests.cfg.sample
> @@ -94,6 +94,53 @@ variants:
>           max_vms = 5
>           alive_test_cmd = ps aux
>
> +
> +    - nic_hotplug:
> +        type = pci_hotplug
> +        pci_type = nic
> +        modprobe_acpiphp = yes
> +        reference_cmd = lspci
> +        find_pci_cmd = 'lspci | tail -n1'
> +        pci_test_cmd = 'nslookup www.redhat.com'
> +        seconds_wait_for_device_install = 3
> +        variants:
> +            - @nic_8139:
> +                pci_model = rtl8139
> +                match_string = "8139"
> +            - nic_virtio:
> +                pci_model = virtio
> +                match_string = "Virtio network device"
> +            - nic_e1000:
> +                pci_model = e1000
> +                match_string = "Gigabit Ethernet Controller"
> +
> +    - block_hotplug:
> +        type = pci_hotplug
> +        pci_type = block
> +        modprobe_acpiphp = yes
> +        reference_cmd = lspci
> +        find_pci_cmd = 'lspci | tail -n1'
> +        images += " stg"
> +        boot_drive_stg = no
> +        image_name_stg = storage
> +        image_size = 1G
> +        force_create_image_stg = yes
> +        pci_test_cmd = 'dir'
> +        seconds_wait_for_device_install = 3
> +        variants:
> +            - block_virtio:
> +                pci_model = virtio
> +                match_string = "Virtio block device"
> +            - block_scsi:
> +                pci_model = scsi
> +                match_string = "SCSI storage controller"
> +        variants:
> +            - fmt_qcow2:
> +                image_format_stg = qcow2
> +            - fmt_raw:
> +                image_format_stg = raw
> +
> +
>   # NICs
>   variants:
>       - @rtl8139:
> @@ -306,6 +353,22 @@ variants:
>               migration_test_command = ver&&  vol
>           stress_boot:
>               alive_test_cmd = systeminfo
> +        nic_hotplug:
> +            modprobe_acpiphp = no
> +            reference_cmd = systeminfo
> +            seconds_wait_for_device_install = 10
> +            find_pci_cmd = ipconfig /all | find "Description"
> +            nic_e1000:
> +                match_string = "Intel(R) PRO/1000 MT Network Connection"
> +        block_hotplug:
> +            use_telnet = yes
> +            modprobe_acpiphp = no
> +            reference_cmd = wmic diskdrive
> +            find_pci_cmd = wmic diskdrive | find "disk drives"
> +            seconds_wait_for_device_install = 10
> +            only block_scsi
> +            block_scsi:
> +                match_string = "SCSI"
>    
It supports Windows block_hotplug now. But we need use_telnet to login 
Windows OS since command 'wmic' could only run on telnet session.
>
>           variants:
>               - Win2000:
> @@ -571,4 +634,4 @@ variants:
>           only rtl8139
>
>   # Choose your test list
> -only fc8_quick
> +#only fc8_quick
> diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
> index 2d11fed..230385a 100644
> --- a/client/tests/kvm/kvm_tests.py
> +++ b/client/tests/kvm/kvm_tests.py
> @@ -585,3 +585,97 @@ def run_stress_boot(tests, params, env):
>           for se in sessions:
>               se.close()
>           logging.info("Total number booted: %d" % (num -1))
> +
> +
> +def run_pci_hotplug(test, params, env):
> +    """
> +    Test pci devices' hotplug
> +    1) pci_add a deivce (nic or storage)
> +    2) Compare 'info pci' output
> +    3) Compare $reference_cmd output
> +    4) Verify whether pci_model is shown in $pci_find_cmd
> +    5) pci_del the device, verify whether could remove the pci device
> +
> +    @param test:   kvm test object
> +    @param params: Dictionary with the test parameters
> +    @param env:    Dictionary with test environment.
> +    """
> +    vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
> +    if not vm:
> +        raise error.TestError("VM object not found in environment")
> +    if not vm.is_alive():
> +        raise error.TestError("VM seems to be dead; Test requires a living VM")
> +
> +    logging.info("Waiting for guest to be up...")
> +
> +    session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
> +    if not session:
> +        raise error.TestFail("Could not log into guest")
> +
> +    logging.info("Logged in")
> +
> +    # modprobe the module that enable hotplug
> +    if params.get("modprobe_acpiphp") == "yes":
> +        if session.get_command_status("modprobe acpiphp"):
> +            raise error.TestError("Modprobe module 'acpiphp' failed")
> +
> +    # get reference output
> +    s, info_pci_ref = vm.send_monitor_cmd("info pci")
> +
> +    # compare the output of `reference_cmd`
> +    ref_cmd = params.get("reference_cmd")
> +    reference = session.get_command_output(ref_cmd)
> +
> +    # implement pci hotplug
> +    tested_model = params.get("pci_model")
> +    logging.info("Testing hotplug pci device:%s" % tested_model)
> +
> +    test_type = params.get("pci_type")
> +    if test_type == "nic":
> +        pci_add_cmd = "pci_add pci_addr=auto nic model=%s" % tested_model
> +        s, add_output = vm.send_monitor_cmd(pci_add_cmd)
> +
> +    elif test_type == "block":
> +        image_name = params.get("image_name_stg")
> +        image_format = params.get("image_format_stg", "qcow2")
> +        image_filename = "%s.%s" % (image_name, image_format)
> +        image_dir = os.path.join(test.bindir, "images")
> +        storage_name = os.path.join(image_dir, image_filename)
> +        pci_add_cmd = "pci_add pci_addr=auto storage file=%s,if=%s" % \
> +                                              (storage_name, tested_model)
> +        s, add_output = vm.send_monitor_cmd(pci_add_cmd)
> +
> +    if not "OK domain" in add_output:
> +        raise error.TestFail("Command failed: %s" % pci_add_cmd)
> +
> +    # 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 in 'info pci'")
> +
> +    time.sleep(int(params.get("seconds_wait_for_device_install")))
> +
> +    o = session.get_command_output(ref_cmd)
> +    if reference == o:
> +        raise error.TestFail("No new device shown in cmd: %s" % ref_cmd)
> +
> +    cmd = params.get("find_pci_cmd")
> +    output = session.get_command_output(cmd)
> +    if not params.get("match_string") in output:
> +        raise error.TestFail("Not found pci model: %s; Command is: %s" %
> +                                                    (tested_model, cmd))
> +
> +    # del 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; Command:%s" %
> +                                                     (tested_model, cmd))
> +
> +    # check whether VM's network&  disk work fine
> +    if session.get_command_status(params.get("pci_test_cmd")):
> +        raise error.TestFail("Check for %s device failed after PCI hotplug" %
> +                                                                 test_type)
> +
> +    session.close()
> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
> index 503f636..95b55eb 100644
> --- a/client/tests/kvm/kvm_vm.py
> +++ b/client/tests/kvm/kvm_vm.py
> @@ -239,6 +239,8 @@ class VM:
>
>           for image_name in kvm_utils.get_sub_dict_names(params, "images"):
>               image_params = kvm_utils.get_sub_dict(params, image_name)
> +            if image_params.get("boot_drive") == "no":
> +                continue
>               qemu_cmd += " -drive file=%s" % get_image_filename(image_params,
>                                                                  image_dir)
>               if image_params.get("drive_format"):
>    


-- 
Yolkfull
Regards,


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Autotest] [PATCH] Add a subtest pci_hotplug in kvm test
  2009-07-03  6:00 ` Yolkfull Chow
@ 2009-07-08  1:51   ` Lucas Meneghel Rodrigues
  2009-07-10  2:01     ` Yolkfull Chow
  2009-07-15  3:37     ` Yolkfull Chow
  0 siblings, 2 replies; 15+ messages in thread
From: Lucas Meneghel Rodrigues @ 2009-07-08  1:51 UTC (permalink / raw)
  To: Yolkfull Chow; +Cc: kvm, autotest

I've spent some time doing a second review and test of the code.
During my tests:

 * I found some problems with PCI hotplug itself and would like help
to figure out why things are not working as expected.
 * Made suggestions regarding the phrasing of the error messages
thrown by the test. Mostly nipticking. Let me know if you think the
new messages make sense.
 * The order of the final test steps looks a bit weird to me

Comments follow.

On Fri, Jul 3, 2009 at 3:00 AM, Yolkfull Chow<yzhou@redhat.com> wrote:
> On 07/03/2009 01:57 PM, Yolkfull Chow wrote:
>> Signed-off-by: Yolkfull Chow<yzhou@redhat.com>
>> ---
>>   client/tests/kvm/kvm.py               |    1 +
>>   client/tests/kvm/kvm_tests.cfg.sample |   65 ++++++++++++++++++++++-
>>   client/tests/kvm/kvm_tests.py         |   94 +++++++++++++++++++++++++++++++++
>>   client/tests/kvm/kvm_vm.py            |    2 +
>>   4 files changed, 161 insertions(+), 1 deletions(-)
>>
>> diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
>> index b18b643..fc92e10 100644
>> --- a/client/tests/kvm/kvm.py
>> +++ b/client/tests/kvm/kvm.py
>> @@ -55,6 +55,7 @@ class kvm(test.test):
>>                   "kvm_install":  test_routine("kvm_install", "run_kvm_install"),
>>                   "linux_s3":     test_routine("kvm_tests", "run_linux_s3"),
>>                   "stress_boot":  test_routine("kvm_tests", "run_stress_boot"),
>> +                "pci_hotplug":  test_routine("kvm_tests", "run_pci_hotplug"),
>>                   }
>>
>>           # Make it possible to import modules from the test's bindir
>> diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample
>> index 2f864de..a9e16d6 100644
>> --- a/client/tests/kvm/kvm_tests.cfg.sample
>> +++ b/client/tests/kvm/kvm_tests.cfg.sample
>> @@ -94,6 +94,53 @@ variants:
>>           max_vms = 5
>>           alive_test_cmd = ps aux
>>
>> +
>> +    - nic_hotplug:
>> +        type = pci_hotplug
>> +        pci_type = nic
>> +        modprobe_acpiphp = yes
>> +        reference_cmd = lspci
>> +        find_pci_cmd = 'lspci | tail -n1'

I tried block device hotplug, lspci doesn't show up the newly added
devices. Already tried with F8 and F9. Any idea why?

>> +        pci_test_cmd = 'nslookup www.redhat.com'
>> +        seconds_wait_for_device_install = 3
>> +        variants:
>> +            - @nic_8139:
>> +                pci_model = rtl8139
>> +                match_string = "8139"
>> +            - nic_virtio:
>> +                pci_model = virtio
>> +                match_string = "Virtio network device"
>> +            - nic_e1000:
>> +                pci_model = e1000
>> +                match_string = "Gigabit Ethernet Controller"

Pretty much all block hotplug 'guest side check' is failing during the
stage where the output  of lspci | tail -n1 is being compared with the
match strings. Hypervisor is qemu 0.10.5 (kvm-87 upstream).

>> +    - block_hotplug:
>> +        type = pci_hotplug
>> +        pci_type = block
>> +        modprobe_acpiphp = yes
>> +        reference_cmd = lspci
>> +        find_pci_cmd = 'lspci | tail -n1'
>> +        images += " stg"
>> +        boot_drive_stg = no
>> +        image_name_stg = storage
>> +        image_size = 1G
>> +        force_create_image_stg = yes
>> +        pci_test_cmd = 'dir'
>> +        seconds_wait_for_device_install = 3
>> +        variants:
>> +            - block_virtio:
>> +                pci_model = virtio
>> +                match_string = "Virtio block device"
>> +            - block_scsi:
>> +                pci_model = scsi
>> +                match_string = "SCSI storage controller"
>> +        variants:
>> +            - fmt_qcow2:
>> +                image_format_stg = qcow2
>> +            - fmt_raw:
>> +                image_format_stg = raw
>> +
>> +
>>   # NICs
>>   variants:
>>       - @rtl8139:
>> @@ -306,6 +353,22 @@ variants:
>>               migration_test_command = ver&&  vol
>>           stress_boot:
>>               alive_test_cmd = systeminfo
>> +        nic_hotplug:
>> +            modprobe_acpiphp = no
>> +            reference_cmd = systeminfo
>> +            seconds_wait_for_device_install = 10
>> +            find_pci_cmd = ipconfig /all | find "Description"
>> +            nic_e1000:
>> +                match_string = "Intel(R) PRO/1000 MT Network Connection"
>> +        block_hotplug:
>> +            use_telnet = yes
>> +            modprobe_acpiphp = no
>> +            reference_cmd = wmic diskdrive
>> +            find_pci_cmd = wmic diskdrive | find "disk drives"
>> +            seconds_wait_for_device_install = 10
>> +            only block_scsi
>> +            block_scsi:
>> +                match_string = "SCSI"
>>
> It supports Windows block_hotplug now. But we need use_telnet to login
> Windows OS since command 'wmic' could only run on telnet session.
>>
>>           variants:
>>               - Win2000:
>> @@ -571,4 +634,4 @@ variants:
>>           only rtl8139
>>
>>   # Choose your test list
>> -only fc8_quick
>> +#only fc8_quick
>> diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
>> index 2d11fed..230385a 100644
>> --- a/client/tests/kvm/kvm_tests.py
>> +++ b/client/tests/kvm/kvm_tests.py
>> @@ -585,3 +585,97 @@ def run_stress_boot(tests, params, env):
>>           for se in sessions:
>>               se.close()
>>           logging.info("Total number booted: %d" % (num -1))
>> +
>> +
>> +def run_pci_hotplug(test, params, env):
>> +    """
>> +    Test pci devices' hotplug
>> +    1) pci_add a deivce (nic or storage)
>> +    2) Compare 'info pci' output
>> +    3) Compare $reference_cmd output
>> +    4) Verify whether pci_model is shown in $pci_find_cmd
>> +    5) pci_del the device, verify whether could remove the pci device

What about if the last steps were

5) Verify if the newly added devices are working properly
6) pci_del the device, verify whether could remove the pci device

6) is already happening in the code, but in reverse order than mentioned above.

>> +    @param test:   kvm test object
>> +    @param params: Dictionary with the test parameters
>> +    @param env:    Dictionary with test environment.
>> +    """
>> +    vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
>> +    if not vm:
>> +        raise error.TestError("VM object not found in environment")
>> +    if not vm.is_alive():
>> +        raise error.TestError("VM seems to be dead; Test requires a living VM")
>> +
>> +    logging.info("Waiting for guest to be up...")
>> +
>> +    session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
>> +    if not session:
>> +        raise error.TestFail("Could not log into guest")
>> +
>> +    logging.info("Logged in")
>> +
>> +    # modprobe the module that enable hotplug
>> +    if params.get("modprobe_acpiphp") == "yes":
>> +        if session.get_command_status("modprobe acpiphp"):
>> +            raise error.TestError("Modprobe module 'acpiphp' failed")
>> +
>> +    # get reference output
>> +    s, info_pci_ref = vm.send_monitor_cmd("info pci")
>> +
>> +    # compare the output of `reference_cmd`
>> +    ref_cmd = params.get("reference_cmd")
>> +    reference = session.get_command_output(ref_cmd)
>> +
>> +    # implement pci hotplug
>> +    tested_model = params.get("pci_model")
>> +    logging.info("Testing hotplug pci device:%s" % tested_model)
>> +
>> +    test_type = params.get("pci_type")
>> +    if test_type == "nic":
>> +        pci_add_cmd = "pci_add pci_addr=auto nic model=%s" % tested_model
>> +        s, add_output = vm.send_monitor_cmd(pci_add_cmd)

The command

s, add_output = vm.send_monitor_cmd(pci_add_cmd)

Can be moved out the if blocks since it will be executed in both
paths, we save one line of code with this (and it's cleaner anyway).

>> +    elif test_type == "block":
>> +        image_name = params.get("image_name_stg")
>> +        image_format = params.get("image_format_stg", "qcow2")
>> +        image_filename = "%s.%s" % (image_name, image_format)
>> +        image_dir = os.path.join(test.bindir, "images")
>> +        storage_name = os.path.join(image_dir, image_filename)
>> +        pci_add_cmd = "pci_add pci_addr=auto storage file=%s,if=%s" % \
>> +                                              (storage_name, tested_model)

The above line would be better with implicit line continuation

pci_add_cmd = ("pci_add pci_addr=auto storage file=%s,if=%s" %
                        (storage_name, tested_model))

>> +        s, add_output = vm.send_monitor_cmd(pci_add_cmd)
>> +
>> +    if not "OK domain" in add_output:
>> +        raise error.TestFail("Command failed: %s" % pci_add_cmd)

Since we're executing a command on the hypervisor to add the device, a
better way to put the above message would be

    if not "OK domain" in add_output:
        raise error.TestFail("Hypervisor command to add device '%s'failed."
                             "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 in 'info pci'")

Another suggestion:

        raise error.TestFail("No new PCI device shown after executing "
                             "hypervisor command 'info pci'")


>> +    time.sleep(int(params.get("seconds_wait_for_device_install")))
>> +
>> +    o = session.get_command_output(ref_cmd)
>> +    if reference == o:
>> +        raise error.TestFail("No new device shown in cmd: %s" % ref_cmd)

I found useful to explain on which side of the check the test fail,
'hypervisor', or 'guest'

        raise error.TestFail("No new device shown on guest command %s output" %
                             ref_cmd)


>> +    cmd = params.get("find_pci_cmd")
>> +    output = session.get_command_output(cmd)
>> +    if not params.get("match_string") in output:
>> +        raise error.TestFail("Not found pci model: %s; Command is: %s" %
>> +                                                    (tested_model, cmd))

        raise error.TestFail("PCI device model '%s' not found on host "
                             "command '%s' ouput" % (tested_model, cmd))

>> +    # del 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; Command:%s" %
>> +                                                     (tested_model, cmd))

        raise error.TestFail("Failed to hot remove pci device '%s'. "
                             "Hypervisor command: '%s'" % (tested_model, cmd))

Hot remove doesn't work for me either... Since we are here, I still
didn't understand why we do a hot remove of a device and right below
it we try to verify if the newly added devices are working properly.
Shouldn't be the other way around (ie checking and then hot removing)?

>> +    # check whether VM's network&  disk work fine
>> +    if session.get_command_status(params.get("pci_test_cmd")):
>> +        raise error.TestFail("Check for %s device failed after PCI hotplug" %
>> +                                                                 test_type)
>> +
>> +    session.close()
>> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
>> index 503f636..95b55eb 100644
>> --- a/client/tests/kvm/kvm_vm.py
>> +++ b/client/tests/kvm/kvm_vm.py
>> @@ -239,6 +239,8 @@ class VM:
>>
>>           for image_name in kvm_utils.get_sub_dict_names(params, "images"):
>>               image_params = kvm_utils.get_sub_dict(params, image_name)
>> +            if image_params.get("boot_drive") == "no":
>> +                continue
>>               qemu_cmd += " -drive file=%s" % get_image_filename(image_params,
>>                                                                  image_dir)
>>               if image_params.get("drive_format"):

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Autotest] [PATCH] Add a subtest pci_hotplug in kvm test
  2009-07-08  1:51   ` [Autotest] " Lucas Meneghel Rodrigues
@ 2009-07-10  2:01     ` Yolkfull Chow
  2009-07-15  3:37     ` Yolkfull Chow
  1 sibling, 0 replies; 15+ messages in thread
From: Yolkfull Chow @ 2009-07-10  2:01 UTC (permalink / raw)
  To: Lucas Meneghel Rodrigues; +Cc: kvm, autotest

On 07/08/2009 09:51 AM, Lucas Meneghel Rodrigues wrote:
> I've spent some time doing a second review and test of the code.
> During my tests:
>
>   * I found some problems with PCI hotplug itself and would like help
> to figure out why things are not working as expected.
>   * Made suggestions regarding the phrasing of the error messages
> thrown by the test. Mostly nipticking. Let me know if you think the
> new messages make sense.
>   * The order of the final test steps looks a bit weird to me
>
> Comments follow.
>    

Lucas, sorry for reply you a little late since I left two days. :)

> On Fri, Jul 3, 2009 at 3:00 AM, Yolkfull Chow<yzhou@redhat.com>  wrote:
>    
>> On 07/03/2009 01:57 PM, Yolkfull Chow wrote:
>>      
>>> Signed-off-by: Yolkfull Chow<yzhou@redhat.com>
>>> ---
>>>    client/tests/kvm/kvm.py               |    1 +
>>>    client/tests/kvm/kvm_tests.cfg.sample |   65 ++++++++++++++++++++++-
>>>    client/tests/kvm/kvm_tests.py         |   94 +++++++++++++++++++++++++++++++++
>>>    client/tests/kvm/kvm_vm.py            |    2 +
>>>    4 files changed, 161 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
>>> index b18b643..fc92e10 100644
>>> --- a/client/tests/kvm/kvm.py
>>> +++ b/client/tests/kvm/kvm.py
>>> @@ -55,6 +55,7 @@ class kvm(test.test):
>>>                    "kvm_install":  test_routine("kvm_install", "run_kvm_install"),
>>>                    "linux_s3":     test_routine("kvm_tests", "run_linux_s3"),
>>>                    "stress_boot":  test_routine("kvm_tests", "run_stress_boot"),
>>> +                "pci_hotplug":  test_routine("kvm_tests", "run_pci_hotplug"),
>>>                    }
>>>
>>>            # Make it possible to import modules from the test's bindir
>>> diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample
>>> index 2f864de..a9e16d6 100644
>>> --- a/client/tests/kvm/kvm_tests.cfg.sample
>>> +++ b/client/tests/kvm/kvm_tests.cfg.sample
>>> @@ -94,6 +94,53 @@ variants:
>>>            max_vms = 5
>>>            alive_test_cmd = ps aux
>>>
>>> +
>>> +    - nic_hotplug:
>>> +        type = pci_hotplug
>>> +        pci_type = nic
>>> +        modprobe_acpiphp = yes
>>> +        reference_cmd = lspci
>>> +        find_pci_cmd = 'lspci | tail -n1'
>>>        
> I tried block device hotplug, lspci doesn't show up the newly added
> devices. Already tried with F8 and F9. Any idea why?
>    
Strange, it could be run successfully with guest RHEL.5.3.i386 and 
Win2008.32(use telnet login), but I never run it on Fedora. Jason 
reminded me several days ago that there is no 'acpiphp' module on Fedora 
which may be related. Anyway, I will fix it.
>    
>>> +        pci_test_cmd = 'nslookup www.redhat.com'
>>> +        seconds_wait_for_device_install = 3
>>> +        variants:
>>> +            - @nic_8139:
>>> +                pci_model = rtl8139
>>> +                match_string = "8139"
>>> +            - nic_virtio:
>>> +                pci_model = virtio
>>> +                match_string = "Virtio network device"
>>> +            - nic_e1000:
>>> +                pci_model = e1000
>>> +                match_string = "Gigabit Ethernet Controller"
>>>        
> Pretty much all block hotplug 'guest side check' is failing during the
> stage where the output  of lspci | tail -n1 is being compared with the
> match strings. Hypervisor is qemu 0.10.5 (kvm-87 upstream).
>
>    
>>> +    - block_hotplug:
>>> +        type = pci_hotplug
>>> +        pci_type = block
>>> +        modprobe_acpiphp = yes
>>> +        reference_cmd = lspci
>>> +        find_pci_cmd = 'lspci | tail -n1'
>>> +        images += " stg"
>>> +        boot_drive_stg = no
>>> +        image_name_stg = storage
>>> +        image_size = 1G
>>> +        force_create_image_stg = yes
>>> +        pci_test_cmd = 'dir'
>>> +        seconds_wait_for_device_install = 3
>>> +        variants:
>>> +            - block_virtio:
>>> +                pci_model = virtio
>>> +                match_string = "Virtio block device"
>>> +            - block_scsi:
>>> +                pci_model = scsi
>>> +                match_string = "SCSI storage controller"
>>> +        variants:
>>> +            - fmt_qcow2:
>>> +                image_format_stg = qcow2
>>> +            - fmt_raw:
>>> +                image_format_stg = raw
>>> +
>>> +
>>>    # NICs
>>>    variants:
>>>        - @rtl8139:
>>> @@ -306,6 +353,22 @@ variants:
>>>                migration_test_command = ver&&    vol
>>>            stress_boot:
>>>                alive_test_cmd = systeminfo
>>> +        nic_hotplug:
>>> +            modprobe_acpiphp = no
>>> +            reference_cmd = systeminfo
>>> +            seconds_wait_for_device_install = 10
>>> +            find_pci_cmd = ipconfig /all | find "Description"
>>> +            nic_e1000:
>>> +                match_string = "Intel(R) PRO/1000 MT Network Connection"
>>> +        block_hotplug:
>>> +            use_telnet = yes
>>> +            modprobe_acpiphp = no
>>> +            reference_cmd = wmic diskdrive
>>> +            find_pci_cmd = wmic diskdrive | find "disk drives"
>>> +            seconds_wait_for_device_install = 10
>>> +            only block_scsi
>>> +            block_scsi:
>>> +                match_string = "SCSI"
>>>
>>>        
>> It supports Windows block_hotplug now. But we need use_telnet to login
>> Windows OS since command 'wmic' could only run on telnet session.
>>      
>>>            variants:
>>>                - Win2000:
>>> @@ -571,4 +634,4 @@ variants:
>>>            only rtl8139
>>>
>>>    # Choose your test list
>>> -only fc8_quick
>>> +#only fc8_quick
>>> diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
>>> index 2d11fed..230385a 100644
>>> --- a/client/tests/kvm/kvm_tests.py
>>> +++ b/client/tests/kvm/kvm_tests.py
>>> @@ -585,3 +585,97 @@ def run_stress_boot(tests, params, env):
>>>            for se in sessions:
>>>                se.close()
>>>            logging.info("Total number booted: %d" % (num -1))
>>> +
>>> +
>>> +def run_pci_hotplug(test, params, env):
>>> +    """
>>> +    Test pci devices' hotplug
>>> +    1) pci_add a deivce (nic or storage)
>>> +    2) Compare 'info pci' output
>>> +    3) Compare $reference_cmd output
>>> +    4) Verify whether pci_model is shown in $pci_find_cmd
>>> +    5) pci_del the device, verify whether could remove the pci device
>>>        
> What about if the last steps were
>
> 5) Verify if the newly added devices are working properly
> 6) pci_del the device, verify whether could remove the pci device
>
> 6) is already happening in the code, but in reverse order than mentioned above.
>
>    
>>> +    @param test:   kvm test object
>>> +    @param params: Dictionary with the test parameters
>>> +    @param env:    Dictionary with test environment.
>>> +    """
>>> +    vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
>>> +    if not vm:
>>> +        raise error.TestError("VM object not found in environment")
>>> +    if not vm.is_alive():
>>> +        raise error.TestError("VM seems to be dead; Test requires a living VM")
>>> +
>>> +    logging.info("Waiting for guest to be up...")
>>> +
>>> +    session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
>>> +    if not session:
>>> +        raise error.TestFail("Could not log into guest")
>>> +
>>> +    logging.info("Logged in")
>>> +
>>> +    # modprobe the module that enable hotplug
>>> +    if params.get("modprobe_acpiphp") == "yes":
>>> +        if session.get_command_status("modprobe acpiphp"):
>>> +            raise error.TestError("Modprobe module 'acpiphp' failed")
>>> +
>>> +    # get reference output
>>> +    s, info_pci_ref = vm.send_monitor_cmd("info pci")
>>> +
>>> +    # compare the output of `reference_cmd`
>>> +    ref_cmd = params.get("reference_cmd")
>>> +    reference = session.get_command_output(ref_cmd)
>>> +
>>> +    # implement pci hotplug
>>> +    tested_model = params.get("pci_model")
>>> +    logging.info("Testing hotplug pci device:%s" % tested_model)
>>> +
>>> +    test_type = params.get("pci_type")
>>> +    if test_type == "nic":
>>> +        pci_add_cmd = "pci_add pci_addr=auto nic model=%s" % tested_model
>>> +        s, add_output = vm.send_monitor_cmd(pci_add_cmd)
>>>        
> The command
>
> s, add_output = vm.send_monitor_cmd(pci_add_cmd)
>
> Can be moved out the if blocks since it will be executed in both
> paths, we save one line of code with this (and it's cleaner anyway).
>
>    
>>> +    elif test_type == "block":
>>> +        image_name = params.get("image_name_stg")
>>> +        image_format = params.get("image_format_stg", "qcow2")
>>> +        image_filename = "%s.%s" % (image_name, image_format)
>>> +        image_dir = os.path.join(test.bindir, "images")
>>> +        storage_name = os.path.join(image_dir, image_filename)
>>> +        pci_add_cmd = "pci_add pci_addr=auto storage file=%s,if=%s" % \
>>> +                                              (storage_name, tested_model)
>>>        
> The above line would be better with implicit line continuation
>
> pci_add_cmd = ("pci_add pci_addr=auto storage file=%s,if=%s" %
>                          (storage_name, tested_model))
>
>    
>>> +        s, add_output = vm.send_monitor_cmd(pci_add_cmd)
>>> +
>>> +    if not "OK domain" in add_output:
>>> +        raise error.TestFail("Command failed: %s" % pci_add_cmd)
>>>        
> Since we're executing a command on the hypervisor to add the device, a
> better way to put the above message would be
>
>      if not "OK domain" in add_output:
>          raise error.TestFail("Hypervisor command to add device '%s'failed."
>                               "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 in 'info pci'")
>>>        
> Another suggestion:
>
>          raise error.TestFail("No new PCI device shown after executing "
>                               "hypervisor command 'info pci'")
>
>
>    
>>> +    time.sleep(int(params.get("seconds_wait_for_device_install")))
>>> +
>>> +    o = session.get_command_output(ref_cmd)
>>> +    if reference == o:
>>> +        raise error.TestFail("No new device shown in cmd: %s" % ref_cmd)
>>>        
> I found useful to explain on which side of the check the test fail,
> 'hypervisor', or 'guest'
>
>          raise error.TestFail("No new device shown on guest command %s output" %
>                               ref_cmd)
>
>
>    
>>> +    cmd = params.get("find_pci_cmd")
>>> +    output = session.get_command_output(cmd)
>>> +    if not params.get("match_string") in output:
>>> +        raise error.TestFail("Not found pci model: %s; Command is: %s" %
>>> +                                                    (tested_model, cmd))
>>>        
>          raise error.TestFail("PCI device model '%s' not found on host "
>                               "command '%s' ouput" % (tested_model, cmd))
>
>    
>>> +    # del 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; Command:%s" %
>>> +                                                     (tested_model, cmd))
>>>        
>          raise error.TestFail("Failed to hot remove pci device '%s'. "
>                               "Hypervisor command: '%s'" % (tested_model, cmd))
>
> Hot remove doesn't work for me either... Since we are here, I still
> didn't understand why we do a hot remove of a device and right below
> it we try to verify if the newly added devices are working properly.
> Shouldn't be the other way around (ie checking and then hot removing)?
>
>    
>>> +    # check whether VM's network&    disk work fine
>>> +    if session.get_command_status(params.get("pci_test_cmd")):
>>> +        raise error.TestFail("Check for %s device failed after PCI hotplug" %
>>> +                                                                 test_type)
>>> +
>>> +    session.close()
>>> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
>>> index 503f636..95b55eb 100644
>>> --- a/client/tests/kvm/kvm_vm.py
>>> +++ b/client/tests/kvm/kvm_vm.py
>>> @@ -239,6 +239,8 @@ class VM:
>>>
>>>            for image_name in kvm_utils.get_sub_dict_names(params, "images"):
>>>                image_params = kvm_utils.get_sub_dict(params, image_name)
>>> +            if image_params.get("boot_drive") == "no":
>>> +                continue
>>>                qemu_cmd += " -drive file=%s" % get_image_filename(image_params,
>>>                                                                   image_dir)
>>>                if image_params.get("drive_format"):
>>>        


-- 
Yolkfull
Regards,


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Autotest] [PATCH] Add a subtest pci_hotplug in kvm test
  2009-07-08  1:51   ` [Autotest] " Lucas Meneghel Rodrigues
  2009-07-10  2:01     ` Yolkfull Chow
@ 2009-07-15  3:37     ` Yolkfull Chow
  1 sibling, 0 replies; 15+ messages in thread
From: Yolkfull Chow @ 2009-07-15  3:37 UTC (permalink / raw)
  To: Lucas Meneghel Rodrigues; +Cc: kvm, autotest

On 07/08/2009 09:51 AM, Lucas Meneghel Rodrigues wrote:
> I've spent some time doing a second review and test of the code.
> During my tests:
>
>   * I found some problems with PCI hotplug itself and would like help
> to figure out why things are not working as expected.
>   * Made suggestions regarding the phrasing of the error messages
> thrown by the test. Mostly nipticking. Let me know if you think the
> new messages make sense.
>   * The order of the final test steps looks a bit weird to me
>
> Comments follow.
>
> On Fri, Jul 3, 2009 at 3:00 AM, Yolkfull Chow<yzhou@redhat.com>  wrote:
>    
>> On 07/03/2009 01:57 PM, Yolkfull Chow wrote:
>>      
>>> Signed-off-by: Yolkfull Chow<yzhou@redhat.com>
>>> ---
>>>    client/tests/kvm/kvm.py               |    1 +
>>>    client/tests/kvm/kvm_tests.cfg.sample |   65 ++++++++++++++++++++++-
>>>    client/tests/kvm/kvm_tests.py         |   94 +++++++++++++++++++++++++++++++++
>>>    client/tests/kvm/kvm_vm.py            |    2 +
>>>    4 files changed, 161 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
>>> index b18b643..fc92e10 100644
>>> --- a/client/tests/kvm/kvm.py
>>> +++ b/client/tests/kvm/kvm.py
>>> @@ -55,6 +55,7 @@ class kvm(test.test):
>>>                    "kvm_install":  test_routine("kvm_install", "run_kvm_install"),
>>>                    "linux_s3":     test_routine("kvm_tests", "run_linux_s3"),
>>>                    "stress_boot":  test_routine("kvm_tests", "run_stress_boot"),
>>> +                "pci_hotplug":  test_routine("kvm_tests", "run_pci_hotplug"),
>>>                    }
>>>
>>>            # Make it possible to import modules from the test's bindir
>>> diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample
>>> index 2f864de..a9e16d6 100644
>>> --- a/client/tests/kvm/kvm_tests.cfg.sample
>>> +++ b/client/tests/kvm/kvm_tests.cfg.sample
>>> @@ -94,6 +94,53 @@ variants:
>>>            max_vms = 5
>>>            alive_test_cmd = ps aux
>>>
>>> +
>>> +    - nic_hotplug:
>>> +        type = pci_hotplug
>>> +        pci_type = nic
>>> +        modprobe_acpiphp = yes
>>> +        reference_cmd = lspci
>>> +        find_pci_cmd = 'lspci | tail -n1'
>>>        
> I tried block device hotplug, lspci doesn't show up the newly added
> devices. Already tried with F8 and F9. Any idea why?
>    
   It doesn't need to modprobe acpiphp on Fedora, also, both F8 and F9 
don't have virtio & virtio_ring modules.  I ran it on guest Fedora-11 
and Win2008,  both ran successfully:

# ./scan_results.py
test                                                    status    
seconds    info
----                                                    ------    
-------    ----
Fedora.11.32.nic_hotplug.nic_rtl8139                            GOOD    
68    completed successfully
Fedora.11.32.nic_hotplug.nic_virtio                     GOOD    46    
completed successfully
Fedora.11.32.block_hotplug.fmt_qcow2.block_virtio        GOOD    46    
completed successfully
Fedora.11.32.block_hotplug.fmt_qcow2.block_scsi         GOOD    44    
completed successfully
Fedora.11.32.block_hotplug.fmt_raw.block_virtio         GOOD    45    
completed successfully
Fedora.11.32.block_hotplug.fmt_raw.block_scsi           GOOD    46    
completed successfully
Win2008.32.nic_hotplug.nic_rtl8139                              GOOD    
66    completed successfully
Win2008.32.block_hotplug.fmt_qcow2.block_scsi           GOOD    186    
completed successfully
Win2008.32.block_hotplug.fmt_raw.block_scsi             GOOD    71    
completed successfully

>    
>>> +        pci_test_cmd = 'nslookupwww.redhat.com'
>>> +        seconds_wait_for_device_install = 3
>>> +        variants:
>>> +            - @nic_8139:
>>> +                pci_model = rtl8139
>>> +                match_string = "8139"
>>> +            - nic_virtio:
>>> +                pci_model = virtio
>>> +                match_string = "Virtio network device"
>>> +            - nic_e1000:
>>> +                pci_model = e1000
>>> +                match_string = "Gigabit Ethernet Controller"
>>>        
> Pretty much all block hotplug 'guest side check' is failing during the
> stage where the output  of lspci | tail -n1 is being compared with the
> match strings. Hypervisor is qemu 0.10.5 (kvm-87 upstream).
>
>    
>>> +    - block_hotplug:
>>> +        type = pci_hotplug
>>> +        pci_type = block
>>> +        modprobe_acpiphp = yes
>>> +        reference_cmd = lspci
>>> +        find_pci_cmd = 'lspci | tail -n1'
>>> +        images += " stg"
>>> +        boot_drive_stg = no
>>> +        image_name_stg = storage
>>> +        image_size = 1G
>>> +        force_create_image_stg = yes
>>> +        pci_test_cmd = 'dir'
>>> +        seconds_wait_for_device_install = 3
>>> +        variants:
>>> +            - block_virtio:
>>> +                pci_model = virtio
>>> +                match_string = "Virtio block device"
>>> +            - block_scsi:
>>> +                pci_model = scsi
>>> +                match_string = "SCSI storage controller"
>>> +        variants:
>>> +            - fmt_qcow2:
>>> +                image_format_stg = qcow2
>>> +            - fmt_raw:
>>> +                image_format_stg = raw
>>> +
>>> +
>>>    # NICs
>>>    variants:
>>>        - @rtl8139:
>>> @@ -306,6 +353,22 @@ variants:
>>>                migration_test_command = ver&&    vol
>>>            stress_boot:
>>>                alive_test_cmd = systeminfo
>>> +        nic_hotplug:
>>> +            modprobe_acpiphp = no
>>> +            reference_cmd = systeminfo
>>> +            seconds_wait_for_device_install = 10
>>> +            find_pci_cmd = ipconfig /all | find "Description"
>>> +            nic_e1000:
>>> +                match_string = "Intel(R) PRO/1000 MT Network Connection"
>>> +        block_hotplug:
>>> +            use_telnet = yes
>>> +            modprobe_acpiphp = no
>>> +            reference_cmd = wmic diskdrive
>>> +            find_pci_cmd = wmic diskdrive | find "disk drives"
>>> +            seconds_wait_for_device_install = 10
>>> +            only block_scsi
>>> +            block_scsi:
>>> +                match_string = "SCSI"
>>>
>>>        
>> It supports Windows block_hotplug now. But we need use_telnet to login
>> Windows OS since command 'wmic' could only run on telnet session.
>>      
>>>            variants:
>>>                - Win2000:
>>> @@ -571,4 +634,4 @@ variants:
>>>            only rtl8139
>>>
>>>    # Choose your test list
>>> -only fc8_quick
>>> +#only fc8_quick
>>> diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
>>> index 2d11fed..230385a 100644
>>> --- a/client/tests/kvm/kvm_tests.py
>>> +++ b/client/tests/kvm/kvm_tests.py
>>> @@ -585,3 +585,97 @@ def run_stress_boot(tests, params, env):
>>>            for se in sessions:
>>>                se.close()
>>>            logging.info("Total number booted: %d" % (num -1))
>>> +
>>> +
>>> +def run_pci_hotplug(test, params, env):
>>> +    """
>>> +    Test pci devices' hotplug
>>> +    1) pci_add a deivce (nic or storage)
>>> +    2) Compare 'info pci' output
>>> +    3) Compare $reference_cmd output
>>> +    4) Verify whether pci_model is shown in $pci_find_cmd
>>> +    5) pci_del the device, verify whether could remove the pci device
>>>        
> What about if the last steps were
>
> 5) Verify if the newly added devices are working properly
>    
Had worked out how to verify the newly added block device. Will send it 
here right now. Any suggestion about how to verify newly added nic card 
? So far I just keep
  'nslookup www.redhat.com' to check network simply.
> 6) pci_del the device, verify whether could remove the pci device
>
> 6) is already happening in the code, but in reverse order than mentioned above.
>
>    
>>> +    @param test:   kvm test object
>>> +    @param params: Dictionary with the test parameters
>>> +    @param env:    Dictionary with test environment.
>>> +    """
>>> +    vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
>>> +    if not vm:
>>> +        raise error.TestError("VM object not found in environment")
>>> +    if not vm.is_alive():
>>> +        raise error.TestError("VM seems to be dead; Test requires a living VM")
>>> +
>>> +    logging.info("Waiting for guest to be up...")
>>> +
>>> +    session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
>>> +    if not session:
>>> +        raise error.TestFail("Could not log into guest")
>>> +
>>> +    logging.info("Logged in")
>>> +
>>> +    # modprobe the module that enable hotplug
>>> +    if params.get("modprobe_acpiphp") == "yes":
>>> +        if session.get_command_status("modprobe acpiphp"):
>>> +            raise error.TestError("Modprobe module 'acpiphp' failed")
>>> +
>>> +    # get reference output
>>> +    s, info_pci_ref = vm.send_monitor_cmd("info pci")
>>> +
>>> +    # compare the output of `reference_cmd`
>>> +    ref_cmd = params.get("reference_cmd")
>>> +    reference = session.get_command_output(ref_cmd)
>>> +
>>> +    # implement pci hotplug
>>> +    tested_model = params.get("pci_model")
>>> +    logging.info("Testing hotplug pci device:%s" % tested_model)
>>> +
>>> +    test_type = params.get("pci_type")
>>> +    if test_type == "nic":
>>> +        pci_add_cmd = "pci_add pci_addr=auto nic model=%s" % tested_model
>>> +        s, add_output = vm.send_monitor_cmd(pci_add_cmd)
>>>        
> The command
>
> s, add_output = vm.send_monitor_cmd(pci_add_cmd)
>
> Can be moved out the if blocks since it will be executed in both
> paths, we save one line of code with this (and it's cleaner anyway).
>
>    
>>> +    elif test_type == "block":
>>> +        image_name = params.get("image_name_stg")
>>> +        image_format = params.get("image_format_stg", "qcow2")
>>> +        image_filename = "%s.%s" % (image_name, image_format)
>>> +        image_dir = os.path.join(test.bindir, "images")
>>> +        storage_name = os.path.join(image_dir, image_filename)
>>> +        pci_add_cmd = "pci_add pci_addr=auto storage file=%s,if=%s" % \
>>> +                                              (storage_name, tested_model)
>>>        
> The above line would be better with implicit line continuation
>
> pci_add_cmd = ("pci_add pci_addr=auto storage file=%s,if=%s" %
>                          (storage_name, tested_model))
>
>    
>>> +        s, add_output = vm.send_monitor_cmd(pci_add_cmd)
>>> +
>>> +    if not "OK domain" in add_output:
>>> +        raise error.TestFail("Command failed: %s" % pci_add_cmd)
>>>        
> Since we're executing a command on the hypervisor to add the device, a
> better way to put the above message would be
>
>      if not "OK domain" in add_output:
>          raise error.TestFail("Hypervisor command to add device '%s'failed."
>                               "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 in 'info pci'")
>>>        
> Another suggestion:
>
>          raise error.TestFail("No new PCI device shown after executing "
>                               "hypervisor command 'info pci'")
>
>
>    
>>> +    time.sleep(int(params.get("seconds_wait_for_device_install")))
>>> +
>>> +    o = session.get_command_output(ref_cmd)
>>> +    if reference == o:
>>> +        raise error.TestFail("No new device shown in cmd: %s" % ref_cmd)
>>>        
> I found useful to explain on which side of the check the test fail,
> 'hypervisor', or 'guest'
>
>          raise error.TestFail("No new device shown on guest command %s output" %
>                               ref_cmd)
>
>
>    
>>> +    cmd = params.get("find_pci_cmd")
>>> +    output = session.get_command_output(cmd)
>>> +    if not params.get("match_string") in output:
>>> +        raise error.TestFail("Not found pci model: %s; Command is: %s" %
>>> +                                                    (tested_model, cmd))
>>>        
>          raise error.TestFail("PCI device model '%s' not found on host "
>                               "command '%s' ouput" % (tested_model, cmd))
>
>    
>>> +    # del 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; Command:%s" %
>>> +                                                     (tested_model, cmd))
>>>        
>          raise error.TestFail("Failed to hot remove pci device '%s'. "
>                               "Hypervisor command: '%s'" % (tested_model, cmd))
>
> Hot remove doesn't work for me either... Since we are here, I still
> didn't understand why we do a hot remove of a device and right below
> it we try to verify if the newly added devices are working properly.
> Shouldn't be the other way around (ie checking and then hot removing)?
>    

It did actually not verify the newly added device but simply verify if 
pci_del bring in any problem to the guest (disk or network). Since 
sometimes I found pci_del a nic card can break the guest's network as 
tested in our internal kvm version.

>    
>>> +    # check whether VM's network&    disk work fine
>>> +    if session.get_command_status(params.get("pci_test_cmd")):
>>> +        raise error.TestFail("Check for %s device failed after PCI hotplug" %
>>> +                                                                 test_type)
>>> +
>>> +    session.close()
>>> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
>>> index 503f636..95b55eb 100644
>>> --- a/client/tests/kvm/kvm_vm.py
>>> +++ b/client/tests/kvm/kvm_vm.py
>>> @@ -239,6 +239,8 @@ class VM:
>>>
>>>            for image_name in kvm_utils.get_sub_dict_names(params, "images"):
>>>                image_params = kvm_utils.get_sub_dict(params, image_name)
>>> +            if image_params.get("boot_drive") == "no":
>>> +                continue
>>>                qemu_cmd += " -drive file=%s" % get_image_filename(image_params,
>>>                                                                   image_dir)
>>>                if image_params.get("drive_format"):
>>>        


-- 
Yolkfull
Regards,


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] Add a subtest pci_hotplug in kvm test
  2009-08-04  7:54         ` Yolkfull Chow
@ 2009-08-04  8:47           ` Yolkfull Chow
  0 siblings, 0 replies; 15+ messages in thread
From: Yolkfull Chow @ 2009-08-04  8:47 UTC (permalink / raw)
  To: kvm; +Cc: autotest, lmr


Sorry for just submitting a wrong patch file which including a bug, please ignore previous one
and review following patch:

Differences between previous patch:

- Use a loop waiting for some seconds to compare output of a command
- Use a loop waiting for some seconds to catch string indicates which
  PCI device
- Add option kill_vm_on_error in block_hotplug since once a model failed
  to be hot removed, it will affect next model

A better result I can get is:
-------
./scan_results.py
test                                                       status	seconds info
----                                                       ------	------- ----
Fedora.11.32.nic_hotplug.nic_8139                          GOOD	107     completed successfully
Fedora.11.32.nic_hotplug.nic_virtio                        FAIL	76	Not found pci model:virtio; Command is:lspci | tail -n1
Fedora.11.32.block_hotplug.fmt_qcow2.block_virtio          GOOD	92	completed successfully
Fedora.11.32.block_hotplug.fmt_qcow2.block_scsi            GOOD	48	completed successfully
RHEL.5.3.i386.nic_hotplug.nic_8139                         GOOD	144     completed successfully
RHEL.5.3.i386.nic_hotplug.nic_virtio                       GOOD	48	completed successfully
RHEL.5.3.i386.block_hotplug.fmt_qcow2.block_virtio         GOOD	47	completed successfully
RHEL.5.3.i386.block_hotplug.fmt_qcow2.block_scsi           GOOD	47	completed successfully
Win2008.32.nic_hotplug.nic_8139                            GOOD	141     completed successfully
Win2008.32.nic_hotplug.nic_virtio                          GOOD	99	completed successfully
Win2008.32.block_hotplug.fmt_qcow2.block_scsi              GOOD	90	completed successfully
----                                                       GOOD	953


Signed-off-by: Yolkfull Chow <yzhou@redhat.com>
---
 client/tests/kvm/kvm.py               |    1 +
 client/tests/kvm/kvm_tests.cfg.sample |   67 +++++++++++++++++++++
 client/tests/kvm/kvm_tests.py         |  105 +++++++++++++++++++++++++++++++++
 client/tests/kvm/kvm_vm.py            |    2 +
 4 files changed, 175 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
index 070e463..f985388 100644
--- a/client/tests/kvm/kvm.py
+++ b/client/tests/kvm/kvm.py
@@ -56,6 +56,7 @@ class kvm(test.test):
                 "linux_s3":     test_routine("kvm_tests", "run_linux_s3"),
                 "stress_boot":  test_routine("kvm_tests", "run_stress_boot"),
                 "timedrift":    test_routine("kvm_tests", "run_timedrift"),
+                "pci_hotplug":   test_routine("kvm_tests", "run_pci_hotplug"),
                 }
 
         # Make it possible to import modules from the test's bindir
diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample
index 7cd12cb..9af1bc8 100644
--- a/client/tests/kvm/kvm_tests.cfg.sample
+++ b/client/tests/kvm/kvm_tests.cfg.sample
@@ -118,6 +118,53 @@ variants:
         kill_vm = yes
         kill_vm_gracefully = no
 
+    - nic_hotplug:
+        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'
+        wait_secs_for_hook_up = 3
+        variants:
+            - nic_8139:
+                pci_model = rtl8139
+                match_string = "8139"
+            - nic_virtio:
+                pci_model = virtio
+                match_string = "Virtio network device"
+            - nic_e1000:
+                pci_model = e1000
+                match_string = "Gigabit Ethernet Controller"
+
+    - block_hotplug:
+        type = pci_hotplug
+        pci_type = block
+        reference_cmd = lspci
+        find_pci_cmd = 'lspci | tail -n1'
+        images += " stg"
+        boot_drive_stg = no
+        image_name_stg = storage
+        image_size_stg = 1G
+        remove_image_stg = yes
+        force_create_image_stg = yes
+        pci_test_cmd = "yes | mke2fs `fdisk -l 2>&1 | awk '/\/dev\/[sv]d[a-z] doesn/ {print $2}'`"
+        wait_secs_for_hook_up = 3
+        kill_vm_on_error = yes
+        variants:
+            - block_virtio:
+                pci_model = virtio
+                match_string = "Virtio block device"
+            - block_scsi:
+                pci_model = scsi
+                match_string = "SCSI"
+        variants:
+            - fmt_qcow2:
+                image_format_stg = qcow2
+            - fmt_raw:
+                image_format_stg = raw
+                only Fedora Ubuntu Windows
+
 
 # NICs
 variants:
@@ -259,6 +306,10 @@ variants:
             - RHEL:
                 no setup
                 ssh_prompt = "\[root@.{0,50}][\#\$] "
+                nic_hotplug:
+                    modprobe_module = acpiphp
+                block_hotplug:
+                    modprobe_module = acpiphp
 
                 variants:
                     - 5.3.i386:
@@ -345,6 +396,22 @@ variants:
             # Alternative host load:
             #host_load_command = "dd if=/dev/urandom of=/dev/null"
             host_load_instances = 8
+        nic_hotplug:
+            reference_cmd = ipconfig /all
+            find_pci_cmd = ipconfig /all | find "Description"
+            wait_secs_for_hook_up = 10
+            nic_e1000:
+                match_string = "Intel(R) PRO/1000 MT Network Connection"
+            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
 
         variants:
             - Win2000:
diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
index 9784ec9..b553003 100644
--- a/client/tests/kvm/kvm_tests.py
+++ b/client/tests/kvm/kvm_tests.py
@@ -743,3 +743,108 @@ def run_timedrift(test, params, env):
                              % drift_total)
 
     session.close()
+
+
+def run_pci_hotplug(test, params, env):
+    """
+    Test pci devices' hotplug
+    1) PCI add a deivce (NIC / block)
+    2) Compare output of hypervisor command `info pci`
+    3) Compare output of guest command `reference_cmd`
+    4) Verify whether pci_model is shown in `pci_find_cmd`
+    5) Check whether the newly added pci device works fine
+    6) PCI delete the device, verify whether could remove the pci device
+
+    @param test:   kvm test object
+    @param params: Dictionary with the test parameters
+    @param env:    Dictionary with test environment.
+    """
+    vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
+    if not vm:
+        raise error.TestError("VM object not found in environment")
+    if not vm.is_alive():
+        raise error.TestError("VM seems to be dead; Test requires a living VM")
+
+    logging.info("Waiting for guest to be up...")
+
+    session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
+    if not session:
+        raise error.TestFail("Could not log into guest")
+
+    logging.info("Logged in")
+
+    # Modprobe the module if specified in config file
+    if params.get("modprobe_module"):
+        module = params.get("modprobe_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
+    s, info_pci_ref = vm.send_monitor_cmd("info pci")
+
+    # Get output of command as reference
+    reference = session.get_command_output(params.get("reference_cmd"))
+
+    tested_model = params.get("pci_model")
+    test_type = params.get("pci_type")
+
+    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)
+        pci_add_cmd = ("pci_add pci_addr=auto storage file=%s,if=%s" %
+                                    (storage_name, 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 in 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("Not found pci model:%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:
+        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()
diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index eba9b84..4a7a85c 100644
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -225,6 +225,8 @@ class VM:
 
         for image_name in kvm_utils.get_sub_dict_names(params, "images"):
             image_params = kvm_utils.get_sub_dict(params, image_name)
+            if image_params.get("boot_drive") == "no":
+                continue
             qemu_cmd += " -drive file=%s" % get_image_filename(image_params,
                                                                image_dir)
             if image_params.get("drive_format"):
-- 
1.6.2.5


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] Add a subtest pci_hotplug in kvm test
  2009-08-04  3:30       ` Yolkfull Chow
@ 2009-08-04  7:54         ` Yolkfull Chow
  2009-08-04  8:47           ` Yolkfull Chow
  0 siblings, 1 reply; 15+ messages in thread
From: Yolkfull Chow @ 2009-08-04  7:54 UTC (permalink / raw)
  To: kvm; +Cc: autotest, lmr

Differences between previous patch:

- Use a loop waiting for some seconds to compare output of a command
- Use a loop waiting for some seconds to catch string indicates which
  PCI device
- Add option kill_vm_on_error in block_hotplug since once a model failed
  to be hot removed, it will affect next model

A better result I can get is:
-------
./scan_results.py
test                                            		status
seconds	info
----                                            		------
-------	----
Fedora.11.32.nic_hotplug.nic_8139               		GOOD
107	completed successfully
Fedora.11.32.nic_hotplug.nic_virtio             		FAIL
76	Not found pci model:virtio; Command is:lspci | tail -n1
Fedora.11.32.block_hotplug.fmt_qcow2.block_virtio		GOOD
92	completed successfully
Fedora.11.32.block_hotplug.fmt_qcow2.block_scsi 		GOOD
48	completed successfully
RHEL.5.3.i386.nic_hotplug.nic_8139              		GOOD
144	completed successfully
RHEL.5.3.i386.nic_hotplug.nic_virtio            		GOOD
48	completed successfully
RHEL.5.3.i386.block_hotplug.fmt_qcow2.block_virtio		GOOD
47	completed successfully
RHEL.5.3.i386.block_hotplug.fmt_qcow2.block_scsi		GOOD
47	completed successfully
Win2008.32.nic_hotplug.nic_8139                 		GOOD
141	completed successfully
Win2008.32.nic_hotplug.nic_virtio               		GOOD
99	completed successfully
Win2008.32.block_hotplug.fmt_qcow2.block_scsi   		GOOD
90	completed successfully
----                                            		GOOD
953	



Signed-off-by: Yolkfull Chow <yzhou@redhat.com>
---
 client/tests/kvm/kvm.py               |    1 +
 client/tests/kvm/kvm_tests.cfg.sample |   67 +++++++++++++++++++++
 client/tests/kvm/kvm_tests.py         |  105 +++++++++++++++++++++++++++++++++
 client/tests/kvm/kvm_vm.py            |    2 +
 4 files changed, 175 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
index 070e463..f985388 100644
--- a/client/tests/kvm/kvm.py
+++ b/client/tests/kvm/kvm.py
@@ -56,6 +56,7 @@ class kvm(test.test):
                 "linux_s3":     test_routine("kvm_tests", "run_linux_s3"),
                 "stress_boot":  test_routine("kvm_tests", "run_stress_boot"),
                 "timedrift":    test_routine("kvm_tests", "run_timedrift"),
+                "pci_hotplug":   test_routine("kvm_tests", "run_pci_hotplug"),
                 }
 
         # Make it possible to import modules from the test's bindir
diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample
index 7cd12cb..9af1bc8 100644
--- a/client/tests/kvm/kvm_tests.cfg.sample
+++ b/client/tests/kvm/kvm_tests.cfg.sample
@@ -118,6 +118,53 @@ variants:
         kill_vm = yes
         kill_vm_gracefully = no
 
+    - nic_hotplug:
+        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'
+        wait_secs_for_hook_up = 3
+        variants:
+            - nic_8139:
+                pci_model = rtl8139
+                match_string = "8139"
+            - nic_virtio:
+                pci_model = virtio
+                match_string = "Virtio network device"
+            - nic_e1000:
+                pci_model = e1000
+                match_string = "Gigabit Ethernet Controller"
+
+    - block_hotplug:
+        type = pci_hotplug
+        pci_type = block
+        reference_cmd = lspci
+        find_pci_cmd = 'lspci | tail -n1'
+        images += " stg"
+        boot_drive_stg = no
+        image_name_stg = storage
+        image_size_stg = 1G
+        remove_image_stg = yes
+        force_create_image_stg = yes
+        pci_test_cmd = "yes | mke2fs `fdisk -l 2>&1 | awk '/\/dev\/[sv]d[a-z] doesn/ {print $2}'`"
+        wait_secs_for_hook_up = 3
+        kill_vm_on_error = yes
+        variants:
+            - block_virtio:
+                pci_model = virtio
+                match_string = "Virtio block device"
+            - block_scsi:
+                pci_model = scsi
+                match_string = "SCSI"
+        variants:
+            - fmt_qcow2:
+                image_format_stg = qcow2
+            - fmt_raw:
+                image_format_stg = raw
+                only Fedora Ubuntu Windows
+
 
 # NICs
 variants:
@@ -259,6 +306,10 @@ variants:
             - RHEL:
                 no setup
                 ssh_prompt = "\[root@.{0,50}][\#\$] "
+                nic_hotplug:
+                    modprobe_module = acpiphp
+                block_hotplug:
+                    modprobe_module = acpiphp
 
                 variants:
                     - 5.3.i386:
@@ -345,6 +396,22 @@ variants:
             # Alternative host load:
             #host_load_command = "dd if=/dev/urandom of=/dev/null"
             host_load_instances = 8
+        nic_hotplug:
+            reference_cmd = ipconfig /all
+            find_pci_cmd = ipconfig /all | find "Description"
+            wait_secs_for_hook_up = 10
+            nic_e1000:
+                match_string = "Intel(R) PRO/1000 MT Network Connection"
+            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
 
         variants:
             - Win2000:
diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
index 9784ec9..5a1fc21 100644
--- a/client/tests/kvm/kvm_tests.py
+++ b/client/tests/kvm/kvm_tests.py
@@ -743,3 +743,108 @@ def run_timedrift(test, params, env):
                              % drift_total)
 
     session.close()
+
+
+def run_pci_hotplug(test, params, env):
+    """
+    Test pci devices' hotplug
+    1) PCI add a deivce (NIC / block)
+    2) Compare 'info pci' output
+    3) Compare 'reference_cmd' output
+    4) Verify whether pci_model is shown in 'pci_find_cmd'
+    5) Check whether the newly added pci device works fine
+    6) PCI delete the device, verify whether could remove the pci device
+
+    @param test:   kvm test object
+    @param params: Dictionary with the test parameters
+    @param env:    Dictionary with test environment.
+    """
+    vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
+    if not vm:
+        raise error.TestError("VM object not found in environment")
+    if not vm.is_alive():
+        raise error.TestError("VM seems to be dead; Test requires a living VM")
+
+    logging.info("Waiting for guest to be up...")
+
+    session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
+    if not session:
+        raise error.TestFail("Could not log into guest")
+
+    logging.info("Logged in")
+
+    # Modprobe the module if specified in config file
+    if params.get("modprobe_module"):
+        module = params.get("modprobe_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
+    s, info_pci_ref = vm.send_monitor_cmd("info pci")
+
+    # Get output of command as reference
+    reference = session.get_command_output(params.get("reference_cmd"))
+
+    tested_model = params.get("pci_model")
+    logging.info("Testing hotplug pci device:%s" % tested_model)
+    test_type = params.get("pci_type")
+    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)
+        pci_add_cmd = ("pci_add pci_addr=auto storage file=%s,if=%s" %
+                                    (storage_name, 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 in guest: %s" % ref_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("Not found pci model:%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:
+        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()
diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index eba9b84..4a7a85c 100644
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -225,6 +225,8 @@ class VM:
 
         for image_name in kvm_utils.get_sub_dict_names(params, "images"):
             image_params = kvm_utils.get_sub_dict(params, image_name)
+            if image_params.get("boot_drive") == "no":
+                continue
             qemu_cmd += " -drive file=%s" % get_image_filename(image_params,
                                                                image_dir)
             if image_params.get("drive_format"):
-- 
1.6.2.5


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] Add a subtest pci_hotplug in kvm test
  2009-08-03 11:37     ` Dor Laor
@ 2009-08-04  3:30       ` Yolkfull Chow
  2009-08-04  7:54         ` Yolkfull Chow
  0 siblings, 1 reply; 15+ messages in thread
From: Yolkfull Chow @ 2009-08-04  3:30 UTC (permalink / raw)
  To: Dor Laor; +Cc: glommer, autotest, kvm, lmr

On Mon, Aug 03, 2009 at 02:37:29PM +0300, Dor Laor wrote:
> On 08/03/2009 12:19 PM, Yolkfull Chow wrote:
>> On 06/30/2009 09:58 PM, Dor Laor wrote:
>>> On 06/30/2009 02:11 PM, Yolkfull Chow wrote:
>>>> Signed-off-by: Yolkfull Chow<yzhou@redhat.com>
>>>> ---
>>>> client/tests/kvm/kvm.py | 1 +
>>>> client/tests/kvm/kvm_tests.cfg.sample | 56 ++++++++++++++++++++
>>>> client/tests/kvm/kvm_tests.py | 93 +++++++++++++++++++++++++++++++++
>>>> client/tests/kvm/kvm_vm.py | 2 +
>>>> 4 files changed, 152 insertions(+), 0 deletions(-)
>>>>
>>>> diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
>>>> index 4c7bae4..4fbce5b 100644
>>>> --- a/client/tests/kvm/kvm.py
>>>> +++ b/client/tests/kvm/kvm.py
>>>> @@ -55,6 +55,7 @@ class kvm(test.test):
>>>> "kvm_install": test_routine("kvm_install", "run_kvm_install"),
>>>> "linux_s3": test_routine("kvm_tests", "run_linux_s3"),
>>>> "stress_boot": test_routine("kvm_tests", "run_stress_boot"),
>>>> + "pci_hotplug": test_routine("kvm_tests", "run_pci_hotplug"),
>>>
>>> Cool! It's very good since it tends to break.
>>>
>>>
>>>> }
>>>>
>>>> # Make it possible to import modules from the test's bindir
>>>> diff --git a/client/tests/kvm/kvm_tests.cfg.sample
>>>> b/client/tests/kvm/kvm_tests.cfg.sample
>>>> index 2f864de..50b5765 100644
>>>> --- a/client/tests/kvm/kvm_tests.cfg.sample
>>>> +++ b/client/tests/kvm/kvm_tests.cfg.sample
>>>> @@ -94,6 +94,52 @@ variants:
>>>> max_vms = 5
>>>> alive_test_cmd = ps aux
>>>>
>>>> +
>>>> + - nic_hotplug:
>>>> + type = pci_hotplug
>>>> + pci_type = nic
>>>> + modprobe_acpiphp = yes
>>>> + reference_cmd = lspci
>>>> + find_pci_cmd = 'lspci | tail -n1'
>>>> + pci_test_cmd = 'nslookup www.redhat.com'
>>>> + variants:
>>>> + - @nic_8139:
>>>> + pci_model = rtl8139
>>>> + match_string = "8139"
>>>> + - nic_virtio:
>>>> + pci_model = virtio
>>>> + match_string = "Virtio network device"
>>>> + - nic_e1000:
>>>> + pci_model = e1000
>>>> + match_string = "Gigabit Ethernet Controller"
>>>> +
>>>> + - block_hotplug:
>>>> + type = pci_hotplug
>>>> + pci_type = block
>>>> + modprobe_acpiphp = yes
>>>> + reference_cmd = lspci
>>>> + find_pci_cmd = 'lspci | tail -n1'
>>>> + images += " stg"
>>>> + boot_drive_stg = no
>>>> + image_name_stg = storage
>>>> + image_size = 1G
>>>> + force_create_image_stg = yes
>>>> + pci_test_cmd = 'dir'
>>>> + no Windows
>>>> + variants:
>>>> + - block_virtio:
>>>> + pci_model = virtio
>>>> + match_string = "Virtio block device"
>>>> + - block_scsi:
>>>> + pci_model = scsi
>>>> + match_string = "SCSI storage controller"
>>>> + variants:
>>>
>>> There is no need to test qcow2/raw here since it shouldn't matter.
>>> You can test qcow2 only, it is enough.
>>
>> Hi Glauber, according to Dor's comments on this, I did some testing and
>> got an interesting result for block_hotplug:
>> 1) hotplug storage of raw + SCSI will always fail on Windows
>> 2) hotplug storage of Raw + Virtio will always fail on Fedora
>> 3) hotplug storage with image format Raw will also fail often on RHEL
>>
>> Does block_hotplug relate to image format? Would you give me any clue on
>> this?
>
> It shouldn't matter. In case the test is sensitive for timeout, it might.
>
> Can you describe what's working and what's not on each combination?
> As for scsi, it is not reliable so it might be scsi's fault.
>
> Can you provide the fdisk -l ouput on Fedora when it is not working?
> From the test below, there is not time/event for letting the guest hook  
> up the new block device.
> Maybe you need to do several retries in a loop or check a real event in  
> the guest (better one)

I can make sure now there is a bug in block hotplug feature since segfault has been found in
dmesg on my laptop Fedora. Also, both guest RHEL.5.3-i386 and Windows 2008 have
crashed during running block_hotplug test. 
For example, for Windows 2008-32 guest, sometimes issue command 'systeminfo' during block_hotplug
can crash the guest.

I had added a loop wait for the PCI device hooked up, before this, I
used sleep(some_seconds) wait for module installed. 

>
>> Thanks in advance.
>>
>>>
>>>> + - fmt_qcow2:
>>>> + image_format_stg = qcow2
>>>> + - fmt_raw:
>>>> + image_format_stg = raw
>>>> +
>>>> +
>>>> # NICs
>>>> variants:
>>>> - @rtl8139:
>>>> @@ -306,6 +352,12 @@ variants:
>>>> migration_test_command = ver&& vol
>>>> stress_boot:
>>>> alive_test_cmd = systeminfo
>>>> + nic_hotplug:
>>>> + modprobe_acpiphp = no
>>>> + reference_cmd = systeminfo
>>>> + find_pci_cmd = ipconfig /all | find "Description"
>>>> + nic_e1000:
>>>> + match_string = "Intel(R) PRO/1000 MT Network Connection"
>>>>
>>>> variants:
>>>> - Win2000:
>>>> @@ -530,6 +582,10 @@ virtio|virtio_blk|e1000:
>>>> only Fedora.9 openSUSE-11 Ubuntu-8.10-server
>>>>
>>>>
>>>> +nic_hotplug.nic_virtio|block_hotplug:
>>>> + no Windows
>>>> +
>>>> +
>>>> variants:
>>>> - @qcow2:
>>>> image_format = qcow2
>>>> diff --git a/client/tests/kvm/kvm_tests.py
>>>> b/client/tests/kvm/kvm_tests.py
>>>> index 2d11fed..21280b9 100644
>>>> --- a/client/tests/kvm/kvm_tests.py
>>>> +++ b/client/tests/kvm/kvm_tests.py
>>>> @@ -585,3 +585,96 @@ def run_stress_boot(tests, params, env):
>>>> for se in sessions:
>>>> se.close()
>>>> logging.info("Total number booted: %d" % (num -1))
>>>> +
>>>> +
>>>> +def run_pci_hotplug(test, params, env):
>>>> + """
>>>> + Test pci devices' hotplug
>>>> + 1) pci_add a deivce (nic or storage)
>>>> + 2) Compare 'info pci' output
>>>> + 3) Compare $reference_cmd output
>>>> + 4) Verify whether pci_model is shown in $pci_find_cmd
>>>> + 5) pci_del the device, verify whether could remove the pci device
>>>> +
>>>> + @param test: kvm test object
>>>> + @param params: Dictionary with the test parameters
>>>> + @param env: Dictionary with test environment.
>>>> + """
>>>> + vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
>>>> + if not vm:
>>>> + raise error.TestError("VM object not found in environment")
>>>> + if not vm.is_alive():
>>>> + raise error.TestError("VM seems to be dead; Test requires a living
>>>> VM")
>>>> +
>>>> + logging.info("Waiting for guest to be up...")
>>>> +
>>>> + session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
>>>> + if not session:
>>>> + raise error.TestFail("Could not log into guest")
>>>> +
>>>> + logging.info("Logged in")
>>>> +
>>>> + # modprobe the module that enable hotplug
>>>> + if params.get("modprobe_acpiphp") == "yes":
>>>> + if session.get_command_status("modprobe acpiphp"):
>>>> + raise error.TestError("Modprobe module 'acpiphp' failed")
>>>> +
>>>> + # get reference output
>>>> + s, info_pci_ref = vm.send_monitor_cmd("info pci")
>>>> +
>>>> + # compare the output of `reference_cmd`
>>>> + ref_cmd = params.get("reference_cmd")
>>>> + reference = session.get_command_output(ref_cmd)
>>>> +
>>>> + # implement pci hotplug
>>>> + tested_model = params.get("pci_model")
>>>> + logging.info("Testing hotplug pci device:%s" % tested_model)
>>>> +
>>>> + test_type = params.get("pci_type")
>>>> + if test_type == "nic":
>>>> + pci_add_cmd = "pci_add pci_addr=auto nic model=%s" % tested_model
>>>> + s, add_output = vm.send_monitor_cmd(pci_add_cmd)
>>>
>>> You're basing the assumption that the VM was raised with -net tap or
>>> -net user with the right vlan.
>>> Actually it would be nice to hot add the host back end too (available
>>> on newer kvm's). It's not a must.
>>>
>>>
>>>> +
>>>> + elif test_type == "block":
>>>> + image_name = params.get("image_name_stg")
>>>> + image_format = params.get("image_format_stg", "qcow2")
>>>> + image_filename = "%s.%s" % (image_name, image_format)
>>>> + image_dir = os.path.join(test.bindir, "images")
>>>> + storage_name = os.path.join(image_dir, image_filename)
>>>> + pci_add_cmd = "pci_add pci_addr=auto storage file=%s,if=%s" % \
>>>> + (storage_name, tested_model)
>>>> + s, add_output = vm.send_monitor_cmd(pci_add_cmd)
>>>> +
>>>> + if not "OK domain" in add_output:
>>>> + raise error.TestFail("Command failed: %s" % pci_add_cmd)
>>>> +
>>>> + # 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 in 'info pci'")
>>>> +
>>>> + time.sleep(5)
>>>> +
>>>> + o = session.get_command_output(ref_cmd)
>>>> + if reference == o:
>>>> + raise error.TestFail("No new device shown in cmd: %s" % ref_cmd)
>>>> +
>>>> + cmd = params.get("find_pci_cmd")
>>>> + output = session.get_command_output(cmd)
>>>> + if not params.get("match_string") in output:
>>>> + raise error.TestFail("Not found pci model: %s; Command is: %s" % ( \
>>>> + tested_model, cmd))
>>>> +
>>>> + # del 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; \
>>>> + Command: %s" % (tested_model, cmd))
>>>> +
>>>> + # check whether VM's network& disk work fine
>>>> + if session.get_command_status(params.get("pci_test_cmd")):
>>>> + raise error.TestFail("VM's %s damaged after pci_hotplug" % test_type)
>>>
>>> Doesn't it need to fail after the hot delete?
>>>
>>>> +
>>>> + session.close()
>>>> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
>>>> index 503f636..95b55eb 100644
>>>> --- a/client/tests/kvm/kvm_vm.py
>>>> +++ b/client/tests/kvm/kvm_vm.py
>>>> @@ -239,6 +239,8 @@ class VM:
>>>>
>>>> for image_name in kvm_utils.get_sub_dict_names(params, "images"):
>>>> image_params = kvm_utils.get_sub_dict(params, image_name)
>>>> + if image_params.get("boot_drive") == "no":
>>>> + continue
>>>> qemu_cmd += " -drive file=%s" % get_image_filename(image_params,
>>>> image_dir)
>>>> if image_params.get("drive_format"):
>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe kvm" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] Add a subtest pci_hotplug in kvm test
  2009-08-03  9:19   ` Yolkfull Chow
  2009-08-03 11:37     ` Dor Laor
@ 2009-08-03 13:21     ` Glauber Costa
  1 sibling, 0 replies; 15+ messages in thread
From: Glauber Costa @ 2009-08-03 13:21 UTC (permalink / raw)
  To: Yolkfull Chow; +Cc: dlaor, autotest, kvm, lmr

On Mon, Aug 03, 2009 at 05:19:17PM +0800, Yolkfull Chow wrote:
> On 06/30/2009 09:58 PM, Dor Laor wrote:
>> On 06/30/2009 02:11 PM, Yolkfull Chow wrote:
>>> Signed-off-by: Yolkfull Chow<yzhou@redhat.com>
>>> ---
>>>   client/tests/kvm/kvm.py               |    1 +
>>>   client/tests/kvm/kvm_tests.cfg.sample |   56 ++++++++++++++++++++
>>>   client/tests/kvm/kvm_tests.py         |   93  
>>> +++++++++++++++++++++++++++++++++
>>>   client/tests/kvm/kvm_vm.py            |    2 +
>>>   4 files changed, 152 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
>>> index 4c7bae4..4fbce5b 100644
>>> --- a/client/tests/kvm/kvm.py
>>> +++ b/client/tests/kvm/kvm.py
>>> @@ -55,6 +55,7 @@ class kvm(test.test):
>>>                   "kvm_install":  test_routine("kvm_install",  
>>> "run_kvm_install"),
>>>                   "linux_s3":     test_routine("kvm_tests",  
>>> "run_linux_s3"),
>>>                   "stress_boot":  test_routine("kvm_tests",  
>>> "run_stress_boot"),
>>> +                "pci_hotplug":  test_routine("kvm_tests",  
>>> "run_pci_hotplug"),
>>
>> Cool! It's very good since it tends to break.
>>
>>
>>>                   }
>>>
>>>           # Make it possible to import modules from the test's bindir
>>> diff --git a/client/tests/kvm/kvm_tests.cfg.sample  
>>> b/client/tests/kvm/kvm_tests.cfg.sample
>>> index 2f864de..50b5765 100644
>>> --- a/client/tests/kvm/kvm_tests.cfg.sample
>>> +++ b/client/tests/kvm/kvm_tests.cfg.sample
>>> @@ -94,6 +94,52 @@ variants:
>>>           max_vms = 5
>>>           alive_test_cmd = ps aux
>>>
>>> +
>>> +    - nic_hotplug:
>>> +        type = pci_hotplug
>>> +        pci_type = nic
>>> +        modprobe_acpiphp = yes
>>> +        reference_cmd = lspci
>>> +        find_pci_cmd = 'lspci | tail -n1'
>>> +        pci_test_cmd = 'nslookup www.redhat.com'
>>> +        variants:
>>> +            - @nic_8139:
>>> +                pci_model = rtl8139
>>> +                match_string = "8139"
>>> +            - nic_virtio:
>>> +                pci_model = virtio
>>> +                match_string = "Virtio network device"
>>> +            - nic_e1000:
>>> +                pci_model = e1000
>>> +                match_string = "Gigabit Ethernet Controller"
>>> +
>>> +    - block_hotplug:
>>> +        type = pci_hotplug
>>> +        pci_type = block
>>> +        modprobe_acpiphp = yes
>>> +        reference_cmd = lspci
>>> +        find_pci_cmd = 'lspci | tail -n1'
>>> +        images += " stg"
>>> +        boot_drive_stg = no
>>> +        image_name_stg = storage
>>> +        image_size = 1G
>>> +        force_create_image_stg = yes
>>> +        pci_test_cmd = 'dir'
>>> +        no Windows
>>> +        variants:
>>> +            - block_virtio:
>>> +                pci_model = virtio
>>> +                match_string = "Virtio block device"
>>> +            - block_scsi:
>>> +                pci_model = scsi
>>> +                match_string = "SCSI storage controller"
>>> +        variants:
>>
>> There is no need to test qcow2/raw here since it shouldn't matter.
>> You can test qcow2 only, it is enough.
>
> Hi Glauber,  according to Dor's comments on this, I did some testing and  
> got an interesting result for block_hotplug:
> 1) hotplug storage of raw + SCSI  will always fail on Windows
> 2) hotplug storage of Raw + Virtio will always fail on Fedora
> 3) hotplug storage with image format Raw will also fail often on RHEL
>
> Does block_hotplug relate to image format?  Would you give me any clue  
> on this?

Hi,

hotplugging a pci device should have nothing to do with the underlying format.
However, if we are using a format that is more racy and subject to breaks, the
hotplug window may make easy for race conditions to happen. For example, qcow2
with writeback caching.

As for the failures you describe, I'd like to see details. They surely sound like
a bug.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] Add a subtest pci_hotplug in kvm test
  2009-08-03  9:19   ` Yolkfull Chow
@ 2009-08-03 11:37     ` Dor Laor
  2009-08-04  3:30       ` Yolkfull Chow
  2009-08-03 13:21     ` Glauber Costa
  1 sibling, 1 reply; 15+ messages in thread
From: Dor Laor @ 2009-08-03 11:37 UTC (permalink / raw)
  To: Yolkfull Chow; +Cc: glommer, autotest, kvm, lmr

On 08/03/2009 12:19 PM, Yolkfull Chow wrote:
> On 06/30/2009 09:58 PM, Dor Laor wrote:
>> On 06/30/2009 02:11 PM, Yolkfull Chow wrote:
>>> Signed-off-by: Yolkfull Chow<yzhou@redhat.com>
>>> ---
>>> client/tests/kvm/kvm.py | 1 +
>>> client/tests/kvm/kvm_tests.cfg.sample | 56 ++++++++++++++++++++
>>> client/tests/kvm/kvm_tests.py | 93 +++++++++++++++++++++++++++++++++
>>> client/tests/kvm/kvm_vm.py | 2 +
>>> 4 files changed, 152 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
>>> index 4c7bae4..4fbce5b 100644
>>> --- a/client/tests/kvm/kvm.py
>>> +++ b/client/tests/kvm/kvm.py
>>> @@ -55,6 +55,7 @@ class kvm(test.test):
>>> "kvm_install": test_routine("kvm_install", "run_kvm_install"),
>>> "linux_s3": test_routine("kvm_tests", "run_linux_s3"),
>>> "stress_boot": test_routine("kvm_tests", "run_stress_boot"),
>>> + "pci_hotplug": test_routine("kvm_tests", "run_pci_hotplug"),
>>
>> Cool! It's very good since it tends to break.
>>
>>
>>> }
>>>
>>> # Make it possible to import modules from the test's bindir
>>> diff --git a/client/tests/kvm/kvm_tests.cfg.sample
>>> b/client/tests/kvm/kvm_tests.cfg.sample
>>> index 2f864de..50b5765 100644
>>> --- a/client/tests/kvm/kvm_tests.cfg.sample
>>> +++ b/client/tests/kvm/kvm_tests.cfg.sample
>>> @@ -94,6 +94,52 @@ variants:
>>> max_vms = 5
>>> alive_test_cmd = ps aux
>>>
>>> +
>>> + - nic_hotplug:
>>> + type = pci_hotplug
>>> + pci_type = nic
>>> + modprobe_acpiphp = yes
>>> + reference_cmd = lspci
>>> + find_pci_cmd = 'lspci | tail -n1'
>>> + pci_test_cmd = 'nslookup www.redhat.com'
>>> + variants:
>>> + - @nic_8139:
>>> + pci_model = rtl8139
>>> + match_string = "8139"
>>> + - nic_virtio:
>>> + pci_model = virtio
>>> + match_string = "Virtio network device"
>>> + - nic_e1000:
>>> + pci_model = e1000
>>> + match_string = "Gigabit Ethernet Controller"
>>> +
>>> + - block_hotplug:
>>> + type = pci_hotplug
>>> + pci_type = block
>>> + modprobe_acpiphp = yes
>>> + reference_cmd = lspci
>>> + find_pci_cmd = 'lspci | tail -n1'
>>> + images += " stg"
>>> + boot_drive_stg = no
>>> + image_name_stg = storage
>>> + image_size = 1G
>>> + force_create_image_stg = yes
>>> + pci_test_cmd = 'dir'
>>> + no Windows
>>> + variants:
>>> + - block_virtio:
>>> + pci_model = virtio
>>> + match_string = "Virtio block device"
>>> + - block_scsi:
>>> + pci_model = scsi
>>> + match_string = "SCSI storage controller"
>>> + variants:
>>
>> There is no need to test qcow2/raw here since it shouldn't matter.
>> You can test qcow2 only, it is enough.
>
> Hi Glauber, according to Dor's comments on this, I did some testing and
> got an interesting result for block_hotplug:
> 1) hotplug storage of raw + SCSI will always fail on Windows
> 2) hotplug storage of Raw + Virtio will always fail on Fedora
> 3) hotplug storage with image format Raw will also fail often on RHEL
>
> Does block_hotplug relate to image format? Would you give me any clue on
> this?

It shouldn't matter. In case the test is sensitive for timeout, it might.

Can you describe what's working and what's not on each combination?
As for scsi, it is not reliable so it might be scsi's fault.

Can you provide the fdisk -l ouput on Fedora when it is not working?
 From the test below, there is not time/event for letting the guest hook 
up the new block device.
Maybe you need to do several retries in a loop or check a real event in 
the guest (better one)

> Thanks in advance.
>
>>
>>> + - fmt_qcow2:
>>> + image_format_stg = qcow2
>>> + - fmt_raw:
>>> + image_format_stg = raw
>>> +
>>> +
>>> # NICs
>>> variants:
>>> - @rtl8139:
>>> @@ -306,6 +352,12 @@ variants:
>>> migration_test_command = ver&& vol
>>> stress_boot:
>>> alive_test_cmd = systeminfo
>>> + nic_hotplug:
>>> + modprobe_acpiphp = no
>>> + reference_cmd = systeminfo
>>> + find_pci_cmd = ipconfig /all | find "Description"
>>> + nic_e1000:
>>> + match_string = "Intel(R) PRO/1000 MT Network Connection"
>>>
>>> variants:
>>> - Win2000:
>>> @@ -530,6 +582,10 @@ virtio|virtio_blk|e1000:
>>> only Fedora.9 openSUSE-11 Ubuntu-8.10-server
>>>
>>>
>>> +nic_hotplug.nic_virtio|block_hotplug:
>>> + no Windows
>>> +
>>> +
>>> variants:
>>> - @qcow2:
>>> image_format = qcow2
>>> diff --git a/client/tests/kvm/kvm_tests.py
>>> b/client/tests/kvm/kvm_tests.py
>>> index 2d11fed..21280b9 100644
>>> --- a/client/tests/kvm/kvm_tests.py
>>> +++ b/client/tests/kvm/kvm_tests.py
>>> @@ -585,3 +585,96 @@ def run_stress_boot(tests, params, env):
>>> for se in sessions:
>>> se.close()
>>> logging.info("Total number booted: %d" % (num -1))
>>> +
>>> +
>>> +def run_pci_hotplug(test, params, env):
>>> + """
>>> + Test pci devices' hotplug
>>> + 1) pci_add a deivce (nic or storage)
>>> + 2) Compare 'info pci' output
>>> + 3) Compare $reference_cmd output
>>> + 4) Verify whether pci_model is shown in $pci_find_cmd
>>> + 5) pci_del the device, verify whether could remove the pci device
>>> +
>>> + @param test: kvm test object
>>> + @param params: Dictionary with the test parameters
>>> + @param env: Dictionary with test environment.
>>> + """
>>> + vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
>>> + if not vm:
>>> + raise error.TestError("VM object not found in environment")
>>> + if not vm.is_alive():
>>> + raise error.TestError("VM seems to be dead; Test requires a living
>>> VM")
>>> +
>>> + logging.info("Waiting for guest to be up...")
>>> +
>>> + session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
>>> + if not session:
>>> + raise error.TestFail("Could not log into guest")
>>> +
>>> + logging.info("Logged in")
>>> +
>>> + # modprobe the module that enable hotplug
>>> + if params.get("modprobe_acpiphp") == "yes":
>>> + if session.get_command_status("modprobe acpiphp"):
>>> + raise error.TestError("Modprobe module 'acpiphp' failed")
>>> +
>>> + # get reference output
>>> + s, info_pci_ref = vm.send_monitor_cmd("info pci")
>>> +
>>> + # compare the output of `reference_cmd`
>>> + ref_cmd = params.get("reference_cmd")
>>> + reference = session.get_command_output(ref_cmd)
>>> +
>>> + # implement pci hotplug
>>> + tested_model = params.get("pci_model")
>>> + logging.info("Testing hotplug pci device:%s" % tested_model)
>>> +
>>> + test_type = params.get("pci_type")
>>> + if test_type == "nic":
>>> + pci_add_cmd = "pci_add pci_addr=auto nic model=%s" % tested_model
>>> + s, add_output = vm.send_monitor_cmd(pci_add_cmd)
>>
>> You're basing the assumption that the VM was raised with -net tap or
>> -net user with the right vlan.
>> Actually it would be nice to hot add the host back end too (available
>> on newer kvm's). It's not a must.
>>
>>
>>> +
>>> + elif test_type == "block":
>>> + image_name = params.get("image_name_stg")
>>> + image_format = params.get("image_format_stg", "qcow2")
>>> + image_filename = "%s.%s" % (image_name, image_format)
>>> + image_dir = os.path.join(test.bindir, "images")
>>> + storage_name = os.path.join(image_dir, image_filename)
>>> + pci_add_cmd = "pci_add pci_addr=auto storage file=%s,if=%s" % \
>>> + (storage_name, tested_model)
>>> + s, add_output = vm.send_monitor_cmd(pci_add_cmd)
>>> +
>>> + if not "OK domain" in add_output:
>>> + raise error.TestFail("Command failed: %s" % pci_add_cmd)
>>> +
>>> + # 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 in 'info pci'")
>>> +
>>> + time.sleep(5)
>>> +
>>> + o = session.get_command_output(ref_cmd)
>>> + if reference == o:
>>> + raise error.TestFail("No new device shown in cmd: %s" % ref_cmd)
>>> +
>>> + cmd = params.get("find_pci_cmd")
>>> + output = session.get_command_output(cmd)
>>> + if not params.get("match_string") in output:
>>> + raise error.TestFail("Not found pci model: %s; Command is: %s" % ( \
>>> + tested_model, cmd))
>>> +
>>> + # del 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; \
>>> + Command: %s" % (tested_model, cmd))
>>> +
>>> + # check whether VM's network& disk work fine
>>> + if session.get_command_status(params.get("pci_test_cmd")):
>>> + raise error.TestFail("VM's %s damaged after pci_hotplug" % test_type)
>>
>> Doesn't it need to fail after the hot delete?
>>
>>> +
>>> + session.close()
>>> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
>>> index 503f636..95b55eb 100644
>>> --- a/client/tests/kvm/kvm_vm.py
>>> +++ b/client/tests/kvm/kvm_vm.py
>>> @@ -239,6 +239,8 @@ class VM:
>>>
>>> for image_name in kvm_utils.get_sub_dict_names(params, "images"):
>>> image_params = kvm_utils.get_sub_dict(params, image_name)
>>> + if image_params.get("boot_drive") == "no":
>>> + continue
>>> qemu_cmd += " -drive file=%s" % get_image_filename(image_params,
>>> image_dir)
>>> if image_params.get("drive_format"):
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe kvm" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] Add a subtest pci_hotplug in kvm test
  2009-06-30 13:58 ` Dor Laor
  2009-07-01  2:09   ` Yolkfull Chow
@ 2009-08-03  9:19   ` Yolkfull Chow
  2009-08-03 11:37     ` Dor Laor
  2009-08-03 13:21     ` Glauber Costa
  1 sibling, 2 replies; 15+ messages in thread
From: Yolkfull Chow @ 2009-08-03  9:19 UTC (permalink / raw)
  To: glommer; +Cc: dlaor, autotest, kvm, lmr

On 06/30/2009 09:58 PM, Dor Laor wrote:
> On 06/30/2009 02:11 PM, Yolkfull Chow wrote:
>> Signed-off-by: Yolkfull Chow<yzhou@redhat.com>
>> ---
>>   client/tests/kvm/kvm.py               |    1 +
>>   client/tests/kvm/kvm_tests.cfg.sample |   56 ++++++++++++++++++++
>>   client/tests/kvm/kvm_tests.py         |   93 
>> +++++++++++++++++++++++++++++++++
>>   client/tests/kvm/kvm_vm.py            |    2 +
>>   4 files changed, 152 insertions(+), 0 deletions(-)
>>
>> diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
>> index 4c7bae4..4fbce5b 100644
>> --- a/client/tests/kvm/kvm.py
>> +++ b/client/tests/kvm/kvm.py
>> @@ -55,6 +55,7 @@ class kvm(test.test):
>>                   "kvm_install":  test_routine("kvm_install", 
>> "run_kvm_install"),
>>                   "linux_s3":     test_routine("kvm_tests", 
>> "run_linux_s3"),
>>                   "stress_boot":  test_routine("kvm_tests", 
>> "run_stress_boot"),
>> +                "pci_hotplug":  test_routine("kvm_tests", 
>> "run_pci_hotplug"),
>
> Cool! It's very good since it tends to break.
>
>
>>                   }
>>
>>           # Make it possible to import modules from the test's bindir
>> diff --git a/client/tests/kvm/kvm_tests.cfg.sample 
>> b/client/tests/kvm/kvm_tests.cfg.sample
>> index 2f864de..50b5765 100644
>> --- a/client/tests/kvm/kvm_tests.cfg.sample
>> +++ b/client/tests/kvm/kvm_tests.cfg.sample
>> @@ -94,6 +94,52 @@ variants:
>>           max_vms = 5
>>           alive_test_cmd = ps aux
>>
>> +
>> +    - nic_hotplug:
>> +        type = pci_hotplug
>> +        pci_type = nic
>> +        modprobe_acpiphp = yes
>> +        reference_cmd = lspci
>> +        find_pci_cmd = 'lspci | tail -n1'
>> +        pci_test_cmd = 'nslookup www.redhat.com'
>> +        variants:
>> +            - @nic_8139:
>> +                pci_model = rtl8139
>> +                match_string = "8139"
>> +            - nic_virtio:
>> +                pci_model = virtio
>> +                match_string = "Virtio network device"
>> +            - nic_e1000:
>> +                pci_model = e1000
>> +                match_string = "Gigabit Ethernet Controller"
>> +
>> +    - block_hotplug:
>> +        type = pci_hotplug
>> +        pci_type = block
>> +        modprobe_acpiphp = yes
>> +        reference_cmd = lspci
>> +        find_pci_cmd = 'lspci | tail -n1'
>> +        images += " stg"
>> +        boot_drive_stg = no
>> +        image_name_stg = storage
>> +        image_size = 1G
>> +        force_create_image_stg = yes
>> +        pci_test_cmd = 'dir'
>> +        no Windows
>> +        variants:
>> +            - block_virtio:
>> +                pci_model = virtio
>> +                match_string = "Virtio block device"
>> +            - block_scsi:
>> +                pci_model = scsi
>> +                match_string = "SCSI storage controller"
>> +        variants:
>
> There is no need to test qcow2/raw here since it shouldn't matter.
> You can test qcow2 only, it is enough.

Hi Glauber,  according to Dor's comments on this, I did some testing and 
got an interesting result for block_hotplug:
1) hotplug storage of raw + SCSI  will always fail on Windows
2) hotplug storage of Raw + Virtio will always fail on Fedora
3) hotplug storage with image format Raw will also fail often on RHEL

Does block_hotplug relate to image format?  Would you give me any clue 
on this?
Thanks in advance.

>
>> +            - fmt_qcow2:
>> +                image_format_stg = qcow2
>> +            - fmt_raw:
>> +                image_format_stg = raw
>> +
>> +
>>   # NICs
>>   variants:
>>       - @rtl8139:
>> @@ -306,6 +352,12 @@ variants:
>>               migration_test_command = ver&&  vol
>>           stress_boot:
>>               alive_test_cmd = systeminfo
>> +        nic_hotplug:
>> +            modprobe_acpiphp = no
>> +            reference_cmd = systeminfo
>> +            find_pci_cmd = ipconfig /all | find "Description"
>> +            nic_e1000:
>> +                match_string = "Intel(R) PRO/1000 MT Network 
>> Connection"
>>
>>           variants:
>>               - Win2000:
>> @@ -530,6 +582,10 @@ virtio|virtio_blk|e1000:
>>       only Fedora.9 openSUSE-11 Ubuntu-8.10-server
>>
>>
>> +nic_hotplug.nic_virtio|block_hotplug:
>> +    no Windows
>> +
>> +
>>   variants:
>>       - @qcow2:
>>           image_format = qcow2
>> diff --git a/client/tests/kvm/kvm_tests.py 
>> b/client/tests/kvm/kvm_tests.py
>> index 2d11fed..21280b9 100644
>> --- a/client/tests/kvm/kvm_tests.py
>> +++ b/client/tests/kvm/kvm_tests.py
>> @@ -585,3 +585,96 @@ def run_stress_boot(tests, params, env):
>>           for se in sessions:
>>               se.close()
>>           logging.info("Total number booted: %d" % (num -1))
>> +
>> +
>> +def run_pci_hotplug(test, params, env):
>> +    """
>> +    Test pci devices' hotplug
>> +    1) pci_add a deivce (nic or storage)
>> +    2) Compare 'info pci' output
>> +    3) Compare $reference_cmd output
>> +    4) Verify whether pci_model is shown in $pci_find_cmd
>> +    5) pci_del the device, verify whether could remove the pci device
>> +
>> +    @param test:   kvm test object
>> +    @param params: Dictionary with the test parameters
>> +    @param env:    Dictionary with test environment.
>> +    """
>> +    vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
>> +    if not vm:
>> +        raise error.TestError("VM object not found in environment")
>> +    if not vm.is_alive():
>> +        raise error.TestError("VM seems to be dead; Test requires a 
>> living VM")
>> +
>> +    logging.info("Waiting for guest to be up...")
>> +
>> +    session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
>> +    if not session:
>> +        raise error.TestFail("Could not log into guest")
>> +
>> +    logging.info("Logged in")
>> +
>> +    # modprobe the module that enable hotplug
>> +    if params.get("modprobe_acpiphp") == "yes":
>> +        if session.get_command_status("modprobe acpiphp"):
>> +            raise error.TestError("Modprobe module 'acpiphp' failed")
>> +
>> +    # get reference output
>> +    s, info_pci_ref = vm.send_monitor_cmd("info pci")
>> +
>> +    # compare the output of `reference_cmd`
>> +    ref_cmd = params.get("reference_cmd")
>> +    reference = session.get_command_output(ref_cmd)
>> +
>> +    # implement pci hotplug
>> +    tested_model = params.get("pci_model")
>> +    logging.info("Testing hotplug pci device:%s" % tested_model)
>> +
>> +    test_type = params.get("pci_type")
>> +    if test_type == "nic":
>> +        pci_add_cmd = "pci_add pci_addr=auto nic model=%s" % 
>> tested_model
>> +        s, add_output = vm.send_monitor_cmd(pci_add_cmd)
>
> You're basing the assumption that the VM was raised with -net tap or 
> -net user with the right vlan.
> Actually it would be nice to hot add the host back end too (available 
> on newer kvm's). It's not a must.
>
>
>> +
>> +    elif test_type == "block":
>> +        image_name = params.get("image_name_stg")
>> +        image_format = params.get("image_format_stg", "qcow2")
>> +        image_filename = "%s.%s" % (image_name, image_format)
>> +        image_dir = os.path.join(test.bindir, "images")
>> +        storage_name = os.path.join(image_dir, image_filename)
>> +        pci_add_cmd = "pci_add pci_addr=auto storage file=%s,if=%s" % \
>> +                                              (storage_name, 
>> tested_model)
>> +        s, add_output = vm.send_monitor_cmd(pci_add_cmd)
>> +
>> +    if not "OK domain" in add_output:
>> +        raise error.TestFail("Command failed: %s" % pci_add_cmd)
>> +
>> +    # 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 in 'info pci'")
>> +
>> +    time.sleep(5)
>> +
>> +    o = session.get_command_output(ref_cmd)
>> +    if reference == o:
>> +        raise error.TestFail("No new device shown in cmd: %s" % 
>> ref_cmd)
>> +
>> +    cmd = params.get("find_pci_cmd")
>> +    output = session.get_command_output(cmd)
>> +    if not params.get("match_string") in output:
>> +        raise error.TestFail("Not found pci model: %s; Command is: 
>> %s" % ( \
>> +                                                           
>> tested_model, cmd))
>> +
>> +    # del 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; \
>> +                          Command: %s" % (tested_model, cmd))
>> +
>> +    # check whether VM's network&  disk work fine
>> +    if session.get_command_status(params.get("pci_test_cmd")):
>> +        raise error.TestFail("VM's %s damaged after pci_hotplug" % 
>> test_type)
>
> Doesn't it need to fail after the hot delete?
>
>> +
>> +    session.close()
>> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
>> index 503f636..95b55eb 100644
>> --- a/client/tests/kvm/kvm_vm.py
>> +++ b/client/tests/kvm/kvm_vm.py
>> @@ -239,6 +239,8 @@ class VM:
>>
>>           for image_name in kvm_utils.get_sub_dict_names(params, 
>> "images"):
>>               image_params = kvm_utils.get_sub_dict(params, image_name)
>> +            if image_params.get("boot_drive") == "no":
>> +                continue
>>               qemu_cmd += " -drive file=%s" % 
>> get_image_filename(image_params,
>>                                                                  
>> image_dir)
>>               if image_params.get("drive_format"):
>
> -- 
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


-- 
Yolkfull
Regards,


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] Add a subtest pci_hotplug in kvm test
  2009-06-30 13:58 ` Dor Laor
@ 2009-07-01  2:09   ` Yolkfull Chow
  2009-08-03  9:19   ` Yolkfull Chow
  1 sibling, 0 replies; 15+ messages in thread
From: Yolkfull Chow @ 2009-07-01  2:09 UTC (permalink / raw)
  To: dlaor; +Cc: autotest, kvm, lmr

On 06/30/2009 09:58 PM, Dor Laor wrote:
> On 06/30/2009 02:11 PM, Yolkfull Chow wrote:
>> Signed-off-by: Yolkfull Chow<yzhou@redhat.com>
>> ---
>>   client/tests/kvm/kvm.py               |    1 +
>>   client/tests/kvm/kvm_tests.cfg.sample |   56 ++++++++++++++++++++
>>   client/tests/kvm/kvm_tests.py         |   93 
>> +++++++++++++++++++++++++++++++++
>>   client/tests/kvm/kvm_vm.py            |    2 +
>>   4 files changed, 152 insertions(+), 0 deletions(-)
>>
>> diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
>> index 4c7bae4..4fbce5b 100644
>> --- a/client/tests/kvm/kvm.py
>> +++ b/client/tests/kvm/kvm.py
>> @@ -55,6 +55,7 @@ class kvm(test.test):
>>                   "kvm_install":  test_routine("kvm_install", 
>> "run_kvm_install"),
>>                   "linux_s3":     test_routine("kvm_tests", 
>> "run_linux_s3"),
>>                   "stress_boot":  test_routine("kvm_tests", 
>> "run_stress_boot"),
>> +                "pci_hotplug":  test_routine("kvm_tests", 
>> "run_pci_hotplug"),
>
> Cool! It's very good since it tends to break.
>
>
>>                   }
>>
>>           # Make it possible to import modules from the test's bindir
>> diff --git a/client/tests/kvm/kvm_tests.cfg.sample 
>> b/client/tests/kvm/kvm_tests.cfg.sample
>> index 2f864de..50b5765 100644
>> --- a/client/tests/kvm/kvm_tests.cfg.sample
>> +++ b/client/tests/kvm/kvm_tests.cfg.sample
>> @@ -94,6 +94,52 @@ variants:
>>           max_vms = 5
>>           alive_test_cmd = ps aux
>>
>> +
>> +    - nic_hotplug:
>> +        type = pci_hotplug
>> +        pci_type = nic
>> +        modprobe_acpiphp = yes
>> +        reference_cmd = lspci
>> +        find_pci_cmd = 'lspci | tail -n1'
>> +        pci_test_cmd = 'nslookup www.redhat.com'
>> +        variants:
>> +            - @nic_8139:
>> +                pci_model = rtl8139
>> +                match_string = "8139"
>> +            - nic_virtio:
>> +                pci_model = virtio
>> +                match_string = "Virtio network device"
>> +            - nic_e1000:
>> +                pci_model = e1000
>> +                match_string = "Gigabit Ethernet Controller"
>> +
>> +    - block_hotplug:
>> +        type = pci_hotplug
>> +        pci_type = block
>> +        modprobe_acpiphp = yes
>> +        reference_cmd = lspci
>> +        find_pci_cmd = 'lspci | tail -n1'
>> +        images += " stg"
>> +        boot_drive_stg = no
>> +        image_name_stg = storage
>> +        image_size = 1G
>> +        force_create_image_stg = yes
>> +        pci_test_cmd = 'dir'
>> +        no Windows
>> +        variants:
>> +            - block_virtio:
>> +                pci_model = virtio
>> +                match_string = "Virtio block device"
>> +            - block_scsi:
>> +                pci_model = scsi
>> +                match_string = "SCSI storage controller"
>> +        variants:
>
> There is no need to test qcow2/raw here since it shouldn't matter.
> You can test qcow2 only, it is enough.
>
>> +            - fmt_qcow2:
>> +                image_format_stg = qcow2
>> +            - fmt_raw:
>> +                image_format_stg = raw
>> +
>> +
>>   # NICs
>>   variants:
>>       - @rtl8139:
>> @@ -306,6 +352,12 @@ variants:
>>               migration_test_command = ver&&  vol
>>           stress_boot:
>>               alive_test_cmd = systeminfo
>> +        nic_hotplug:
>> +            modprobe_acpiphp = no
>> +            reference_cmd = systeminfo
>> +            find_pci_cmd = ipconfig /all | find "Description"
>> +            nic_e1000:
>> +                match_string = "Intel(R) PRO/1000 MT Network 
>> Connection"
>>
>>           variants:
>>               - Win2000:
>> @@ -530,6 +582,10 @@ virtio|virtio_blk|e1000:
>>       only Fedora.9 openSUSE-11 Ubuntu-8.10-server
>>
>>
>> +nic_hotplug.nic_virtio|block_hotplug:
>> +    no Windows
>> +
>> +
>>   variants:
>>       - @qcow2:
>>           image_format = qcow2
>> diff --git a/client/tests/kvm/kvm_tests.py 
>> b/client/tests/kvm/kvm_tests.py
>> index 2d11fed..21280b9 100644
>> --- a/client/tests/kvm/kvm_tests.py
>> +++ b/client/tests/kvm/kvm_tests.py
>> @@ -585,3 +585,96 @@ def run_stress_boot(tests, params, env):
>>           for se in sessions:
>>               se.close()
>>           logging.info("Total number booted: %d" % (num -1))
>> +
>> +
>> +def run_pci_hotplug(test, params, env):
>> +    """
>> +    Test pci devices' hotplug
>> +    1) pci_add a deivce (nic or storage)
>> +    2) Compare 'info pci' output
>> +    3) Compare $reference_cmd output
>> +    4) Verify whether pci_model is shown in $pci_find_cmd
>> +    5) pci_del the device, verify whether could remove the pci device
>> +
>> +    @param test:   kvm test object
>> +    @param params: Dictionary with the test parameters
>> +    @param env:    Dictionary with test environment.
>> +    """
>> +    vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
>> +    if not vm:
>> +        raise error.TestError("VM object not found in environment")
>> +    if not vm.is_alive():
>> +        raise error.TestError("VM seems to be dead; Test requires a 
>> living VM")
>> +
>> +    logging.info("Waiting for guest to be up...")
>> +
>> +    session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
>> +    if not session:
>> +        raise error.TestFail("Could not log into guest")
>> +
>> +    logging.info("Logged in")
>> +
>> +    # modprobe the module that enable hotplug
>> +    if params.get("modprobe_acpiphp") == "yes":
>> +        if session.get_command_status("modprobe acpiphp"):
>> +            raise error.TestError("Modprobe module 'acpiphp' failed")
>> +
>> +    # get reference output
>> +    s, info_pci_ref = vm.send_monitor_cmd("info pci")
>> +
>> +    # compare the output of `reference_cmd`
>> +    ref_cmd = params.get("reference_cmd")
>> +    reference = session.get_command_output(ref_cmd)
>> +
>> +    # implement pci hotplug
>> +    tested_model = params.get("pci_model")
>> +    logging.info("Testing hotplug pci device:%s" % tested_model)
>> +
>> +    test_type = params.get("pci_type")
>> +    if test_type == "nic":
>> +        pci_add_cmd = "pci_add pci_addr=auto nic model=%s" % 
>> tested_model
>> +        s, add_output = vm.send_monitor_cmd(pci_add_cmd)
>
> You're basing the assumption that the VM was raised with -net tap or 
> -net user with the right vlan.
> Actually it would be nice to hot add the host back end too (available 
> on newer kvm's). It's not a must.
>
>
>> +
>> +    elif test_type == "block":
>> +        image_name = params.get("image_name_stg")
>> +        image_format = params.get("image_format_stg", "qcow2")
>> +        image_filename = "%s.%s" % (image_name, image_format)
>> +        image_dir = os.path.join(test.bindir, "images")
>> +        storage_name = os.path.join(image_dir, image_filename)
>> +        pci_add_cmd = "pci_add pci_addr=auto storage file=%s,if=%s" % \
>> +                                              (storage_name, 
>> tested_model)
>> +        s, add_output = vm.send_monitor_cmd(pci_add_cmd)
>> +
>> +    if not "OK domain" in add_output:
>> +        raise error.TestFail("Command failed: %s" % pci_add_cmd)
>> +
>> +    # 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 in 'info pci'")
>> +
>> +    time.sleep(5)
>> +
>> +    o = session.get_command_output(ref_cmd)
>> +    if reference == o:
>> +        raise error.TestFail("No new device shown in cmd: %s" % 
>> ref_cmd)
>> +
>> +    cmd = params.get("find_pci_cmd")
>> +    output = session.get_command_output(cmd)
>> +    if not params.get("match_string") in output:
>> +        raise error.TestFail("Not found pci model: %s; Command is: 
>> %s" % ( \
>> +                                                           
>> tested_model, cmd))
>> +
>> +    # del 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; \
>> +                          Command: %s" % (tested_model, cmd))
>> +
>> +    # check whether VM's network&  disk work fine
>> +    if session.get_command_status(params.get("pci_test_cmd")):
>> +        raise error.TestFail("VM's %s damaged after pci_hotplug" % 
>> test_type)
>
> Doesn't it need to fail after the hot delete?
Yes I think. Sometimes the pci_del will succeed whereas it may break the 
existing network(already found such a defect).
>
>> +
>> +    session.close()
>> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
>> index 503f636..95b55eb 100644
>> --- a/client/tests/kvm/kvm_vm.py
>> +++ b/client/tests/kvm/kvm_vm.py
>> @@ -239,6 +239,8 @@ class VM:
>>
>>           for image_name in kvm_utils.get_sub_dict_names(params, 
>> "images"):
>>               image_params = kvm_utils.get_sub_dict(params, image_name)
>> +            if image_params.get("boot_drive") == "no":
>> +                continue
>>               qemu_cmd += " -drive file=%s" % 
>> get_image_filename(image_params,
>>                                                                  
>> image_dir)
>>               if image_params.get("drive_format"):
>


-- 
Yolkfull
Regards,


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] Add a subtest pci_hotplug in kvm test
  2009-06-30 11:11 Yolkfull Chow
  2009-06-30 13:58 ` Dor Laor
@ 2009-06-30 22:40 ` Lucas Meneghel Rodrigues
  1 sibling, 0 replies; 15+ messages in thread
From: Lucas Meneghel Rodrigues @ 2009-06-30 22:40 UTC (permalink / raw)
  To: Yolkfull Chow; +Cc: autotest, kvm

On Tue, 2009-06-30 at 19:11 +0800, Yolkfull Chow wrote:
> Signed-off-by: Yolkfull Chow <yzhou@redhat.com>
> ---
>  client/tests/kvm/kvm.py               |    1 +
>  client/tests/kvm/kvm_tests.cfg.sample |   56 ++++++++++++++++++++
>  client/tests/kvm/kvm_tests.py         |   93 +++++++++++++++++++++++++++++++++
>  client/tests/kvm/kvm_vm.py            |    2 +
>  4 files changed, 152 insertions(+), 0 deletions(-)

Thank you for your contribution Yolkfull, pci hotplug is an important
feature that we should test and stress.

> diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
> index 4c7bae4..4fbce5b 100644
> --- a/client/tests/kvm/kvm.py
> +++ b/client/tests/kvm/kvm.py
> @@ -55,6 +55,7 @@ class kvm(test.test):
>                  "kvm_install":  test_routine("kvm_install", "run_kvm_install"),
>                  "linux_s3":     test_routine("kvm_tests", "run_linux_s3"),
>                  "stress_boot":  test_routine("kvm_tests", "run_stress_boot"),
> +                "pci_hotplug":  test_routine("kvm_tests", "run_pci_hotplug"),
>                  }
>  
>          # Make it possible to import modules from the test's bindir
> diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample
> index 2f864de..50b5765 100644
> --- a/client/tests/kvm/kvm_tests.cfg.sample
> +++ b/client/tests/kvm/kvm_tests.cfg.sample
> @@ -94,6 +94,52 @@ variants:
>          max_vms = 5    
>          alive_test_cmd = ps aux
>  
> +
> +    - nic_hotplug:
> +        type = pci_hotplug
> +        pci_type = nic
> +        modprobe_acpiphp = yes
> +        reference_cmd = lspci
> +        find_pci_cmd = 'lspci | tail -n1'
> +        pci_test_cmd = 'nslookup www.redhat.com'
> +        variants:
> +            - @nic_8139:
> +                pci_model = rtl8139
> +                match_string = "8139"
> +            - nic_virtio:
> +                pci_model = virtio
> +                match_string = "Virtio network device"
> +            - nic_e1000:
> +                pci_model = e1000
> +                match_string = "Gigabit Ethernet Controller"
> +
> +    - block_hotplug:
> +        type = pci_hotplug
> +        pci_type = block
> +        modprobe_acpiphp = yes
> +        reference_cmd = lspci
> +        find_pci_cmd = 'lspci | tail -n1'
> +        images += " stg"
> +        boot_drive_stg = no
> +        image_name_stg = storage
> +        image_size = 1G
> +        force_create_image_stg = yes
> +        pci_test_cmd = 'dir'

Nice catch here, as dir would work on both command.com and *sh.

> +        no Windows
> +        variants:
> +            - block_virtio:
> +                pci_model = virtio
> +                match_string = "Virtio block device"
> +            - block_scsi:
> +                pci_model = scsi
> +                match_string = "SCSI storage controller"
> +        variants:
> +            - fmt_qcow2:
> +                image_format_stg = qcow2
> +            - fmt_raw:
> +                image_format_stg = raw
> +
> +
>  # NICs
>  variants:
>      - @rtl8139:
> @@ -306,6 +352,12 @@ variants:
>              migration_test_command = ver && vol
>          stress_boot:
>              alive_test_cmd = systeminfo
> +        nic_hotplug:
> +            modprobe_acpiphp = no
> +            reference_cmd = systeminfo
> +            find_pci_cmd = ipconfig /all | find "Description"
> +            nic_e1000:
> +                match_string = "Intel(R) PRO/1000 MT Network Connection"
>  
>          variants:
>              - Win2000:
> @@ -530,6 +582,10 @@ virtio|virtio_blk|e1000:
>      only Fedora.9 openSUSE-11 Ubuntu-8.10-server
>  
> 
> +nic_hotplug.nic_virtio|block_hotplug:
> +    no Windows
> +
> +
>  variants:
>      - @qcow2:
>          image_format = qcow2
> diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
> index 2d11fed..21280b9 100644
> --- a/client/tests/kvm/kvm_tests.py
> +++ b/client/tests/kvm/kvm_tests.py
> @@ -585,3 +585,96 @@ def run_stress_boot(tests, params, env):
>          for se in sessions:
>              se.close()
>          logging.info("Total number booted: %d" % (num -1))
> +
> +
> +def run_pci_hotplug(test, params, env):
> +    """
> +    Test pci devices' hotplug
> +    1) pci_add a deivce (nic or storage)
> +    2) Compare 'info pci' output
> +    3) Compare $reference_cmd output
> +    4) Verify whether pci_model is shown in $pci_find_cmd
> +    5) pci_del the device, verify whether could remove the pci device
> +
> +    @param test:   kvm test object
> +    @param params: Dictionary with the test parameters
> +    @param env:    Dictionary with test environment.
> +    """
> +    vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
> +    if not vm:
> +        raise error.TestError("VM object not found in environment")
> +    if not vm.is_alive():
> +        raise error.TestError("VM seems to be dead; Test requires a living VM")

The snippet above can be turned on a utility function, I am going to
cook up a patch doing it. When finished, I will replace it myself, no
need to worry about it.

> +    logging.info("Waiting for guest to be up...")
> +
> +    session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
> +    if not session:
> +        raise error.TestFail("Could not log into guest")
> +
> +    logging.info("Logged in")
> +
> +    # modprobe the module that enable hotplug
> +    if params.get("modprobe_acpiphp") == "yes":
> +        if session.get_command_status("modprobe acpiphp"):
> +            raise error.TestError("Modprobe module 'acpiphp' failed")
> +
> +    # get reference output
> +    s, info_pci_ref = vm.send_monitor_cmd("info pci")
> +
> +    # compare the output of `reference_cmd`
> +    ref_cmd = params.get("reference_cmd")
> +    reference = session.get_command_output(ref_cmd)
> +
> +    # implement pci hotplug
> +    tested_model = params.get("pci_model")
> +    logging.info("Testing hotplug pci device:%s" % tested_model)
> +
> +    test_type = params.get("pci_type")
> +    if test_type == "nic":
> +        pci_add_cmd = "pci_add pci_addr=auto nic model=%s" % tested_model
> +        s, add_output = vm.send_monitor_cmd(pci_add_cmd)
> +
> +    elif test_type == "block":
> +        image_name = params.get("image_name_stg")
> +        image_format = params.get("image_format_stg", "qcow2")
> +        image_filename = "%s.%s" % (image_name, image_format)
> +        image_dir = os.path.join(test.bindir, "images")
> +        storage_name = os.path.join(image_dir, image_filename)
> +        pci_add_cmd = "pci_add pci_addr=auto storage file=%s,if=%s" % \
> +                                              (storage_name, tested_model)
> +        s, add_output = vm.send_monitor_cmd(pci_add_cmd)
> +
> +    if not "OK domain" in add_output:
> +        raise error.TestFail("Command failed: %s" % pci_add_cmd)
> +
> +    # 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 in 'info pci'")
> +
> +    time.sleep(5)
> +   
> +    o = session.get_command_output(ref_cmd)
> +    if reference == o:
> +        raise error.TestFail("No new device shown in cmd: %s" % ref_cmd)
> +
> +    cmd = params.get("find_pci_cmd")
> +    output = session.get_command_output(cmd)
> +    if not params.get("match_string") in output:
> +        raise error.TestFail("Not found pci model: %s; Command is: %s" % ( \
> +                                                           tested_model, cmd))

Above we could use a better schema to do line break, I'd rather see the
following:

        raise error.TestFail("Not found pci model: %s; Command is: %s" %
                             (tested_model, cmd))

Implicit line continuation (using expressions in parenthesis) looks a lot better.

> +    # del 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; \
> +                          Command: %s" % (tested_model, cmd))

Ditto for line continuation.

We have just removed a device, why would we expect it to function after
the removal?

> +    # check whether VM's network & disk work fine
> +    if session.get_command_status(params.get("pci_test_cmd")):
> +        raise error.TestFail("VM's %s damaged after pci_hotplug" % test_type)


The above exception might be slightly misleading, as the VM is not
damaged, just something went wrong during the whole PCI addition
process. My suggestion is something along the lines:

"Check for %s device failed after PCI hotplug" % test_type

> +    session.close()
> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
> index 503f636..95b55eb 100644
> --- a/client/tests/kvm/kvm_vm.py
> +++ b/client/tests/kvm/kvm_vm.py
> @@ -239,6 +239,8 @@ class VM:
>  
>          for image_name in kvm_utils.get_sub_dict_names(params, "images"):
>              image_params = kvm_utils.get_sub_dict(params, image_name)
> +            if image_params.get("boot_drive") == "no":
> +                continue
>              qemu_cmd += " -drive file=%s" % get_image_filename(image_params,
>                                                                 image_dir)
>              if image_params.get("drive_format"):


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] Add a subtest pci_hotplug in kvm test
  2009-06-30 11:11 Yolkfull Chow
@ 2009-06-30 13:58 ` Dor Laor
  2009-07-01  2:09   ` Yolkfull Chow
  2009-08-03  9:19   ` Yolkfull Chow
  2009-06-30 22:40 ` Lucas Meneghel Rodrigues
  1 sibling, 2 replies; 15+ messages in thread
From: Dor Laor @ 2009-06-30 13:58 UTC (permalink / raw)
  To: Yolkfull Chow; +Cc: autotest, kvm, lmr

On 06/30/2009 02:11 PM, Yolkfull Chow wrote:
> Signed-off-by: Yolkfull Chow<yzhou@redhat.com>
> ---
>   client/tests/kvm/kvm.py               |    1 +
>   client/tests/kvm/kvm_tests.cfg.sample |   56 ++++++++++++++++++++
>   client/tests/kvm/kvm_tests.py         |   93 +++++++++++++++++++++++++++++++++
>   client/tests/kvm/kvm_vm.py            |    2 +
>   4 files changed, 152 insertions(+), 0 deletions(-)
>
> diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
> index 4c7bae4..4fbce5b 100644
> --- a/client/tests/kvm/kvm.py
> +++ b/client/tests/kvm/kvm.py
> @@ -55,6 +55,7 @@ class kvm(test.test):
>                   "kvm_install":  test_routine("kvm_install", "run_kvm_install"),
>                   "linux_s3":     test_routine("kvm_tests", "run_linux_s3"),
>                   "stress_boot":  test_routine("kvm_tests", "run_stress_boot"),
> +                "pci_hotplug":  test_routine("kvm_tests", "run_pci_hotplug"),

Cool! It's very good since it tends to break.


>                   }
>
>           # Make it possible to import modules from the test's bindir
> diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample
> index 2f864de..50b5765 100644
> --- a/client/tests/kvm/kvm_tests.cfg.sample
> +++ b/client/tests/kvm/kvm_tests.cfg.sample
> @@ -94,6 +94,52 @@ variants:
>           max_vms = 5
>           alive_test_cmd = ps aux
>
> +
> +    - nic_hotplug:
> +        type = pci_hotplug
> +        pci_type = nic
> +        modprobe_acpiphp = yes
> +        reference_cmd = lspci
> +        find_pci_cmd = 'lspci | tail -n1'
> +        pci_test_cmd = 'nslookup www.redhat.com'
> +        variants:
> +            - @nic_8139:
> +                pci_model = rtl8139
> +                match_string = "8139"
> +            - nic_virtio:
> +                pci_model = virtio
> +                match_string = "Virtio network device"
> +            - nic_e1000:
> +                pci_model = e1000
> +                match_string = "Gigabit Ethernet Controller"
> +
> +    - block_hotplug:
> +        type = pci_hotplug
> +        pci_type = block
> +        modprobe_acpiphp = yes
> +        reference_cmd = lspci
> +        find_pci_cmd = 'lspci | tail -n1'
> +        images += " stg"
> +        boot_drive_stg = no
> +        image_name_stg = storage
> +        image_size = 1G
> +        force_create_image_stg = yes
> +        pci_test_cmd = 'dir'
> +        no Windows
> +        variants:
> +            - block_virtio:
> +                pci_model = virtio
> +                match_string = "Virtio block device"
> +            - block_scsi:
> +                pci_model = scsi
> +                match_string = "SCSI storage controller"
> +        variants:

There is no need to test qcow2/raw here since it shouldn't matter.
You can test qcow2 only, it is enough.

> +            - fmt_qcow2:
> +                image_format_stg = qcow2
> +            - fmt_raw:
> +                image_format_stg = raw
> +
> +
>   # NICs
>   variants:
>       - @rtl8139:
> @@ -306,6 +352,12 @@ variants:
>               migration_test_command = ver&&  vol
>           stress_boot:
>               alive_test_cmd = systeminfo
> +        nic_hotplug:
> +            modprobe_acpiphp = no
> +            reference_cmd = systeminfo
> +            find_pci_cmd = ipconfig /all | find "Description"
> +            nic_e1000:
> +                match_string = "Intel(R) PRO/1000 MT Network Connection"
>
>           variants:
>               - Win2000:
> @@ -530,6 +582,10 @@ virtio|virtio_blk|e1000:
>       only Fedora.9 openSUSE-11 Ubuntu-8.10-server
>
>
> +nic_hotplug.nic_virtio|block_hotplug:
> +    no Windows
> +
> +
>   variants:
>       - @qcow2:
>           image_format = qcow2
> diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
> index 2d11fed..21280b9 100644
> --- a/client/tests/kvm/kvm_tests.py
> +++ b/client/tests/kvm/kvm_tests.py
> @@ -585,3 +585,96 @@ def run_stress_boot(tests, params, env):
>           for se in sessions:
>               se.close()
>           logging.info("Total number booted: %d" % (num -1))
> +
> +
> +def run_pci_hotplug(test, params, env):
> +    """
> +    Test pci devices' hotplug
> +    1) pci_add a deivce (nic or storage)
> +    2) Compare 'info pci' output
> +    3) Compare $reference_cmd output
> +    4) Verify whether pci_model is shown in $pci_find_cmd
> +    5) pci_del the device, verify whether could remove the pci device
> +
> +    @param test:   kvm test object
> +    @param params: Dictionary with the test parameters
> +    @param env:    Dictionary with test environment.
> +    """
> +    vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
> +    if not vm:
> +        raise error.TestError("VM object not found in environment")
> +    if not vm.is_alive():
> +        raise error.TestError("VM seems to be dead; Test requires a living VM")
> +
> +    logging.info("Waiting for guest to be up...")
> +
> +    session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
> +    if not session:
> +        raise error.TestFail("Could not log into guest")
> +
> +    logging.info("Logged in")
> +
> +    # modprobe the module that enable hotplug
> +    if params.get("modprobe_acpiphp") == "yes":
> +        if session.get_command_status("modprobe acpiphp"):
> +            raise error.TestError("Modprobe module 'acpiphp' failed")
> +
> +    # get reference output
> +    s, info_pci_ref = vm.send_monitor_cmd("info pci")
> +
> +    # compare the output of `reference_cmd`
> +    ref_cmd = params.get("reference_cmd")
> +    reference = session.get_command_output(ref_cmd)
> +
> +    # implement pci hotplug
> +    tested_model = params.get("pci_model")
> +    logging.info("Testing hotplug pci device:%s" % tested_model)
> +
> +    test_type = params.get("pci_type")
> +    if test_type == "nic":
> +        pci_add_cmd = "pci_add pci_addr=auto nic model=%s" % tested_model
> +        s, add_output = vm.send_monitor_cmd(pci_add_cmd)

You're basing the assumption that the VM was raised with -net tap or 
-net user with the right vlan.
Actually it would be nice to hot add the host back end too (available on 
newer kvm's). It's not a must.


> +
> +    elif test_type == "block":
> +        image_name = params.get("image_name_stg")
> +        image_format = params.get("image_format_stg", "qcow2")
> +        image_filename = "%s.%s" % (image_name, image_format)
> +        image_dir = os.path.join(test.bindir, "images")
> +        storage_name = os.path.join(image_dir, image_filename)
> +        pci_add_cmd = "pci_add pci_addr=auto storage file=%s,if=%s" % \
> +                                              (storage_name, tested_model)
> +        s, add_output = vm.send_monitor_cmd(pci_add_cmd)
> +
> +    if not "OK domain" in add_output:
> +        raise error.TestFail("Command failed: %s" % pci_add_cmd)
> +
> +    # 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 in 'info pci'")
> +
> +    time.sleep(5)
> +
> +    o = session.get_command_output(ref_cmd)
> +    if reference == o:
> +        raise error.TestFail("No new device shown in cmd: %s" % ref_cmd)
> +
> +    cmd = params.get("find_pci_cmd")
> +    output = session.get_command_output(cmd)
> +    if not params.get("match_string") in output:
> +        raise error.TestFail("Not found pci model: %s; Command is: %s" % ( \
> +                                                           tested_model, cmd))
> +
> +    # del 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; \
> +                          Command: %s" % (tested_model, cmd))
> +
> +    # check whether VM's network&  disk work fine
> +    if session.get_command_status(params.get("pci_test_cmd")):
> +        raise error.TestFail("VM's %s damaged after pci_hotplug" % test_type)

Doesn't it need to fail after the hot delete?

> +
> +    session.close()
> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
> index 503f636..95b55eb 100644
> --- a/client/tests/kvm/kvm_vm.py
> +++ b/client/tests/kvm/kvm_vm.py
> @@ -239,6 +239,8 @@ class VM:
>
>           for image_name in kvm_utils.get_sub_dict_names(params, "images"):
>               image_params = kvm_utils.get_sub_dict(params, image_name)
> +            if image_params.get("boot_drive") == "no":
> +                continue
>               qemu_cmd += " -drive file=%s" % get_image_filename(image_params,
>                                                                  image_dir)
>               if image_params.get("drive_format"):


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH] Add a subtest pci_hotplug in kvm test
@ 2009-06-30 11:11 Yolkfull Chow
  2009-06-30 13:58 ` Dor Laor
  2009-06-30 22:40 ` Lucas Meneghel Rodrigues
  0 siblings, 2 replies; 15+ messages in thread
From: Yolkfull Chow @ 2009-06-30 11:11 UTC (permalink / raw)
  To: autotest; +Cc: kvm, lmr, Yolkfull Chow


Signed-off-by: Yolkfull Chow <yzhou@redhat.com>
---
 client/tests/kvm/kvm.py               |    1 +
 client/tests/kvm/kvm_tests.cfg.sample |   56 ++++++++++++++++++++
 client/tests/kvm/kvm_tests.py         |   93 +++++++++++++++++++++++++++++++++
 client/tests/kvm/kvm_vm.py            |    2 +
 4 files changed, 152 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
index 4c7bae4..4fbce5b 100644
--- a/client/tests/kvm/kvm.py
+++ b/client/tests/kvm/kvm.py
@@ -55,6 +55,7 @@ class kvm(test.test):
                 "kvm_install":  test_routine("kvm_install", "run_kvm_install"),
                 "linux_s3":     test_routine("kvm_tests", "run_linux_s3"),
                 "stress_boot":  test_routine("kvm_tests", "run_stress_boot"),
+                "pci_hotplug":  test_routine("kvm_tests", "run_pci_hotplug"),
                 }
 
         # Make it possible to import modules from the test's bindir
diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample
index 2f864de..50b5765 100644
--- a/client/tests/kvm/kvm_tests.cfg.sample
+++ b/client/tests/kvm/kvm_tests.cfg.sample
@@ -94,6 +94,52 @@ variants:
         max_vms = 5    
         alive_test_cmd = ps aux
 
+
+    - nic_hotplug:
+        type = pci_hotplug
+        pci_type = nic
+        modprobe_acpiphp = yes
+        reference_cmd = lspci
+        find_pci_cmd = 'lspci | tail -n1'
+        pci_test_cmd = 'nslookup www.redhat.com'
+        variants:
+            - @nic_8139:
+                pci_model = rtl8139
+                match_string = "8139"
+            - nic_virtio:
+                pci_model = virtio
+                match_string = "Virtio network device"
+            - nic_e1000:
+                pci_model = e1000
+                match_string = "Gigabit Ethernet Controller"
+
+    - block_hotplug:
+        type = pci_hotplug
+        pci_type = block
+        modprobe_acpiphp = yes
+        reference_cmd = lspci
+        find_pci_cmd = 'lspci | tail -n1'
+        images += " stg"
+        boot_drive_stg = no
+        image_name_stg = storage
+        image_size = 1G
+        force_create_image_stg = yes
+        pci_test_cmd = 'dir'
+        no Windows
+        variants:
+            - block_virtio:
+                pci_model = virtio
+                match_string = "Virtio block device"
+            - block_scsi:
+                pci_model = scsi
+                match_string = "SCSI storage controller"
+        variants:
+            - fmt_qcow2:
+                image_format_stg = qcow2
+            - fmt_raw:
+                image_format_stg = raw
+
+
 # NICs
 variants:
     - @rtl8139:
@@ -306,6 +352,12 @@ variants:
             migration_test_command = ver && vol
         stress_boot:
             alive_test_cmd = systeminfo
+        nic_hotplug:
+            modprobe_acpiphp = no
+            reference_cmd = systeminfo
+            find_pci_cmd = ipconfig /all | find "Description"
+            nic_e1000:
+                match_string = "Intel(R) PRO/1000 MT Network Connection"
 
         variants:
             - Win2000:
@@ -530,6 +582,10 @@ virtio|virtio_blk|e1000:
     only Fedora.9 openSUSE-11 Ubuntu-8.10-server
 
 
+nic_hotplug.nic_virtio|block_hotplug:
+    no Windows
+
+
 variants:
     - @qcow2:
         image_format = qcow2
diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
index 2d11fed..21280b9 100644
--- a/client/tests/kvm/kvm_tests.py
+++ b/client/tests/kvm/kvm_tests.py
@@ -585,3 +585,96 @@ def run_stress_boot(tests, params, env):
         for se in sessions:
             se.close()
         logging.info("Total number booted: %d" % (num -1))
+
+
+def run_pci_hotplug(test, params, env):
+    """
+    Test pci devices' hotplug
+    1) pci_add a deivce (nic or storage)
+    2) Compare 'info pci' output
+    3) Compare $reference_cmd output
+    4) Verify whether pci_model is shown in $pci_find_cmd
+    5) pci_del the device, verify whether could remove the pci device
+
+    @param test:   kvm test object
+    @param params: Dictionary with the test parameters
+    @param env:    Dictionary with test environment.
+    """
+    vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
+    if not vm:
+        raise error.TestError("VM object not found in environment")
+    if not vm.is_alive():
+        raise error.TestError("VM seems to be dead; Test requires a living VM")
+
+    logging.info("Waiting for guest to be up...")
+
+    session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
+    if not session:
+        raise error.TestFail("Could not log into guest")
+
+    logging.info("Logged in")
+
+    # modprobe the module that enable hotplug
+    if params.get("modprobe_acpiphp") == "yes":
+        if session.get_command_status("modprobe acpiphp"):
+            raise error.TestError("Modprobe module 'acpiphp' failed")
+
+    # get reference output
+    s, info_pci_ref = vm.send_monitor_cmd("info pci")
+
+    # compare the output of `reference_cmd`
+    ref_cmd = params.get("reference_cmd")
+    reference = session.get_command_output(ref_cmd)
+
+    # implement pci hotplug
+    tested_model = params.get("pci_model")
+    logging.info("Testing hotplug pci device:%s" % tested_model)
+
+    test_type = params.get("pci_type")
+    if test_type == "nic":
+        pci_add_cmd = "pci_add pci_addr=auto nic model=%s" % tested_model
+        s, add_output = vm.send_monitor_cmd(pci_add_cmd)
+
+    elif test_type == "block":
+        image_name = params.get("image_name_stg")
+        image_format = params.get("image_format_stg", "qcow2")
+        image_filename = "%s.%s" % (image_name, image_format)
+        image_dir = os.path.join(test.bindir, "images")
+        storage_name = os.path.join(image_dir, image_filename)
+        pci_add_cmd = "pci_add pci_addr=auto storage file=%s,if=%s" % \
+                                              (storage_name, tested_model)
+        s, add_output = vm.send_monitor_cmd(pci_add_cmd)
+
+    if not "OK domain" in add_output:
+        raise error.TestFail("Command failed: %s" % pci_add_cmd)
+
+    # 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 in 'info pci'")
+
+    time.sleep(5)
+   
+    o = session.get_command_output(ref_cmd)
+    if reference == o:
+        raise error.TestFail("No new device shown in cmd: %s" % ref_cmd)
+
+    cmd = params.get("find_pci_cmd")
+    output = session.get_command_output(cmd)
+    if not params.get("match_string") in output:
+        raise error.TestFail("Not found pci model: %s; Command is: %s" % ( \
+                                                           tested_model, cmd))
+
+    # del 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; \
+                          Command: %s" % (tested_model, cmd))
+
+    # check whether VM's network & disk work fine
+    if session.get_command_status(params.get("pci_test_cmd")):
+        raise error.TestFail("VM's %s damaged after pci_hotplug" % test_type)
+
+    session.close()
diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 503f636..95b55eb 100644
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -239,6 +239,8 @@ class VM:
 
         for image_name in kvm_utils.get_sub_dict_names(params, "images"):
             image_params = kvm_utils.get_sub_dict(params, image_name)
+            if image_params.get("boot_drive") == "no":
+                continue
             qemu_cmd += " -drive file=%s" % get_image_filename(image_params,
                                                                image_dir)
             if image_params.get("drive_format"):
-- 
1.6.2.5


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2009-08-04  8:47 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-03  5:57 [PATCH] Add a subtest pci_hotplug in kvm test Yolkfull Chow
2009-07-03  6:00 ` Yolkfull Chow
2009-07-08  1:51   ` [Autotest] " Lucas Meneghel Rodrigues
2009-07-10  2:01     ` Yolkfull Chow
2009-07-15  3:37     ` Yolkfull Chow
  -- strict thread matches above, loose matches on Subject: below --
2009-06-30 11:11 Yolkfull Chow
2009-06-30 13:58 ` Dor Laor
2009-07-01  2:09   ` Yolkfull Chow
2009-08-03  9:19   ` Yolkfull Chow
2009-08-03 11:37     ` Dor Laor
2009-08-04  3:30       ` Yolkfull Chow
2009-08-04  7:54         ` Yolkfull Chow
2009-08-04  8:47           ` Yolkfull Chow
2009-08-03 13:21     ` Glauber Costa
2009-06-30 22:40 ` Lucas Meneghel Rodrigues

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).