No need to use serial console for the following reasons:
- The test could be also run for windows guest which does not have serial
console support currently.
- The test have the codes to shutdown the primary link during testing the new
plugged cards.
So we can safely use ssh/rss to login.

Also fix the problems when nic_script was not specified in the configuration
files.

Signed-off-by: Jason Wang <jasow...@redhat.com>
---
 client/tests/kvm/tests/nic_hotplug.py |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/client/tests/kvm/tests/nic_hotplug.py 
b/client/tests/kvm/tests/nic_hotplug.py
index 2946396..d44276a 100644
--- a/client/tests/kvm/tests/nic_hotplug.py
+++ b/client/tests/kvm/tests/nic_hotplug.py
@@ -23,20 +23,21 @@ def run_nic_hotplug(test, params, env):
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
     timeout = int(params.get("login_timeout", 360))
     guest_delay = int(params.get("guest_delay", 20))
-    session_serial = kvm_test_utils.wait_for_login(vm, timeout=timeout,
-                                                   serial=True)
+    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
     romfile = params.get("romfile")
 
     # Modprobe the module if specified in config file
     module = params.get("modprobe_module")
     if module:
-        session_serial.get_command_output("modprobe %s" % module)
+        session.get_command_output("modprobe %s" % module)
 
     def netdev_add(vm):
         netdev_id = kvm_utils.generate_random_id()
-        attach_cmd = ("netdev_add tap,id=%s,script=%s" %
-                      (netdev_id, kvm_utils.get_path(vm.root_dir,
-                                                     
params.get("nic_script"))))
+        attach_cmd = ("netdev_add tap,id=%s" % netdev_id)
+        nic_script = params.get("nic_script")
+        if nic_script:
+            attach_cmd += ",script=%s" % kvm_utils.get_path(vm.root_dir,
+                                                            nic_script)
         netdev_extra_params = params.get("netdev_extra_params")
         if netdev_extra_params:
             attach_cmd += ",%s" % netdev_extra_params
@@ -80,7 +81,7 @@ def run_nic_hotplug(test, params, env):
         vm.monitor.cmd(device_add_cmd)
 
         qdev = vm.monitor.info("qtree")
-        if id not in qdev:
+        if not nic_id in qdev:
             logging.error(qdev)
             raise error.TestFail("Device %s was not plugged into qdev"
                                  "tree" % nic_id)
@@ -115,8 +116,8 @@ def run_nic_hotplug(test, params, env):
     device_id = nic_add(vm, "virtio", netdev_id, mac, romfile)
 
     if "Win" not in params.get("guest_name", ""):
-        session_serial.sendline("dhclient %s &" %
-                         kvm_test_utils.get_linux_ifname(session_serial, mac))
+        session.sendline("dhclient %s &" %
+                         kvm_test_utils.get_linux_ifname(session, mac))
 
     logging.info("Shutting down the primary link")
     vm.monitor.cmd("set_link %s down" % vm.netdev_id[0])

_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to