QEMU -netdev option

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
PeterX
Member
Member
Posts: 590
Joined: Fri Nov 22, 2019 5:46 am

QEMU -netdev option

Post by PeterX »

Anyone can tell me how to use the -netdev option with QEMU, if you don't mind?
I don't know about tap or bridge or any other network stuff that the "--help" option mentions. The wikipage didn't mention -netdev at all. It seems to be a newer replacement for -net.

Greetings
Peter
0b1
Member
Member
Posts: 35
Joined: Sun Feb 04, 2018 8:04 pm

Re: QEMU -netdev option

Post by 0b1 »

-net allows you to specify the network card and its settings.
-netdev allow you to specify more general settings about that card, particularly in how it interacts with the underlying operating system.
The tun/tap stuff is important, because it controls how your card can communicate on the real network. I don't have a working network stack yet, but my QEMU settings look like this.

Code: Select all

REM Nics I need to emulate are ne2k_pci, e1000, virtio
SET NIC1=-net nic,netdev=mynet1,model=ne2k_pci,macaddr=AA:BB:CC:DD:EE:FF 
SET NETDEV1=-netdev type=user,id=mynet1,restrict=no
SET LOGNET1=-object filter-dump,id=f1,netdev=mynet0,file=%LOGDIR%\qemu-net0.pcap

SET NIC2=-net nic,netdev=mynet2,model=e1000,macaddr=AA:BB:CC:DD:EE:FE
SET NETDEV2=-netdev type=user,id=mynet2,restrict=no
SET LOGNET2=-object filter-dump,id=f2,netdev=mynet1,file=%LOGDIR%\qemu-net1.pcap

SET SYSLOG=-D %LOGDIR%/qemu/systemlog.txt
SET TRACE=-trace enable=ide*
SET IDEDISK=-drive file=%BINDIR%\bootable.raw,format=raw,if=ide
REM -monitor stdio  REM lets you see monitor inside the command prompt so you can scroll to that which is invisible in the native monitor 

SET QEMUCONFIG= %IDEDISK% -rtc base=localtime -cpu qemu64,+pdpe1gb -m 256M -smp 4 %NIC1% %NIC2% %NETDEV1% %NETDEV2% %NOTRACE%

REM The calling script launches qemu with %QEMUCONFIG% made up of all the above.


REM stuff I'm not using right now.
REM SATA: -M q35
REM logging %SYSLOG% %TRACE%
REM SET NVMEDISK=-device nvme,drive=nvme0,serial=deadbeaf1,num_queues=8 -drive file=%BINDIR%\bootable.raw,if=none,id=nvme0
@REM (extra for above config) %NIC1% %NIC2% %NETDEV1% %NETDEV2% %LOGNET1% 

(ignore the NOTRACE variable - it resolves to an empty string. I just prefixed with NO to effectively comment out tracing)
Code or code not. There is no try.
Post Reply