# [solved] Non-functional network in kvm guest with virtio net

## PF4Public

Recently I have tried to install Gentoo in a KVM guest. Everything went fine except for the networking.

Whatever I tried, networking refused to work. DHCP could not obtain IP address. Manually setting IP and gateway didn't help either. With tcpdump at DHCP server I have confirmed that DHCP got the request and replied, but the virtio net didn't receive it. Its RX counters were not increased. TX counters on the contrary did increase.

Only when I have replaced virtio net with rtl nic, everything started working properly.

What is the problem with virtio net?

Interesting observation is that this KVM host also has a number of Debian guests with virtio net and those have absolutely no problem with it. Thus I suppose that it could be some kernel configuration option which allows virtio net receiving packets?

This is weird anyway...Last edited by PF4Public on Tue Aug 27, 2019 11:39 pm; edited 1 time in total

----------

## mike155

1) Please show us how you start QEMU/KVM (the parameters you use to start QEMU/KVM).

2) Please post the kernel config of the guest using wgetpaste.

----------

## PF4Public

Hi, mike155

I'm actually using libvirt. Here is the config of this particular VM: https://bpaste.net/show/WOCD

Kernel config is here: http://dpaste.com/3XK54V4

----------

## NeddySeagoon

PF4Public,

This looks good.

```
    <interface type='bridge'>

      <mac address='52:54:00:db:48:91'/>

      <source bridge='br0'/>

      <model type='rtl8139'/>

      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>

    </interface>
```

but that's with rtl8139 emulated hardware, not virtio.

Your kernel looks OK to me too.

-- edit --

How is br0 configured on your host?

----------

## mike155

I agree with NeddySeagoon.

It should probably look like:

```
<interface type='bridge'>

    <source bridge='br0'/>

    <mac address='52:54:00:db:48:91'/>

    <model type='virtio'/> 

 </interface>
```

----------

## PF4Public

 *mike155 wrote:*   

> I agree with NeddySeagoon.
> 
> It should probably look like:
> 
> ```
> ...

 

Ofcourse it should, but like I've said, it didn't work, so I temporarily put realtek there

----------

## NeddySeagoon

PF4Public,

br0 on the host?

----------

## PF4Public

Host has eth0 and eth1, which are bonded and then bridged with tap0:

```
auto bond0

iface bond0 inet manual

    bond_mode 802.3ad

    bond_miimon 100

    bond_downdelay 200

    bond_updelay 200

    slaves eth0 eth1

auto br0

iface br0 inet static

   address 192.168.100.252

   broadcast 192.168.100.255

   netmask 255.255.255.0

   gateway 192.168.100.253

   dns-search *my-local-domain*

   dns-nameservers 192.168.100.253 192.168.100.254

   pre-up ip tuntap add dev tap0 mode tap user root

   pre-up ip link set tap0 up

   bridge_ports bond0 tap0

   bridge_stp off

   bridge_maxwait 0

   bridge_fd      0

   post-down ip link set tap0 down

   post-down ip tuntap del dev tap0 mode tap

```

----------

## NeddySeagoon

PF4Public,

How do you stop eth0 and eth1 being brought up before they are donated to the bridge?

----------

## PF4Public

Turns out, virtio net needs CONFIG_PCI_MSI=y for properly functioning

 *NeddySeagoon wrote:*   

> PF4Public,
> 
> How do you stop eth0 and eth1 being brought up before they are donated to the bridge?

 

Honestly saying I do not remember. I've configured this host many-many years ago and it runs ever since. All I do is keeping it updated.

I can speculate that it is because eth0 and eth1 are not marked with auto; and bond0 is also manual

----------

