Sample Header Ad - 728x90

QEMU: How to convert -net flags into -device & -netdev

3 votes
0 answers
1184 views
I'm trying to emulate Raspberry Pi via QEMU and the following works for me:
qemu-system-arm \
	-append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" \
	-boot c \
	-cpu arm1176 \
	-drive "file=2019-04-08-raspbian-stretch-lite.img,if=scsi,cache=none,discard=ignore,format=raw" \
	-kernel ./kernel-qemu-4.4.34-jessie \
	-m 256M \
	-machine type=versatilepb,accel=tcg \
	-name packer-qemu \
	-no-reboot \
	-vnc 127.0.0.1:4 \
	-net nic \
	-net user,id=user.0,hostfwd=tcp::5555-:22
and I'm able to both VNC in via 5904 and SSH in via 5555 (after starting SSHd via VNC). In other words network seems to be set up correctly. As I discovered [-net option has been deprecated](https://wiki.qemu.org/Documentation/Networking#The_legacy_-net_option) in favour of -device & -netdev, so I'd like to translate the above two last flags into "new QEMU". It appears that the new -device flag forces me to pick a driver, which isn't the case with -net. I like explicitness, but how do I know what is the default/implicit driver? Port forwarding in the following example doesn't seem to work anymore (I can't SSH in; connection times out):
qemu-system-arm \
	-append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" \
	-boot c \
	-cpu arm1176 \
	-drive "file=2019-04-08-raspbian-stretch-lite.img,if=scsi,cache=none,discard=ignore,format=raw" \
	-kernel ./kernel-qemu-4.4.34-jessie \
	-m 256M \
	-machine type=versatilepb,accel=tcg \
	-name packer-qemu \
	-no-reboot \
	-vnc 127.0.0.1:4 \
	-device e1000,netdev=user.0 \
	-netdev user,id=user.0,hostfwd=tcp::5555-:22
Am I just using wrong driver? ---- QEMU 3.1.0 (installed from Homebrew) (Host) MacOS 10.14.4
Asked by Radek Simko (131 rep)
Apr 17, 2019, 07:24 PM
Last activity: Jan 22, 2020, 07:39 AM