From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:54890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RROGf-0006qJ-EM for qemu-devel@nongnu.org; Fri, 18 Nov 2011 08:14:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RROGd-0003RE-Ve for qemu-devel@nongnu.org; Fri, 18 Nov 2011 08:14:09 -0500 Received: from fmmailgate03.web.de ([217.72.192.234]:36626) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RROGd-0003Qz-JA for qemu-devel@nongnu.org; Fri, 18 Nov 2011 08:14:07 -0500 Received: from moweb001.kundenserver.de (moweb001.kundenserver.de [172.19.20.114]) by fmmailgate03.web.de (Postfix) with ESMTP id AF5141AADEB34 for ; Fri, 18 Nov 2011 14:13:51 +0100 (CET) Message-ID: <4EC65A04.6050709@web.de> Date: Fri, 18 Nov 2011 11:13:40 -0200 From: Jan Kiszka MIME-Version: 1.0 References: <4EC6517B.3060904@web.de> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig2F7E04EA2F172871FE30DA0E" 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) --------------enig2F7E04EA2F172871FE30DA0E Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2011-11-18 11:07, Markus Armbruster wrote: > Jan Kiszka writes: >=20 >> On 2011-11-16 08:07, Markus Armbruster wrote: >>> Maybe I'm missing something, but it looks like hostfwd_add doesn't fu= lly >>> work with -netdev. >>> >>> Command definition from hmp-commands.hx: >>> >>> { >>> .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= guest (requires -net user)", >>> .mhandler.cmd =3D net_slirp_hostfwd_add, >>> }, >>> >>> Note: params says command takes either 1 or 3 arguments. args_type >>> can't express that, so it asks for 1-3. >>> >>> Command handler: >>> >>> 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"); >>> >>> 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); >>> } >>> >>> } >>> >>> If I understand the code correctly, the command has the following for= ms: >>> >>> * hostfwd_add REDIR >>> >>> This form uses the default stack (first member of slirp_stacks). >>> Seems to work okay with -netdev: >>> >>> $ qemu-system-x86_64 --nodefaults --enable-kvm -vnc :0 -S -m 384 = -monitor stdio -netdev user,id=3Dnet.0 -device virtio-net-pci,netdev=3Dne= t.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 Po= rt RecvQ SendQ >>> TCP[HOST_FORWARD] 12 * 12345 10.0.2.15 = 22 0 0 >>> >>> * hostfwd_add VLAN STACK REDIR >>> >>> This form was added in commit f13b572c "slirp: Make hostfwd_add/rem= ove >>> multi-instance-aware". >>> >>> I don't like how it overloads the command; adding the optional >>> arguments at the end would have been cleaner. Water under the brid= ge. >>> >>> Note that slirp_lookup() converts VLAN to an int (without error >>> checking, i.e. non-integers are silently interpreted as zero, integ= ers >>> out of bounds are silently truncated). >>> >>> Anyway, I can't make it work with -netdev: >>> >>> (qemu) hostfwd_add -1 net.0 tcp::12345-:22 >>> unknown VLAN -1 >>> >>> * Just for giggles: what if I give two arguments? >>> >>> $ qemu-system-x86_64--nodefaults --enable-kvm -vnc :0 -S -m 384 -= monitor stdio -net user -device virtio-net-pci,id=3Dnic.0,vlan=3D0QEMU 0.= 15.92 monitor - type 'help' for more information >>> (qemu) hostfwd_add 0 user.0 >>> invalid host forwarding rule '(null)' >>> >>> The (null) is from a printf-like function printing a null pointer w= ith >>> conversion %s. Crash bug on some systems. >>> >> >> 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]] >> >> ? >=20 > Should work quite nicely, as long as the targeted SlirpState has a name= =2E > Always the case, isn't it? IIRC, all network clients get model.instance as default name. >=20 > Libvirt doesn't depend on hostfwd_add, as far as I can tell. >=20 > hostwd_remove should be changed to match. Yep. Jan --------------enig2F7E04EA2F172871FE30DA0E 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/ iEYEARECAAYFAk7GWgUACgkQitSsb3rl5xT1zwCg7a7WdLPc6LM40mBuXP4zN8qQ fHYAnj3Gf3VB6g/eH32PTW7QdehNGB6b =iFHz -----END PGP SIGNATURE----- --------------enig2F7E04EA2F172871FE30DA0E--