summaryrefslogtreecommitdiffstats
path: root/yocto-poky/meta/lib/oeqa/utils/qemurunner.py
diff options
context:
space:
mode:
Diffstat (limited to 'yocto-poky/meta/lib/oeqa/utils/qemurunner.py')
-rw-r--r--yocto-poky/meta/lib/oeqa/utils/qemurunner.py77
1 files changed, 40 insertions, 37 deletions
diff --git a/yocto-poky/meta/lib/oeqa/utils/qemurunner.py b/yocto-poky/meta/lib/oeqa/utils/qemurunner.py
index bdc6e0a8f..784cf964f 100644
--- a/yocto-poky/meta/lib/oeqa/utils/qemurunner.py
+++ b/yocto-poky/meta/lib/oeqa/utils/qemurunner.py
@@ -91,12 +91,12 @@ class QemuRunner:
self._dump_host()
raise SystemExit
- def start(self, qemuparams = None):
+ def start(self, qemuparams = None, get_ip = True):
if self.display:
os.environ["DISPLAY"] = self.display
- else:
- logger.error("To start qemu I need a X desktop, please set DISPLAY correctly (e.g. DISPLAY=:1)")
- return False
+ # Set this flag so that Qemu doesn't do any grabs as SDL grabs
+ # interact badly with screensavers.
+ os.environ["QEMU_DONT_GRAB"] = "1"
if not os.path.exists(self.rootfs):
logger.error("Invalid rootfs %s" % self.rootfs)
return False
@@ -118,10 +118,10 @@ class QemuRunner:
logger.error("Failed to create listening socket: %s" % msg[1])
return False
- # Set this flag so that Qemu doesn't do any grabs as SDL grabs interact
- # badly with screensavers.
- os.environ["QEMU_DONT_GRAB"] = "1"
- self.qemuparams = 'bootparams="console=tty1 console=ttyS0,115200n8" qemuparams="-serial tcp:127.0.0.1:{}"'.format(threadport)
+
+ self.qemuparams = 'bootparams="console=tty1 console=ttyS0,115200n8 printk.time=1" qemuparams="-serial tcp:127.0.0.1:{}"'.format(threadport)
+ if not self.display:
+ self.qemuparams = 'nographic ' + self.qemuparams
if qemuparams:
self.qemuparams = self.qemuparams[:-1] + " " + qemuparams + " " + '\"'
@@ -178,27 +178,28 @@ class QemuRunner:
if self.is_alive():
logger.info("qemu started - qemu procces pid is %s" % self.qemupid)
- cmdline = ''
- with open('/proc/%s/cmdline' % self.qemupid) as p:
- cmdline = p.read()
- # It is needed to sanitize the data received
- # because is possible to have control characters
- cmdline = re_control_char.sub('', cmdline)
- try:
- ips = re.findall("((?:[0-9]{1,3}\.){3}[0-9]{1,3})", cmdline.split("ip=")[1])
- if not ips or len(ips) != 3:
- raise ValueError
- else:
- self.ip = ips[0]
- self.server_ip = ips[1]
- except IndexError, ValueError:
- logger.info("Couldn't get ip from qemu process arguments! Here is the qemu command line used:\n%s\nand output from runqemu:\n%s" % (cmdline, self.getOutput(output)))
- self._dump_host()
- self.stop()
- return False
- logger.info("qemu cmdline used:\n{}".format(cmdline))
- logger.info("Target IP: %s" % self.ip)
- logger.info("Server IP: %s" % self.server_ip)
+ if get_ip:
+ cmdline = ''
+ with open('/proc/%s/cmdline' % self.qemupid) as p:
+ cmdline = p.read()
+ # It is needed to sanitize the data received
+ # because is possible to have control characters
+ cmdline = re_control_char.sub('', cmdline)
+ try:
+ ips = re.findall("((?:[0-9]{1,3}\.){3}[0-9]{1,3})", cmdline.split("ip=")[1])
+ if not ips or len(ips) != 3:
+ raise ValueError
+ else:
+ self.ip = ips[0]
+ self.server_ip = ips[1]
+ except IndexError, ValueError:
+ logger.info("Couldn't get ip from qemu process arguments! Here is the qemu command line used:\n%s\nand output from runqemu:\n%s" % (cmdline, self.getOutput(output)))
+ self._dump_host()
+ self.stop()
+ return False
+ logger.info("qemu cmdline used:\n{}".format(cmdline))
+ logger.info("Target IP: %s" % self.ip)
+ logger.info("Server IP: %s" % self.server_ip)
self.thread = LoggingThread(self.log, threadsock, logger)
self.thread.start()
@@ -366,23 +367,25 @@ class QemuRunner:
# We assume target system have echo to get command status
if not raw:
command = "%s; echo $?\n" % command
- self.server_socket.sendall(command)
+
data = ''
status = 0
- stopread = False
- endtime = time.time()+5
- while time.time()<endtime and not stopread:
+ self.server_socket.sendall(command)
+ keepreading = True
+ while keepreading:
sread, _, _ = select.select([self.server_socket],[],[],5)
- for sock in sread:
- answer = sock.recv(1024)
+ if sread:
+ answer = self.server_socket.recv(1024)
if answer:
data += answer
# Search the prompt to stop
if re.search("[a-zA-Z0-9]+@[a-zA-Z0-9\-]+:~#", data):
- stopread = True
- break
+ keepreading = False
else:
raise Exception("No data on serial console socket")
+ else:
+ keepreading = False
+
if data:
if raw:
status = 1
OpenPOWER on IntegriCloud