All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Markus Armbruster <armbru@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] hostfwd_add and -netdev user
Date: Fri, 18 Nov 2011 10:37:15 -0200	[thread overview]
Message-ID: <4EC6517B.3060904@web.de> (raw)
In-Reply-To: <m3mxbwpei4.fsf@blackfin.pond.sub.org>

[-- Attachment #1: Type: text/plain, Size: 3334 bytes --]

On 2011-11-16 08:07, Markus Armbruster wrote:
> Maybe I'm missing something, but it looks like hostfwd_add doesn't fully
> work with -netdev.
> 
> Command definition from hmp-commands.hx:
> 
>     {
>         .name       = "hostfwd_add",
>         .args_type  = "arg1:s,arg2:s?,arg3:s?",
>         .params     = "[vlan_id name] [tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport",
>         .help       = "redirect TCP or UDP connections from host to guest (requires -net user)",
>         .mhandler.cmd = 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 = qdict_get_str(qdict, "arg1");
>     const char *arg2 = qdict_get_try_str(qdict, "arg2");
>     const char *arg3 = qdict_get_try_str(qdict, "arg3");
> 
>     if (arg2) {
>         s = slirp_lookup(mon, arg1, arg2);
>         redir_str = arg3;
>     } else {
>         s = slirp_lookup(mon, NULL, NULL);
>         redir_str = arg1;
>     }
>     if (s) {
>         slirp_hostfwd(s, redir_str, 0);
>     }
> 
> }
> 
> If I understand the code correctly, the command has the following forms:
> 
> * 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=net.0 -device virtio-net-pci,netdev=net.0,id=nic.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
> 
> * hostfwd_add VLAN STACK REDIR
> 
>   This form was added in commit f13b572c "slirp: Make hostfwd_add/remove
>   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 bridge.
> 
>   Note that slirp_lookup() converts VLAN to an int (without error
>   checking, i.e. non-integers are silently interpreted as zero, integers
>   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=nic.0,vlan=0QEMU 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 with
>   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]]

?

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

  reply	other threads:[~2011-11-18 12:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-16 10:07 [Qemu-devel] hostfwd_add and -netdev user Markus Armbruster
2011-11-18 12:37 ` Jan Kiszka [this message]
2011-11-18 13:07   ` Markus Armbruster
2011-11-18 13:13     ` Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EC6517B.3060904@web.de \
    --to=jan.kiszka@web.de \
    --cc=armbru@redhat.com \
    --cc=markmc@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.