
我的虛擬機 (Ubuntu 12.04) 連接了 2 個網路接口,被識別為eth0
和eth1
。
現在我想把卡換成virtio來提高性能,所以我打開虛擬機器設定並將兩個適配器的類型變更為半虛擬化網路(virtio-net)
但重新啟動後,性能似乎是相同的,更不用說更慢了,當我檢查輸出時,除了和 之外ifconfig
還有另一個virbr0
介面。eth0
eth1
我認為更改 VirtualBox 中的類型將eth0
成為eth1
virtio 適配器。後來我在網路上找到的一些頁面證實了這一點。他們說只要改變適配器類型就足夠了,速度就會立即提高。但就我而言,事實並非如此。
如何配置適配器才能使其運作?
配置是這樣的。eth0
是通往外部網路的橋樑。eth1
是一個僅主機適配器
$ ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:62:0d:bd
inet addr:10.184.130.70 Bcast:10.184.130.255 Mask:255.255.240.0
inet6 addr: fe80::a00:27ff:fe64:dbd/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:411321 errors:0 dropped:2 overruns:0 frame:0
TX packets:118875 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:298154310 (298.1 MB) TX bytes:65017532 (65.0 MB)
eth1 Link encap:Ethernet HWaddr 08:00:27:9d:6b:df
inet addr:172.17.0.6 Bcast:172.17.255.255 Mask:255.255.0.0
inet6 addr: fe80::a00:27ff:fe8d:6bdf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:12445 errors:0 dropped:0 overruns:0 frame:0
TX packets:13566 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1275663 (1.2 MB) TX bytes:8705940 (8.7 MB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8538 errors:0 dropped:0 overruns:0 frame:0
TX packets:8538 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2286738 (2.2 MB) TX bytes:2286738 (2.2 MB)
virbr0 Link encap:Ethernet HWaddr 76:ee:57:37:78:7c
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
我已經跑了lsmod | grep virt
,但沒有顯示結果。insmod
沒有顯示任何類似的virtio_net
東西
$ insmod virt<tab><tab>
virtio_balloon virtio_console virtio_mmio virtio-rng virtual
當前的內核Linux vmdev 3.2.0-124-generic #167-Ubuntu SMP Fri Mar 3 15:26:21 UTC 2017 i686 i686 i386 GNU/Linux
。我需要什麼選項來啟用 virtio 驅動程式的載入嗎?
該文件/etc/udev/rules.d/70-persistent-net.rules
也沒有顯示任何與 virtio 相關的內容,除了在我重新生成適配器的 MAC 位址時的註釋中
我做了很多測試iperf
,Intel PRO/1000 適配器的結果在 250-350Mbps 左右,而 virtio 網路卡的結果總是在 100-150Mbps 之間,遠低於我的預期。所以我現在就切換回 e1000 卡,直到我找到解決方案。
我在網路上看到了一些可能的相關問題,但到目前為止還沒有辦法解決
- https://getsatisfaction.cumulusnetworks.com/cumulus/topics/cumulus-vx-virtualbox-virtio-nic-slow
- https://bugs.launchpad.net/ubuntu/+source/qemu-kvm/+bug/1079212
- https://forums.virtualbox.org/viewtopic.php?f=7&t=26783
編輯:
我的專案已更新到新的 64 位元 Ubuntu 14.04 VM ( 3.13.0-86-generic #131-Ubuntu SMP Thu May 12 23:33:13 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
),但結果仍然相同。 virtio 仍然比 Intel 1000 慢很多
答案1
手動的第 6 章 虛擬網絡:
「半虛擬化網路介面卡(virtio-net)」比較特殊。如果選擇此選項,則 VirtualBox 不會虛擬化常見的網路硬體(常見的來賓作業系統開箱即用支援該硬體)。相反,VirtualBox 期望來賓為虛擬化環境提供特殊的軟體接口,從而避免模擬網路硬體並提高網路效能的複雜性。從版本 3.1 開始,VirtualBox 提供對業界標準「virtio」網路驅動程式的支持,該驅動程式是開源 KVM 專案的一部分。