Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use qemu's "-redir" option in run.py #781

Closed
nyh opened this issue Aug 7, 2016 · 2 comments
Closed

Don't use qemu's "-redir" option in run.py #781

nyh opened this issue Aug 7, 2016 · 2 comments

Comments

@nyh
Copy link
Contributor

nyh commented Aug 7, 2016

QEMU's "-redir" option has been deprecated for at least 5 years now, but silently supported. Since QEMU 2.6, it started to be annoyingly loud about it:

$ scripts/run.py -e tests/tst-rename.so 
qemu-system-x86_64: -redir tcp:2222::22: The -redir option is deprecated. Please use '-netdev user,hostfwd=...' instead.
OSv v0.24-157-gab34727

We can probably fix it exactly as the message suggests.

nyh added a commit that referenced this issue Oct 5, 2016
OSv does not include by default (or at all) an SSH server for a long time,
so the forwarding of the guest's port 22 to port 2222 on the guest is
pretty pointless. And generates the annoying message of issue #781.

Signed-off-by: Nadav Har'El <nyh@scylladb.com>
myechuri pushed a commit to myechuri/osv that referenced this issue Jun 22, 2017
OSv does not include by default (or at all) an SSH server for a long time,
so the forwarding of the guest's port 22 to port 2222 on the guest is
pretty pointless. And generates the annoying message of issue cloudius-systems#781.

Signed-off-by: Nadav Har'El <nyh@scylladb.com>
@geraldo-netto
Copy link
Contributor

Dear @nyh ,

I have played for a while with it today and it turns out,
we require a little more than a simple string replacement...

According to the documentation [1], we should set something like this:

-netdev user,id=<iface name>,hostfwd=tcp:<ip in>:<port in>-<ip out>:<port out>

So, I tried this:

...
if options.api:
  args += ["-netdev", "user,id=hn%d,hostfwd=tcp::8000-:8000" % idx]

for rule in options.forward:
  args += ["-netdev", "user,id=hn{},hostfwd={}".format(idx, rule)]
...

But because we set netdev before handling "--api" or "--forward", qemu fails with the following message:

netto@besta01 ~/osv-3 $ sudo scripts/run.py -nV --api
qemu-system-x86_64: -netdev user,id=hn0,hostfwd=tcp::8000-:8000: Duplicate ID 'hn0' for netdev
qemu failed.

It's strange that it fails because the same documentation says it can handle multiple -netdev entries...
The solution seems to be concatenate the forwards when the first -netdev is defined

[1] https://wiki.qemu.org/Documentation/Networking

Kind Regards,
Geraldo Netto

@nyh
Copy link
Contributor Author

nyh commented Mar 11, 2018

@geraldo-netto I think the redirection options ("api" and "forward") are only relevant to the emulated network (qemu's "user" network), not to bridging mode, so I think the solution is to do something like your above code, but only in the one specific case (an "else:" section of if options.networking) where the "user" netdev is being set up by run.py.

So it's more or less what you suggested, just that you need to do it only for the user netdev, not the bridge ones. Looks pretty straightforward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants