USB 以太网设备在虚拟机中不工作

USB 以太网设备在虚拟机中不工作

我在让 USB 以太网设备在 qemu-kvm/libvirt 虚拟机中工作时遇到问题。

问题是,即使来宾操作系统正常地识别 USB 设备,它也无法安装它。来宾上的 lsusb 显示设备,但来宾 dmesg 日志显示以下错误:

usb 1-5 can't set config #1, error -32

查看主机上的日志,当 libvirt 强制释放设备时,主机上的某些进程似乎会重新获取设备。以下是首次连接卡时来自主机的 dmesg 日志:

[    1.353053] usb 1-2: new high-speed USB device number 3 using ehci-pci
[    1.432153] systemd-udevd[297]: renamed network interface eth0 to enp8s0
[    1.468455] usb 1-2: config 1 has an invalid interface number: 4 but max is 2
[    1.468460] usb 1-2: config 1 has an invalid interface number: 5 but max is 2
[    1.468455] usb 1-2: config 1 has an invalid interface number: 4 but max is 2
[    1.468460] usb 1-2: config 1 has an invalid interface number: 5 but max is 2
[    1.468462] usb 1-2: config 1 has an invalid interface number: 5 but max is 2
[    1.468465] usb 1-2: config 1 has no interface number 1
[    1.468468] usb 1-2: config 1 has no interface number 2
[    1.469951] usb 1-2: New USB device found, idVendor=1410, idProduct=b008
[    1.469955] usb 1-2: New USB device strings: Mfr=4, Product=3, SerialNumber=5
[    1.469958] usb 1-2: Product: Novatel Wireless 4G
[    1.469960] usb 1-2: Manufacturer: Novatel Wireless Inc.
[    1.469963] usb 1-2: SerialNumber: 990000945171911
[    1.473271] hid-generic 0003:1410:B008.0001: hiddev0,hidraw0: USB HID v1.10 Device [Novatel Wireless Inc. Novatel Wireless 4G] on usb-0000:00:1d.7-2/input0

当我尝试在虚拟机中安装设备时(再次从主机记录):

[   92.555534] cdc_ether 1-2:1.4 enp0s29f7u2i4: unregister 'cdc_ether' usb-0000:00:1d.7-2, CDC Ethernet Device
[   92.673039] usb 1-2: reset high-speed USB device number 3 using ehci-pci
[   92.789881] cdc_ether 1-2:1.4 eth0: register 'cdc_ether' at usb-0000:00:1d.7-2, CDC Ethernet Device, 00:15:ff:51:71:90
[   92.814159] systemd-udevd[3480]: renamed network interface eth0 to enp0s29f7u2i4
[   93.321758] cdc_ether 1-2:1.4 enp0s29f7u2i4: unregister 'cdc_ether' usb-0000:00:1d.7-2, CDC Ethernet Device
[   93.442035] usb 1-2: reset high-speed USB device number 3 using ehci-pci
[   93.558723] cdc_ether 1-2:1.4 eth0: register 'cdc_ether' at usb-0000:00:1d.7-2, CDC Ethernet Device, 00:15:ff:51:71:90
[   93.582179] systemd-udevd[3480]: renamed network interface eth0 to enp0s29f7u2i4
[   93.673779] cdc_ether 1-2:1.4 enp0s29f7u2i4: unregister 'cdc_ether' usb-0000:00:1d.7-2, CDC Ethernet Device
[   93.791043] usb 1-2: reset high-speed USB device number 3 using ehci-pci
[   93.907742] cdc_ether 1-2:1.4 eth0: register 'cdc_ether' at usb-0000:00:1d.7-2, CDC Ethernet Device, 00:15:ff:51:71:90
[   93.927194] systemd-udevd[3480]: renamed network interface eth0 to enp0s29f7u2i4
[   94.007311] usb 1-2: usbfs: interface 4 claimed by cdc_ether while 'qemu-kvm' sets config #1

主机操作系统为CentOS 7,虚拟机操作系统为Ubuntu 14.04。两者都有可用于各自包管理器的最新版本的内核。

我尝试过的另一个 USB 以太网卡可以工作,但它使用不同的驱动程序:“rndis_host”,并且通常看起来安装得更干净:

[  875.825026] usb 1-2: new high-speed USB device number 5 using ehci-pci
[  875.940297] usb 1-2: New USB device found, idVendor=1410, idProduct=b009
[  875.940302] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  875.940305] usb 1-2: Product: MiFi 5792
[  875.940308] usb 1-2: Manufacturer: Novatel Wireless
[  875.940310] usb 1-2: SerialNumber: 0123456789ABCDEF
[  875.987211] rndis_host 1-2:1.0 eth0: register 'rndis_host' at usb-0000:00:1d.7-2, RNDIS device, 00:15:ff:21:57:30
[  875.987255] usbcore: registered new interface driver rndis_host
[  876.010204] systemd-udevd[4636]: renamed network interface eth0 to enp0s29f7u2

当我尝试在虚拟机中安装设备时(再次从主机记录):

[ 2017.809111] rndis_host 1-2:1.0 enp0s29f7u2: unregister 'rndis_host' usb-0000:00:1d.7-2, RNDIS device
[ 2018.095036] usb 1-2: reset high-speed USB device number 5 using ehci-pci
[ 2018.439031] usb 1-2: reset high-speed USB device number 5 using ehci-pci

我在主机和来宾上运行最新版本的 NetworkManager 和 usb_modeswitch。我已在 sysconfig 中关闭主机上的 USB 网络,因此当我连接设备时,主机上不会启动网络接口。

有什么调试技巧可以找到在 libvirt 释放设备后尝试重新锁定设备的进程吗?

相关内容