[PATCH] virt.tests.netstress_kill_guest: Workaround udev writing to serial

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On some Linux guests such as RHEL 6.2, it's common that when
the succession of rmmods and modprobes happen, udev, SELinux
and other platform software write messages directly to the
serial, confusing aexpect. So let's write some code to
work around this peculiarity, being more robust in handling
these situations.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx>
---
 client/virt/tests/netstress_kill_guest.py |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/client/virt/tests/netstress_kill_guest.py b/client/virt/tests/netstress_kill_guest.py
index 50eb0af..722169c 100644
--- a/client/virt/tests/netstress_kill_guest.py
+++ b/client/virt/tests/netstress_kill_guest.py
@@ -121,17 +121,29 @@ def run_netstress_kill_guest(test, params, env):
                 os.kill(pid, signal.SIGCONT)
 
 
+    def send_cmd_safe(session_serial, cmd):
+        logging.debug("Sending command: %s", cmd)
+        session_serial.sendline(cmd)
+        got_prompt = False
+        while not got_prompt:
+            time.sleep(0.2)
+            session_serial.sendline()
+            try:
+                session_serial.read_up_to_prompt()
+                got_prompt = True
+            except aexpect.ExpectTimeoutError:
+                pass
+
+
     def netdriver_kill_problem(session_serial):
         modules = get_ethernet_driver(session_serial)
         logging.debug(modules)
         for _ in range(50):
             for module in modules:
-                session_serial.cmd("rmmod %s" % (module))
-                time.sleep(0.2)
+                send_cmd_safe(session_serial, "rmmod %s" % module)
             for module in modules:
-                logging.debug("Sending command: modprobe %s", module)
-                session_serial.sendline("modprobe %s\n" % (module))
-                time.sleep(0.2)
+                send_cmd_safe(session_serial, "modprobe %s" % module)
+
         kill_and_check(vm)
 
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux