summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorYeoh Ee Peng <ee.peng.yeoh@intel.com>2018-11-22 17:10:44 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-11-23 23:35:18 +0000
commitba9c6285c5fa480ddf9956ee45c922d035114503 (patch)
tree34245e2e89cedff723ed899ac74b97e1589d1238 /meta/lib
parent010c24307b96c233c7b478be00e4df4b1b93184d (diff)
downloadpoky-ba9c6285c5fa480ddf9956ee45c922d035114503.tar.gz
qemurunner: Add support for slirp
Enable qemurunner for slirp. Retrieved the ip & port from host machine to connect to qemu from host machine. [YOCTO#10713] (From OE-Core rev: 1db6a6fc9cde28d0a29bcf6d24a8bfbe51d120b1) Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index d40b3b808b..f943034092 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -28,7 +28,8 @@ re_control_char = re.compile('[%s]' % re.escape("".join(control_chars)))
28 28
29class QemuRunner: 29class QemuRunner:
30 30
31 def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, boottime, dump_dir, dump_host_cmds, use_kvm, logger): 31 def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, boottime, dump_dir, dump_host_cmds,
32 use_kvm, logger, use_slirp=False):
32 33
33 # Popen object for runqemu 34 # Popen object for runqemu
34 self.runqemu = None 35 self.runqemu = None
@@ -51,6 +52,7 @@ class QemuRunner:
51 self.logged = False 52 self.logged = False
52 self.thread = None 53 self.thread = None
53 self.use_kvm = use_kvm 54 self.use_kvm = use_kvm
55 self.use_slirp = use_slirp
54 self.msg = '' 56 self.msg = ''
55 57
56 self.runqemutime = 120 58 self.runqemutime = 120
@@ -129,6 +131,8 @@ class QemuRunner:
129 self.logger.debug('Not using kvm for runqemu') 131 self.logger.debug('Not using kvm for runqemu')
130 if not self.display: 132 if not self.display:
131 launch_cmd += ' nographic' 133 launch_cmd += ' nographic'
134 if self.use_slirp:
135 launch_cmd += ' slirp'
132 launch_cmd += ' %s %s' % (self.machine, self.rootfs) 136 launch_cmd += ' %s %s' % (self.machine, self.rootfs)
133 137
134 return self.launch(launch_cmd, qemuparams=qemuparams, get_ip=get_ip, extra_bootparams=extra_bootparams, env=env) 138 return self.launch(launch_cmd, qemuparams=qemuparams, get_ip=get_ip, extra_bootparams=extra_bootparams, env=env)
@@ -238,9 +242,14 @@ class QemuRunner:
238 # because is possible to have control characters 242 # because is possible to have control characters
239 cmdline = re_control_char.sub(' ', cmdline) 243 cmdline = re_control_char.sub(' ', cmdline)
240 try: 244 try:
241 ips = re.findall(r"((?:[0-9]{1,3}\.){3}[0-9]{1,3})", cmdline.split("ip=")[1]) 245 if self.use_slirp:
242 self.ip = ips[0] 246 tcp_ports = cmdline.split("hostfwd=tcp::")[1]
243 self.server_ip = ips[1] 247 host_port = tcp_ports[:tcp_ports.find('-')]
248 self.ip = "localhost:%s" % host_port
249 else:
250 ips = re.findall(r"((?:[0-9]{1,3}\.){3}[0-9]{1,3})", cmdline.split("ip=")[1])
251 self.ip = ips[0]
252 self.server_ip = ips[1]
244 self.logger.debug("qemu cmdline used:\n{}".format(cmdline)) 253 self.logger.debug("qemu cmdline used:\n{}".format(cmdline))
245 except (IndexError, ValueError): 254 except (IndexError, ValueError):
246 # Try to get network configuration from runqemu output 255 # Try to get network configuration from runqemu output