]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
slirp: allow host port 0 for hostfwd
authorVincent Bernat <vincent@bernat.im>
Sat, 25 Feb 2017 21:31:58 +0000 (22:31 +0100)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sat, 29 Apr 2017 16:29:58 +0000 (18:29 +0200)
The OS will allocate automatically a free port. This is useful if you
want to be sure to not get any port conflict. You still have to figure
out which port you got, for example with "lsof" (this could be exposed
in the monitor if needed).

Example of use:

     $ qemu-system-x86_64 -net user,hostfwd=127.0.0.1:0-:22 ...

Then, get your port with:

     $ lsof -np 1474 | grep LISTEN
     qemu-syst 31777 bernat 12u IPv4 [...] TCP 127.0.0.1:35145 (LISTEN)

Signed-off-by: Vincent Bernat <vincent@bernat.im>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
net/slirp.c

index f97ec233454e47f827630da3f9e4ad2005a2f9c9..11b2dd249a79d7cd6b49598b8708c69f800b7604 100644 (file)
@@ -487,7 +487,7 @@ static int slirp_hostfwd(SlirpState *s, const char *redir_str,
         goto fail_syntax;
     }
     host_port = strtol(buf, &end, 0);
-    if (*end != '\0' || host_port < 1 || host_port > 65535) {
+    if (*end != '\0' || host_port < 0 || host_port > 65535) {
         goto fail_syntax;
     }