How to replace `qemu-system -redir` command argument?

倖福魔咒の 提交于 2020-06-09 18:06:32

问题


I have a script starting qemu with these options:

qemu-system-x86_64 [...] -net nic,model=rtl8139 -net user,hostfwd=tcp::5555-:1522 -net dump,file=/tmp/vm0.pcap -redir tcp:9999::9 -redir tcp:17010::17010 -redir tcp:17013::17013

I want to update the script to work with modern qemu options.

I've tried with the following arguments, as documented in the manual page

qemu-system-x86_64 [...] -net nic,model=rtl8139 -net dump,file=/tmp/vm0.pcap -net user,id=tcp1522,hostfwd=tcp::5555-:1522 -netdev user,id=tcp9,hostfwd=tcp::9999-:9 -netdev user,id=tcp17010,hostfwd=tcp::17010-:17010 -netdev user,id=tcp17013,hostfwd=tcp::17013-:17013

but the guest cannot reach the network anymore and it cannot be reached by the host on the forwarded ports.

What's the exact equivalent of the deprecated -redir option?


回答1:


After @PeterMaydell comments and a few more readings I understood how the options -device and -netdev relates in qemu.

The correct translation of the older -redir options used in my script are:

-netdev user,id=ethernet.0,hostfwd=tcp::5555-:1522,hostfwd=tcp::9999-:9,hostfwd=tcp::17010-:17010,hostfwd=tcp::17013-:17013
-device rtl8139,netdev=ethernet.0

In a -netdev user you specify all host->guest port forwards for a single virtual ethernet of the guest. The id option identify such virtual network interface (ethernet.0 in this case).

The -device argument can then define the hardware to simulate for that interface (related with netdev=ethernet.0) so that the guest see that hardware in place and open the forwarded ports.



来源:https://stackoverflow.com/questions/46041082/how-to-replace-qemu-system-redir-command-argument

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!