diff mbox series

[v2] qemu.rst: slirp port forwarding details

Message ID 20221109134930.21879-1-atanas.bunchev@konsulko.com
State New
Headers show
Series [v2] qemu.rst: slirp port forwarding details | expand

Commit Message

Atanas Bunchev Nov. 9, 2022, 1:49 p.m. UTC
Explains the default behavior of `runqemu slirp`.
Explains how to forward ports from the guest to the host machine.

Signed-off-by: Atanas Bunchev <atanas.bunchev@konsulko.com>
---
 documentation/dev-manual/qemu.rst | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Quentin Schulz Nov. 9, 2022, 4:22 p.m. UTC | #1
Hi Atanas,

On 11/9/22 14:49, Atanas Bunchev wrote:
> Explains the default behavior of `runqemu slirp`.
> Explains how to forward ports from the guest to the host machine.
> 
> Signed-off-by: Atanas Bunchev <atanas.bunchev@konsulko.com>
> ---
>   documentation/dev-manual/qemu.rst | 21 +++++++++++++++++++++
>   1 file changed, 21 insertions(+)
> 
> diff --git a/documentation/dev-manual/qemu.rst b/documentation/dev-manual/qemu.rst
> index 5a4a82ce6..a17c8cead 100644
> --- a/documentation/dev-manual/qemu.rst
> +++ b/documentation/dev-manual/qemu.rst
> @@ -426,6 +426,27 @@ 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 ports to host machine's 2222 and 2323, incrementing

Please add "TCP" in front of ports (or somewhere adequate). UDP is not 
forwarded by default.

> +   them if they're already taken by another ``runqemu`` instance.

I'd replace
incrementing them if they're already taken by another runqemu instance
by
or the next free port available.

because it checks if the port is available, it does not matter if it's a 
runqemu instance running or not.

> +   Specific forwarding rules can be configured by
> +   setting ``QB_SLIRP_OPT`` in ``qemuboot.conf``.
> +   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 on the host system, allowing access to http server running in
> +   QEMU from ``http://<host ip>:8080/``
> +

Missing dot at the end of the sentence.

Also, this is incorrect, because if 8080 is already taken, it'll try to 
find the next free port available similar to what's done for the default 
value. So a bit of rewording will be necessary to include this important 
piece of information.

On a side note, quite interestingly, we only check if the TCP port is 
taken even if a forwarding rule for UDP is added.


> +   The second example does the same, but also forwards port 22 to 2222,
> +   allowing ssh access to the emulated system using
> +   ``ssh -P 2222 <user>@<host ip>``
> +

Same remarks apply for this paragraph.

Cheers,
Quentin
diff mbox series

Patch

diff --git a/documentation/dev-manual/qemu.rst b/documentation/dev-manual/qemu.rst
index 5a4a82ce6..a17c8cead 100644
--- a/documentation/dev-manual/qemu.rst
+++ b/documentation/dev-manual/qemu.rst
@@ -426,6 +426,27 @@  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 ports to host machine's 2222 and 2323, incrementing
+   them if they're already taken by another ``runqemu`` instance.
+   Specific forwarding rules can be configured by
+   setting ``QB_SLIRP_OPT`` in ``qemuboot.conf``.
+   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 on the host system, allowing access to http server running in
+   QEMU from ``http://<host ip>:8080/``
+
+   The second example does the same, but also forwards port 22 to 2222, 
+   allowing ssh access to the emulated system using
+   ``ssh -P 2222 <user>@<host ip>``
+
+   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: