def cleanup_ports(self): """ Clean state of all ports and set port to default state. Default state: No data on port or in port buffer. Read mode = blocking. """ # Check if python is still alive match, tmp = self._cmd("is_alive()", 10) if (match is None) or (match != 0): logging.error("Python died/is stuck/have remaining threads") logging.debug(tmp) try: self.vm.verify_kernel_crash() match, tmp = self._cmd("guest_exit()", 10) if (match is None) or (match == 0): self.session.close() self.session = virt_test_utils.wait_for_login(self.vm) self.cmd("killall -9 python " "&& echo -n PASS: python killed" "|| echo -n PASS: python was already dead", 10) self._init_guest() self._cleanup_ports() except Exception, inst: logging.error(inst) raise VirtioPortFatalException("virtio-console driver is " "irreparably blocked, further tests might FAIL.")
def __init__(self, vm): """ Initialize worker for use (including port init on guest) """ self.vm = vm self.session = virt_test_utils.wait_for_login(self.vm) timeout = 10 if self.session.cmd_status('ls /tmp/virtio_console_guest.pyo'): # Copy virtio_console_guest.py into guests virt_dir = os.path.join(os.environ['AUTODIR'], 'virt') vksmd_src = os.path.join(virt_dir, "scripts", "virtio_console_guest.py") dst_dir = "/tmp" self.vm.copy_files_to(vksmd_src, dst_dir) # Compile and execute worker logging.debug("compile virtio_console_guest.py on guest %s", self.vm.name) self.cmd("python -OO /tmp/virtio_console_guest.py -c " "&& echo -n 'PASS: Compile virtio_guest finished' || " "echo -n 'FAIL: Compile virtio_guest failed'", timeout) self.session.sendline() logging.debug("Starting virtio_console_guest.py on guest %s", self.vm.name) self._execute_worker(timeout) self._init_guest(timeout)
def reconnect(self, vm, timeout=10): """ Reconnect to guest_worker (eg. after migration) @param vm: New VM object """ self.vm = vm self.session = virt_test_utils.wait_for_login(self.vm) self._execute_worker(timeout)