Skip to content

Commit

Permalink
virt.tests.netstress_kill_guest: Workaround udev writing to serial
Browse files Browse the repository at this point in the history
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@redhat.com>
  • Loading branch information
lmr committed Mar 7, 2012
1 parent c625fb3 commit 1711f14
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions client/virt/tests/netstress_kill_guest.py
Expand Up @@ -121,17 +121,29 @@ def netload_kill_problem(session_serial):
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)


Expand Down

0 comments on commit 1711f14

Please sign in to comment.