Skip to contentSkip to conversation

virt.tests.netstress_kill_guest: Workaround udev writing to serial

PATCH New Lucas Meneghel Rodrigues 1 participant 1 message Mar 7, 2012 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virt.tests.netstress_kill_guest: Workaround udev writing to serial

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.

---
 client/virt/tests/netstress_kill_guest.py |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)
client/virt/tests/netstress_kill_guest.py +17 -5
index 50eb0af..722169c 100644
@@ -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)
 
 
Signature · 1 line
1.7.7.6