From 7ecd9877e6a1b235070d6feba59a3840ebbc5255 Mon Sep 17 00:00:00 2001 From: Atanas Bunchev Date: Fri, 11 Nov 2022 12:21:51 +0200 Subject: qemu.rst: slirp port forwarding details Explain the default behavior of `runqemu slirp`. Explain how to forward ports from the guest to the host machine. (From yocto-docs rev: 239314da5998f27d0e3a0f2e538216e852bb19d8) Signed-off-by: Atanas Bunchev Reviewed-by: Quentin Schulz Reviewed-by: Michael Opdenacker Signed-off-by: Richard Purdie --- documentation/dev-manual/qemu.rst | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/documentation/dev-manual/qemu.rst b/documentation/dev-manual/qemu.rst index d9b9f69ab3..504fcbdd8d 100644 --- a/documentation/dev-manual/qemu.rst +++ b/documentation/dev-manual/qemu.rst @@ -329,7 +329,7 @@ Following is the command-line help output for the ``runqemu`` command:: Simplified QEMU command-line options can be passed with: nographic - disable video console serial - enable a serial console on /dev/ttyS0 - slirp - enable user networking, no root privileges is required + slirp - enable user networking, no root privileges required kvm - enable KVM when running x86/x86_64 (VT-capable CPU required) kvm-vhost - enable KVM with vhost when running x86/x86_64 (VT-capable CPU required) publicvnc - enable a VNC server open to all hosts @@ -427,6 +427,29 @@ command line: networking that does not need root access but also is not as easy to use or comprehensive as the default. + Using ``slirp`` by default will forward the guest machine's + 22 and 23 TCP ports to host machine's 2222 and 2323 ports + (or the next free ports). Specific forwarding rules can be configured + by setting ``QB_SLIRP_OPT`` as environment variable or in ``qemuboot.conf`` + in the :term:`Build Directory` ``deploy/image`` directory. + Examples:: + + QB_SLIRP_OPT="-netdev user,id=net0,hostfwd=tcp::8080-:80" + + QB_SLIRP_OPT="-netdev user,id=net0,hostfwd=tcp::8080-:80,hostfwd=tcp::2222-:22" + + The first example forwards TCP port 80 from the emulated system to + port 8080 (or the next free port) on the host system, + allowing access to an http server running in QEMU from + ``http://:8080/``. + + The second example does the same, but also forwards TCP port 22 on the + guest system to 2222 (or the next free port) on the host system, + allowing ssh access to the emulated system using + ``ssh -P 2222 @``. + + Keep in mind that proper configuration of firewall software is required. + - ``kvm``: Enables KVM when running "qemux86" or "qemux86-64" QEMU architectures. For KVM to work, all the following conditions must be met: -- cgit v1.2.3-54-g00ecf