By default host side IP address is not set and qemu listens
on all IP addresses on the host machine which is not a good
idea when images have root login enabled without password.
It make sense to listen only on localhost IP address 127.0.0.1 using
config change like:

QB_SLIRP_OPT = "-netdev user,id=net0,hostfwd=tcp:127.0.0.1:2222-:22"

This config works for qemu itself, but breaks runqemu which tries to
parse the host side port number from qemu process command line arguments.
So change the runqemu side hostfwd parsing for port number to ignore
the host IP address field.

Reviewed-by: Quentin Schulz <foss+yo...@0leil.net>
Signed-off-by: Mikko Rapeli <mikko.rap...@linaro.org>
---
 meta/lib/oeqa/utils/qemurunner.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

v3: use IP address from command line too

v2: improved commit message, 
https://lists.openembedded.org/g/openembedded-core/message/173250

v1: https://lists.openembedded.org/g/openembedded-core/topic/95016024#173234

diff --git a/meta/lib/oeqa/utils/qemurunner.py 
b/meta/lib/oeqa/utils/qemurunner.py
index e602399232..c285f30c0a 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -401,9 +401,10 @@ class QemuRunner:
                 cmdline = re_control_char.sub(' ', cmdline)
             try:
                 if self.use_slirp:
-                    tcp_ports = cmdline.split("hostfwd=tcp::")[1]
+                    tcp_ports = cmdline.split("hostfwd=tcp:")[1]
+                    ip, tcp_ports = tcp_ports.split(":")[:2]
                     host_port = tcp_ports[:tcp_ports.find('-')]
-                    self.ip = "localhost:%s" % host_port
+                    self.ip = "%s:%s" % (ip, host_port)
                 else:
                     ips = re.findall(r"((?:[0-9]{1,3}\.){3}[0-9]{1,3})", 
cmdline.split("ip=")[1])
                     self.ip = ips[0]
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#173470): 
https://lists.openembedded.org/g/openembedded-core/message/173470
Mute This Topic: https://lists.openembedded.org/mt/95114891/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to