4

My VM (Ubuntu 12.04) has 2 network interfaces attached which is recognized as eth0 and eth1.

Now I want to change the cards to virtio to improve the performance, so I open VM settings and change both adapters' types to Paravirtualized Network (virtio-net)

But after rebooting the performance seems to be the same, not to say even much slower, and when I checked ifconfig output there's another virbr0 interface beside eth0 and eth1.

I thought that changing the type in VirtualBox will make eth0 and eth1 become a virtio adapter. This was later confirmed by a few pages I found on the internet. They said that just changing the adapter type is enough and the speed will be improved immediately. But in my case it isn't.

How to configure the adapters in order to make it work?

The configuration is like this. eth0 is a bridge to the external network. eth1 is a host-only adapter

$ 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)

I've ran lsmod | grep virt but no result is shown. insmod shows nothing like virtio_net either

$ insmod virt<tab><tab>
virtio_balloon  virtio_console  virtio_mmio     virtio-rng      virtual

The current kernel Linux vmdev 3.2.0-124-generic #167-Ubuntu SMP Fri Mar 3 15:26:21 UTC 2017 i686 i686 i386 GNU/Linux. Is there any options I need to enable the loading of virtio driver?

The file /etc/udev/rules.d/70-persistent-net.rules shows nothing related to virtio either, except in the comment when I regenerate the MAC address of the adapter

I've done a lot of tests with iperf and the results with Intel PRO/1000 adapter vary around 250-350Mbps while the results with virtio-net card always lie between 100-150Mbps, far below my expectations. So I'm switching back to e1000 card right now until a solution is found.

I've seen some possible related problems on the internet but no way to solve so far


Edit:

My project has updated to a new 64-bit 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) but the results are still the same. virtio is still much slower than Intel 1000

phuclv
  • 26,555
  • 15
  • 113
  • 235
  • The `virbr0` interface is not created by VirtualBox or the virtio-net driver. It’s probably the result of having libvirt installed. Also, I wouldn’t count on virtio-net making things faster. The VirtualBox implementation might just be crap. – Daniel B Jun 13 '17 at 06:50
  • @DanielB the virbr0 only appears after switching the adapter type to virtio-net – phuclv Jun 13 '17 at 06:53
  • Still, the virtio-net driver does not create those interfaces. I created a VirtualBox VM with Ubuntu 12.04. It if course does not have a `virbr0` bridge. libvirt is known to create it. – Daniel B Jun 13 '17 at 17:41

1 Answers1

0

Manual Chapter 6. Virtual networking:

The "Paravirtualized network adapter (virtio-net)" is special. If you select this, then VirtualBox does not virtualize common networking hardware (that is supported by common guest operating systems out of the box). Instead, VirtualBox then expects a special software interface for virtualized environments to be provided by the guest, thus avoiding the complexity of emulating networking hardware and improving network performance. Starting with version 3.1, VirtualBox provides support for the industry-standard "virtio" networking drivers, which are part of the open-source KVM project.

Seth
  • 9,000
  • 1
  • 19
  • 34
  • I've read that before when I came to know about virtio. I'm not seeing how they are related here. Can you elaborate? – phuclv Mar 17 '17 at 11:57
  • Well it straight up tells you that's it not meant to replace "common" network interfaces like eth0 and eth1 but instead will work as a special device. Hence it shows up as virbr0 and you will have to configure it separately. With Linux you will probably have a way to simply rename the device file in case you're just concerned about the name but I'd advice against that, as certain software might act funky because they expect a standard network interface. – Seth Mar 17 '17 at 12:00
  • that's what I'm asking. I want to enable and configure it. Right now it has some IP address that's not related to the host and can't be reached by the host or any other VMs – phuclv Mar 17 '17 at 13:14
  • But it's not what your question says. What your question says is that you want to turn eth0/eth1 into a virtio-net device. From what I can tell you would configure them like you would any other of your network interfaces just that the name would be different. Did you actually try to configure the interface? If so, what errors did you encounter or similar? You probably should rework your question to actually show what you know and already tried and what your actual goal is. – Seth Mar 17 '17 at 13:24
  • I have no idea about how virtio works and how to configure it. I just want to use them for my VM. Names are not important, but the network path must be exactly like defined. I thought that it's just a network adapter like any others, but with specific virtualization support. I have checked with lsmod but no module named virtio is loaded. – phuclv Mar 17 '17 at 13:52
  • Your question says that you have an interface `virbr0` that showed up. So have you tried to just configure that interface using the usual means? – Seth Mar 17 '17 at 14:00
  • As I said, I just thought that it's like a normal adapter so just plug in and use. But it turns out much more complex than I thought, out of the scope of my previous network understanding. I've digged through some documents but have no idea how to make it works – phuclv Mar 17 '17 at 14:11
  • So you didn't configure eht0 and eth1 yourself? Well it would really depend on what you need to do. You could possibly post it as an independent question. – Seth Mar 17 '17 at 17:04
  • I've configured those by myself because the it's very simple, just some changing in IP, Mac address or name. But this virbr0 is complelely different. I don't know where it connects to because there's no adapter exposed, and the remaining eth0 and eth1 still function normally – phuclv Mar 18 '17 at 01:18
  • If you actually included some output in your original question, you might get more helpful responses. As it is I don't have any reason to assume that `virbr0` would handle any different and with a Windows host I don't seem to able to replicate it. And as I said, you probably should post this as an independent question (including the current configuration) asking how to setup a virtio-net device in order to replicate your eth config. – Seth Mar 18 '17 at 09:19
  • I've intended to include it in the question, but then leave it as it's no help, it's just another new virbr0 beside eth0 and eth1. All the IPs, MACs and other information in the old didn't change – phuclv Mar 18 '17 at 16:35
  • @Seth The phrasing in the quoted paragraph is rather strange. Just like VMware’s vmxnet adapters, it will of course appear as a normal network adapter to the client OS. So it actually *is* “switching eth0 to virtio”. It’s even that way from the configuration perspective. – Daniel B Jun 13 '17 at 06:49