Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 722
Giacomo Tesio Avatar asked Sep 04 '17 16:09

Giacomo Tesio


People also ask

How do I exit QEMU from command line?

Build everything and start qemu with the VGA console in a new window and the serial console in your terminal. To exit, either close the VGA window or press Ctrl-c or Ctrl-a x in your terminal.

What is QEMU system x86_64 in Linux?

Qemu is a machine emulator that can run operating systems and programs for one machine on a different machine. Mostly it is not used as emulator but as virtualizer in collaboration with KVM kernel components. In that case it utilizes the virtualization technology of the hardware to virtualize guests.

Is KVM and QEMU the same?

Unlike native QEMU, which uses emulation, KVM is a special operating mode of QEMU that uses CPU extensions (HVM) for virtualization via a kernel module. Using KVM, one can run multiple virtual machines running unmodified GNU/Linux, Windows, or any other operating system. (See Guest Support Status for more information.)


1 Answers

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.

like image 158
Giacomo Tesio Avatar answered Sep 23 '22 03:09

Giacomo Tesio