qemu-kvm开启vmxnet3网卡驱动

背景

默认系统安装的包里面没有vmxnet3的网卡驱动,这个可以通过重新打包的方式把驱动打进去,同样的也可以开启其它更多的驱动
标准包为了稳定性方面不会把全部的功能都打进去

网卡支持查询

1
2
3
4
5
6
7
8
9
10
[root@lab4 qemu-kvm]#  /usr/libexec/qemu-kvm -net nic,model=?
Available NIC models for this configuration:
e1000
e1000e
igb
ne2k_isa
rtl8139
virtio-net-pci (aka virtio)
virtio-net-pci-non-transitional
virtio-net-pci-transitional

默认的只有这些网卡

默认开启的网卡

qemu默认configure后,默认是开启了全部的网卡的,我们看下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
[root@lab4 qemu-9.1.0]# ./build/qemu-system-x86_64  -net nic,model=?
Available NIC models for this configuration:
e1000
e1000-82544gc
e1000-82545em
e1000e
i82550
i82551
i82557a
i82557b
i82557c
i82558a
i82558b
i82559a
i82559b
i82559c
i82559er
i82562
i82801
igb
ne2k_isa
ne2k_pci
pcnet
rtl8139
tulip
virtio-net-pci (aka virtio)
virtio-net-pci-non-transitional
virtio-net-pci-transitional
vmxnet3

如果没有做控制的话,就会有这么多的网卡设备

打包选项调整

开启的选项
rpmbuild的时候抓取的参数

1
./configure --cc=clang --cxx=/bin/false --prefix=/usr --libdir=/usr/lib64 --datadir=/usr/share --sysconfdir=/etc --interp-prefix=/usr/qemu-%M --localstatedir=/var --docdir=/usr/share/doc --libexecdir=/usr/libexec '--extra-ldflags=-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now   -flto=thin' '--extra-cflags=-O2 -flto=thin -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS --config /usr/lib/rpm/redhat/redhat-hardened-clang.cfg -fstack-protector-strong   -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wno-string-plus-int' --with-pkgversion=qemu-kvm-9.1.0-15.el9.4.alma.1 --with-suffix=qemu-kvm --firmwarepath=/usr/share/qemu-firmware:/usr/share/ipxe/qemu:/usr/share/seavgabios:/usr/share/seabios --enable-trace-backends=dtrace --with-coroutine=ucontext --tls-priority=@QEMU,SYSTEM --audio-drv-list= --disable-alsa --disable-attr --disable-auth-pam --disable-avx2 --disable-avx512bw --disable-blkio --disable-block-drv-whitelist-in-tools --disable-bochs --disable-bpf --disable-brlapi --disable-bsd-user --disable-bzip2 --disable-cap-ng --disable-capstone --disable-cfi --disable-cfi-debug --disable-cloop --disable-cocoa --disable-coreaudio --disable-coroutine-pool --disable-crypto-afalg --disable-curl --disable-curses --disable-dbus-display --disable-debug-info --disable-debug-mutex --disable-debug-tcg --disable-dmg --disable-docs --disable-download --disable-dsound --disable-fdt --disable-fuse --disable-fuse-lseek --disable-gcrypt --disable-gettext --disable-gio --disable-glusterfs --disable-gnutls --disable-gtk --disable-guest-agent --disable-guest-agent-msi --disable-hvf --disable-iconv --disable-jack --disable-kvm --disable-l2tpv3 --disable-libdaxctl --disable-libdw --disable-libiscsi --disable-libnfs --disable-libpmem --disable-libssh --disable-libudev --disable-libusb --disable-libvduse --disable-linux-aio --disable-linux-io-uring --disable-linux-user --disable-lto --disable-lzfse --disable-lzo --disable-malloc-trim --disable-membarrier --disable-modules --disable-module-upgrades --disable-mpath --disable-multiprocess --disable-netmap --disable-nettle --disable-numa --disable-nvmm --disable-opengl --disable-oss --disable-pa --disable-parallels --disable-pie --disable-plugins --disable-qcow1 --disable-qed --disable-qga-vss --disable-qom-cast-debug --disable-rbd --disable-rdma --disable-replication --disable-rng-none --disable-safe-stack --disable-sanitizers --disable-sdl --disable-sdl-image --disable-seccomp --disable-selinux --disable-slirp --disable-slirp-smbd --disable-smartcard --disable-snappy --disable-sndio --disable-sparse --disable-spice --disable-spice-protocol --disable-strip --disable-system --disable-tcg --disable-tools --disable-tpm --disable-u2f --disable-usb-redir --disable-user --disable-vde --disable-vdi --disable-vduse-blk-export --disable-vhost-crypto --disable-vhost-kernel --disable-vhost-net --disable-vhost-user --disable-vhost-user-blk-server --disable-vhost-vdpa --disable-virglrenderer --disable-virtfs --disable-vnc --disable-vnc-jpeg --disable-png --disable-vnc-sasl --disable-vte --disable-vvfat --disable-werror --disable-whpx --disable-xen --disable-xen-pci-passthrough --disable-xkbcommon --disable-zstd --without-default-devices --with-devices-x86_64=x86_64-rh-devices --rhel-version=9 --target-list=x86_64-softmmu --block-drv-rw-whitelist=qcow2,raw,file,host_device,nbd,iscsi,rbd,blkdebug,luks,null-co,nvme,copy-on-read,throttle,compress,virtio-blk-vhost-vdpa,virtio-blk-vfio-pci,virtio-blk-vhost-user,io_uring,nvme-io_uring --block-drv-ro-whitelist=vdi,vmdk,vhdx,vpc,https --enable-attr --enable-blkio --enable-cap-ng --enable-capstone --enable-coroutine-pool --enable-curl --enable-dbus-display --enable-debug-info --enable-docs --enable-fdt=system --enable-gio --enable-gnutls --enable-guest-agent --enable-iconv --enable-kvm --enable-libpmem --enable-libusb --enable-libudev --enable-linux-aio --enable-linux-io-uring --enable-lzo --enable-malloc-trim --enable-modules --enable-mpath --enable-numa --enable-opengl --enable-pa --enable-pie --enable-rbd --enable-rdma --enable-seccomp --enable-selinux --enable-slirp --enable-snappy --enable-spice-protocol --enable-system --enable-tcg --enable-tools --enable-tpm --enable-usb-redir --enable-vdi --enable-vhost-kernel --enable-vhost-net --enable-vhost-user --enable-vhost-user-blk-server --enable-vhost-vdpa --enable-vnc --enable-png --enable-vnc-sasl --enable-werror --enable-xkbcommon --enable-zstd --enable-safe-stack

应该是这几个里面的
–without-default-devices –with-devices-x86_64=x86_64-rh-devices
关闭了默认的,然后自定义了设备

关闭了默认的,然后自定义了设备

1
2
configs/devices/x86_64-softmmu/x86_64-rh-devices.mak
configs/devices/x86_64-softmmu/default.mak

这个里面看到开启了

1
2
3
看到了几个选项
CONFIG_E1000E_PCI_EXPRESS=y
CONFIG_E1000_PCI=y

这个如果需要的话,自己添加下

1
2
3
[root@lab4 qemu-9.1.0bk]# grep "VMXNET3" -R *
hw/net/meson.build:system_ss.add(when: 'CONFIG_VMXNET3_PCI', if_true: files('net_tx_pkt.c', 'net_rx_pkt.c'))
hw/net/meson.build:system_ss.add(when: 'CONFIG_VMXNET3_PCI', if_true: files('vmxnet3.c'))

这个打包是以patch形式修改的

1
2
3
4
5
6
7
我们改下打包文件里面的话这个文件即可
打包是改这个文件
[root@lab4 qemu-kvm]# vim 0005-Enable-disable-devices-for-RHEL.patch
我们加在
+CONFIG_E1000E_PCI_EXPRESS=y
+CONFIG_E1000_PCI=y
+CONFIG_VMXNET3_PCI=y

这个以patch的形式,那么不用改源码文件了
然后重新打包rpm即可
重新安装包,以后,环境就支持vmxnet3了

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@lab4 qemu-kvm]#  /usr/libexec/qemu-kvm -net nic,model=?
qemu-kvm: warning: Machine type 'pc-i440fx-rhel7.6.0' is deprecated: machines from the previous RHEL major release are subject to deletion in the next RHEL major release
qemu-kvm: warning: CPU model qemu64-x86_64-cpu is deprecated -- use at least 'Nehalem' / 'Opteron_G4', or 'host' / 'max'
Available NIC models for this configuration:
e1000
e1000e
igb
ne2k_isa
rtl8139
virtio-net-pci (aka virtio)
virtio-net-pci-non-transitional
virtio-net-pci-transitional
vmxnet3

启动问题

1
2
3
[root@lab4 qemu-kvm]# virsh start win2k12r2
error: Failed to start domain 'win2k12r2'
error: internal error: QEMU unexpectedly closed the monitor (vm='win2k12r2'): 2025-07-17T08:21:29.017694Z qemu-kvm: -device {"driver":"vmxnet3","netdev":"hostnet0","id":"net0","mac":"52:54:00:d8:60:28","bus":"pci.1","addr":"0x0"}: failed to find romfile "efi-vmxnet3.rom"

启动还是有问题,提示failed to find romfile “efi-vmxnet3.rom”

这个是另外一个包里面的

1
2
3
4
5
6
7
8
9
10
[root@lab4 x86_64]# ls /usr/share/ipxe/qemu/
efi-e1000e.rom efi-e1000.rom efi-rtl8139.rom efi-virtio.rom pxe-e1000e.rom pxe-e1000.rom pxe-rtl8139.rom pxe-virtio.rom


[root@lab4 x86_64]# yum whatprovides /usr/share/ipxe/qemu/efi-e1000e.rom
Last metadata expiration check: 3:25:00 ago on Thu 17 Jul 2025 12:51:24 PM CST.
ipxe-roms-qemu-20200823-9.git4bd064de.el9_0.noarch : Network boot loader roms supported by QEMU, .rom format
Repo : @System
Matched from:
Filename : /usr/share/ipxe/qemu/efi-e1000e.rom

重新打包ipxe-roms-qemu

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
改下spec文件

# ROMS we want for QEMU with format PCIID:QEMUNAME
%global qemuroms \\\
8086100e:e1000 \\\
10ec8139:rtl8139 \\\
1af41000:virtio \\\
808610d3:e1000e \\\
15ad07b0:vmxnet3

%if 0%{?fedora}
# Fedora specific roms
%global qemuroms %{qemuroms} \\\
10222000:pcnet \\\
10ec8029:ne2k_pci \\\
80861209:eepro100 \\\
15ad07b0:vmxnet3
%endif

重新打包后

1
2
3
[root@lab4 ipxe-roms]# rpm -qpl /root/rpmbuild/RPMS/noarch/ipxe-roms-qemu-20200823-9.git4bd064de.el9.noarch.rpm|grep vmxnet
/usr/share/ipxe/qemu/efi-vmxnet3.rom
/usr/share/ipxe/qemu/pxe-vmxnet3.rom

可以看到就是这个包要安装下

再启动 kvm就不报错了

总结

上面的就完成了网卡的vmxnet3的支持,windows要使用这个驱动,我们还要处理下驱动问题,这个单独再写一篇


qemu-kvm开启vmxnet3网卡驱动
https://zphj1987.com/2025/07/17/qemu-kvm开启vmxnet3网卡驱动/
作者
zphj1987
发布于
2025年7月17日
许可协议