Re: [PATCH] net/slirp: allow hostfwd socket paths with dashes
Michael Tokarev <[email protected]>
| Newsgroups | org.nongnu.qemu-trivial,org.nongnu.qemu-devel |
|---|---|
| Message-ID | <[email protected]> |
On 2/14/26 00:57, Christopher Palmer-Richez wrote: > Adds get_last_str_sep, a variant of get_str_sep that checks for the last > occurence of a separator. Updates slirp_hostfwd to parse unix domain > socket paths with dashes. > > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/347 > Signed-off-by: Christopher Palmer-Richez <[email protected]> > --- > QEMU added support for `-netdev user,hostfwd=unix:/tmp/vm-:22` last year. > The implementation detects the first dash, and interprets the right side > of it as the guest address (or lack thereof). If the host socket path > contains a dash, the invocation fails with "Bad guest address." > > This tiny patch adds a variant of the `get_str_sep` method previously > used by `slirp_hostfwd`, but that detects the last occurence of a > separator instead: `get_last_str_sep`. The only difference is the use of > `strrchr` instead of `strchr`. `slirp_hostfwd` now uses it. It ignores > dashes up to the last occurence, which allows unix domain socket paths > with dashes. I think neither of the current or the proposed variants is the right solution. It doesn't matter how we count the dashes, one way or another we'll miss the user intention, for example, does the host side allowed to contain a host name instead of just an IP address? Besides, hostfwd=unix:/tmp/foo-bar-:22 is just ugly, it's difficult to read. It feels like some other solution should be used here, and the original way wasn't right (it is in used now already, though). Or maybe I'm wrong.. dunno. It somehow feels all wrong :) Thanks, /mjt