From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:37080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRNhD-0005kd-KK for qemu-devel@nongnu.org; Fri, 18 Nov 2011 07:37:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RRNhC-0004iR-4d for qemu-devel@nongnu.org; Fri, 18 Nov 2011 07:37:31 -0500 Received: from fmmailgate02.web.de ([217.72.192.227]:50948) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRNhB-0004i0-BS for qemu-devel@nongnu.org; Fri, 18 Nov 2011 07:37:29 -0500 Received: from moweb002.kundenserver.de (moweb002.kundenserver.de [172.19.20.108]) by fmmailgate02.web.de (Postfix) with ESMTP id CBA751BAFB060 for ; Fri, 18 Nov 2011 13:37:26 +0100 (CET) Message-ID: <4EC6517B.3060904@web.de> Date: Fri, 18 Nov 2011 10:37:15 -0200 From: Jan Kiszka MIME-Version: 1.0 References: In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig9987B6E897540209C821E02C" Subject: Re: [Qemu-devel] hostfwd_add and -netdev user List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Mark McLoughlin , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig9987B6E897540209C821E02C Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2011-11-16 08:07, Markus Armbruster wrote: > Maybe I'm missing something, but it looks like hostfwd_add doesn't full= y > work with -netdev. >=20 > Command definition from hmp-commands.hx: >=20 > { > .name =3D "hostfwd_add", > .args_type =3D "arg1:s,arg2:s?,arg3:s?", > .params =3D "[vlan_id name] [tcp|udp]:[hostaddr]:hostport-[= guestaddr]:guestport", > .help =3D "redirect TCP or UDP connections from host to g= uest (requires -net user)", > .mhandler.cmd =3D net_slirp_hostfwd_add, > }, >=20 > Note: params says command takes either 1 or 3 arguments. args_type > can't express that, so it asks for 1-3. >=20 > Command handler: >=20 > void net_slirp_hostfwd_add(Monitor *mon, const QDict *qdict) > { > const char *redir_str; > SlirpState *s; > const char *arg1 =3D qdict_get_str(qdict, "arg1"); > const char *arg2 =3D qdict_get_try_str(qdict, "arg2"); > const char *arg3 =3D qdict_get_try_str(qdict, "arg3"); >=20 > if (arg2) { > s =3D slirp_lookup(mon, arg1, arg2); > redir_str =3D arg3; > } else { > s =3D slirp_lookup(mon, NULL, NULL); > redir_str =3D arg1; > } > if (s) { > slirp_hostfwd(s, redir_str, 0); > } >=20 > } >=20 > If I understand the code correctly, the command has the following forms= : >=20 > * hostfwd_add REDIR >=20 > This form uses the default stack (first member of slirp_stacks). > Seems to work okay with -netdev: >=20 > $ qemu-system-x86_64 --nodefaults --enable-kvm -vnc :0 -S -m 384 -m= onitor stdio -netdev user,id=3Dnet.0 -device virtio-net-pci,netdev=3Dnet.= 0,id=3Dnic.0 > QEMU 0.15.92 monitor - type 'help' for more information > (qemu) hostfwd_add tcp::12345-:22 > (qemu) info usernet > VLAN -1 (net.0): > Protocol[State] FD Source Address Port Dest. Address Port= RecvQ SendQ > TCP[HOST_FORWARD] 12 * 12345 10.0.2.15 22= 0 0 >=20 > * hostfwd_add VLAN STACK REDIR >=20 > This form was added in commit f13b572c "slirp: Make hostfwd_add/remov= e > multi-instance-aware". >=20 > I don't like how it overloads the command; adding the optional > arguments at the end would have been cleaner. Water under the bridge= =2E >=20 > Note that slirp_lookup() converts VLAN to an int (without error > checking, i.e. non-integers are silently interpreted as zero, integer= s > out of bounds are silently truncated). >=20 > Anyway, I can't make it work with -netdev: >=20 > (qemu) hostfwd_add -1 net.0 tcp::12345-:22 > unknown VLAN -1 >=20 > * Just for giggles: what if I give two arguments? >=20 > $ qemu-system-x86_64--nodefaults --enable-kvm -vnc :0 -S -m 384 -mo= nitor stdio -net user -device virtio-net-pci,id=3Dnic.0,vlan=3D0QEMU 0.15= =2E92 monitor - type 'help' for more information > (qemu) hostfwd_add 0 user.0 > invalid host forwarding rule '(null)' >=20 > The (null) is from a printf-like function printing a null pointer wit= h > conversion %s. Crash bug on some systems. >=20 Agreed, there is some need for improvements. I would not mind changing the command syntax, in fact, if it helps and no major user is already relying on it (can't imagine, specifically as netdev support is broken). What about hostfwd_add rule [name [vlan]] ? Jan --------------enig9987B6E897540209C821E02C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk7GUXsACgkQitSsb3rl5xQEmgCgp9591HJ4C/TkKAMIcgGXwfWc C/wAoO7i7WZ928wM9DM1COpCzRq/uf9J =Ut+Y -----END PGP SIGNATURE----- --------------enig9987B6E897540209C821E02C--