summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py36
1 files changed, 22 insertions, 14 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 59dc11d00f..7e5f588f60 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -37,10 +37,12 @@ class QemuRunner:
37 self.runqemu = None 37 self.runqemu = None
38 # pid of the qemu process that runqemu will start 38 # pid of the qemu process that runqemu will start
39 self.qemupid = None 39 self.qemupid = None
40 # target ip - from the command line 40 # target ip - from the command line or runqemu output
41 self.ip = None 41 self.ip = None
42 # host ip - where qemu is running 42 # host ip - where qemu is running
43 self.server_ip = None 43 self.server_ip = None
44 # target ip netmask
45 self.netmask = None
44 46
45 self.machine = machine 47 self.machine = machine
46 self.rootfs = rootfs 48 self.rootfs = rootfs
@@ -192,6 +194,7 @@ class QemuRunner:
192 return False 194 return False
193 time.sleep(1) 195 time.sleep(1)
194 196
197 out = self.getOutput(output)
195 if self.is_alive(): 198 if self.is_alive():
196 logger.info("qemu started - qemu procces pid is %s" % self.qemupid) 199 logger.info("qemu started - qemu procces pid is %s" % self.qemupid)
197 if get_ip: 200 if get_ip:
@@ -203,17 +206,23 @@ class QemuRunner:
203 cmdline = re_control_char.sub('', cmdline) 206 cmdline = re_control_char.sub('', cmdline)
204 try: 207 try:
205 ips = re.findall("((?:[0-9]{1,3}\.){3}[0-9]{1,3})", cmdline.split("ip=")[1]) 208 ips = re.findall("((?:[0-9]{1,3}\.){3}[0-9]{1,3})", cmdline.split("ip=")[1])
206 if not ips or len(ips) != 3: 209 self.ip = ips[0]
207 raise ValueError 210 self.server_ip = ips[1]
208 else: 211 logger.info("qemu cmdline used:\n{}".format(cmdline))
209 self.ip = ips[0]
210 self.server_ip = ips[1]
211 except (IndexError, ValueError): 212 except (IndexError, ValueError):
212 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))) 213 # Try to get network configuration from runqemu output
213 self._dump_host() 214 match = re.match('.*Network configuration: ([0-9.]+)::([0-9.]+):([0-9.]+)$.*',
214 self.stop() 215 out, re.MULTILINE|re.DOTALL)
215 return False 216 if match:
216 logger.info("qemu cmdline used:\n{}".format(cmdline)) 217 self.ip, self.server_ip, self.netmask = match.groups()
218 else:
219 logger.error("Couldn't get ip from qemu command line and runqemu output! "
220 "Here is the qemu command line used:\n%s\n"
221 "and output from runqemu:\n%s" % (cmdline, out))
222 self._dump_host()
223 self.stop()
224 return False
225
217 logger.info("Target IP: %s" % self.ip) 226 logger.info("Target IP: %s" % self.ip)
218 logger.info("Server IP: %s" % self.server_ip) 227 logger.info("Server IP: %s" % self.server_ip)
219 228
@@ -222,12 +231,11 @@ class QemuRunner:
222 if not self.thread.connection_established.wait(self.boottime): 231 if not self.thread.connection_established.wait(self.boottime):
223 logger.error("Didn't receive a console connection from qemu. " 232 logger.error("Didn't receive a console connection from qemu. "
224 "Here is the qemu command line used:\n%s\nand " 233 "Here is the qemu command line used:\n%s\nand "
225 "output from runqemu:\n%s" % (cmdline, 234 "output from runqemu:\n%s" % (cmdline, out))
226 self.getOutput(output)))
227 self.stop_thread() 235 self.stop_thread()
228 return False 236 return False
229 237
230 logger.info("Output from runqemu:\n%s", self.getOutput(output)) 238 logger.info("Output from runqemu:\n%s", out)
231 logger.info("Waiting at most %d seconds for login banner" % self.boottime) 239 logger.info("Waiting at most %d seconds for login banner" % self.boottime)
232 endtime = time.time() + self.boottime 240 endtime = time.time() + self.boottime
233 socklist = [self.server_socket] 241 socklist = [self.server_socket]