Bug 1254044

Summary: Libvirt uses incorrect default network card model for PPC64 guests
Product: Red Hat Enterprise Linux 7 Reporter: Dan Zheng <dzheng>
Component: libvirtAssignee: Andrea Bolognani <abologna>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.2CC: dyuan, gklein, gsun, hannsj_uhl, mzhan, ngu, pkrempa, rbalakri, tlavigne, zhwang
Target Milestone: rc   
Target Release: ---   
Hardware: ppc64le   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.17-9.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 06:51:26 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1201513, 1277183, 1277184    

Description Dan Zheng 2015-08-17 02:01:12 UTC
Description of problem:
'rtl8139' is not supported by qemu on PPC, but it is treated as default value when attaching interface on PPC. This is unreasonable. We should select a new model that supported by qemu on PPC to act as the default value for attaching an interface.


With a running guest, do hotplug an interface to the domain

# virsh list --all
 Id    Name                           State
----------------------------------------------------
 5     dz2                            running

# virsh attach-interface dz2 --type bridge --source virbr0
error: Failed to attach interface
error: internal error: unable to execute QEMU command 'device_add': 'rtl8139' is not a valid device model name

Comment 2 Andrea Bolognani 2015-08-31 12:53:55 UTC
A patch has been proposed upstream:

  https://www.redhat.com/archives/libvir-list/2015-August/msg01036.html

Comment 3 Andrea Bolognani 2015-09-10 09:53:47 UTC
The bug has been fixed upstream.

commit 75036c69df7a64f97f3716396f34f78de027f38b
Author: Andrea Bolognani <abologna>
Date:   Mon Sep 7 08:51:00 2015 +0200

    qemu: Try several network devices when looking for a default
    
    Up until now, the default has been rtl8139, but no check was in
    place to make sure that device was actually available.
    
    Now we try rtl8139, e1000 and virtio-net in turn, checking for
    availability before using any of them: this means we have a much
    better chance for the guest to be able to boot.

v1.2.19-44-g75036c6

Comment 6 Dan Zheng 2015-09-14 10:19:04 UTC
Test on below packages:
qemu-kvm-rhev-2.3.0-22.el7.ppc64le
kernel-3.10.0-306.0.1.el7.ppc64le
libvirt-1.2.17-8.el7+abologna+bz1254044.ppc64le
Guest: kernel-3.10.0-313.el7.ppc64le

Below scenaris are tested.
1. attach one interface with invalid model   
Pass.

# virsh attach-interface d1 --type bridge --source virbr0 --model kkk
error: Failed to attach interface
error: internal error: unable to execute QEMU command 'device_add': 'kkk' is not a valid device model name

2. attach two interfaces, one with default model and --target, the other with specified model
Pass.

#  virsh attach-interface d1 --type bridge --source virbr0 --target dznet1
Interface attached successfully

    <interface type='bridge'>
      <mac address='52:54:00:20:f2:93'/>
      <source bridge='virbr0'/>
      <target dev='dznet1'/>
      <model type='virtio'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </interface>


# virsh attach-interface d1 --type bridge --source virbr0 --model virtio --target dznet2
    <interface type='bridge'>
      <mac address='52:54:00:47:4a:3f'/>
      <source bridge='virbr0'/>
      <target dev='dznet2'/>
      <model type='virtio'/>
      <alias name='net2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </interface>

In guest,
# dhclient enp0s6
# dhclient enp0s5
# ifconfig
enp0s5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.122.207  netmask 255.255.255.0  broadcast 192.168.122.255
        inet6 fe80::5054:ff:fe20:f293  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:20:f2:93  txqueuelen 1000  (Ethernet)
        RX packets 159  bytes 10288 (10.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 1308 (1.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.122.251  netmask 255.255.255.0  broadcast 192.168.122.255
        inet6 fe80::5054:ff:fe47:4a3f  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:47:4a:3f  txqueuelen 1000  (Ethernet)
        RX packets 66  bytes 4756 (4.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 11  bytes 1870 (1.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
# lspci
...
00:05.0 Ethernet controller: Red Hat, Inc Virtio network device
00:06.0 Ethernet controller: Red Hat, Inc Virtio network device

In host, both ssh works.
ssh root.122.251
ssh root.122.207


3. Detach one interface w/o --mac when there are two network interfaces already
Pass.

# virsh detach-interface d1 --type bridge
error: Domain has 2 interfaces. Please specify which one to detach using --mac

# virsh detach-interface d1 --type bridge --mac 52:54:00:20:f2:93
Interface detached successfully

XML is updated.


4. test --type network without --model
Pass.

# virsh attach-interface d1 --type network --target dznet3 --source default
Interface attached successfully

  <interface type='network'>
      <mac address='52:54:00:9f:7c:ea'/>
      <source network='default' bridge='virbr0'/>
      <target dev='dznet3'/>
      <model type='virtio'/>
      <alias name='net4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </interface>
# lspci
...
00:06.0 Ethernet controller: Red Hat, Inc Virtio network device
00:07.0 Ethernet controller: Red Hat, Inc Virtio network device
00:08.0 Ethernet controller: Red Hat, Inc Virtio network device

enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.122.42  netmask 255.255.255.0  broadcast 192.168.122.255
        inet6 fe80::5054:ff:fe9f:7cea  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:9f:7c:ea  txqueuelen 1000  (Ethernet)
        RX packets 100  bytes 8832 (8.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 1716 (1.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

5. attach one with --current, then detach one with --live
Pass.

# virsh attach-interface d1 --type bridge --source virbr0 --current
Interface attached sucocessfully 
    <interface type='bridge'>
      <mac address='52:54:00:47:4a:3f'/>
      <source bridge='virbr0'/>
      <target dev='dznet5'/>
      <model type='virtio'/>
      <alias name='net6'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </interface>
# virsh detach-interface d1 --type bridge  --live --mac 52:54:00:47:4a:3f
Interface detached successfully

XML is updated.

6.attach with --persistent, then destroy with --config
Pass.

# virsh attach-interface d1 --type bridge  --source virbr0  --persistent
Interface attached sucocessfully

# virsh dumpxml d1 | grep interface
   <interface type='bridge'>
      <mac address='52:54:00:85:57:0e'/>
      <source bridge='virbr0'/>
      <target dev='vnet1'/>
      <model type='virtio'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    </interface>

# virsh detach-interface d1 --type bridge   --config
Interface detached successfully

XML is not updated.

Guest destroy, then start.
XML is updated.

Comment 7 Andrea Bolognani 2015-09-14 11:29:25 UTC
Thanks Dan for testing this :)

Comment 9 Dan Zheng 2015-09-17 02:35:24 UTC
Test with below packages:
kernel-3.10.0-316.el7.ppc64le
qemu-kvm-rhev-2.3.0-23.el7.ppc64le
libvirt-1.2.17-9.el7.ppc64le
Guest kernel-3.10.0-313.el7.ppc64le

Below tests are executed:
0. Guest starts running with below interface only.
    <interface type='network'>
      <mac address='52:54:00:c4:e7:28'/>
      <source network='default' bridge='virbr0'/>
      <target dev='vnet0'/>
      <model type='spapr-vlan'/>
      <alias name='net0'/>
      <address type='spapr-vio' reg='0x2000'/>
    </interface>

1. attach one interface with invalid model   
Pass.

# virsh attach-interface d1 --type bridge --source virbr0 --model kkk
error: Failed to attach interface
error: internal error: unable to execute QEMU command 'device_add': 'kkk' is not a valid device model name

2. attach two interfaces, one with default model and --target, the other with specified model
Pass.

#  virsh attach-interface d1 --type bridge --source virbr0 --target dznet1
Interface attached successfully

    <interface type='bridge'>
      <mac address='52:54:00:2a:de:6f'/>
      <source bridge='virbr0'/>
      <target dev='dznet1'/>
      <model type='virtio'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </interface>



# virsh attach-interface d1 --type bridge --source virbr0 --model virtio --target dznet2
    <interface type='bridge'>
      <mac address='52:54:00:7f:74:05'/>
      <source bridge='virbr0'/>
      <target dev='dznet2'/>
      <model type='virtio'/>
      <alias name='net2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </interface>

In guest,
# dhclient enp0s6
# dhclient enp0s5
# ifconfig
enp0s5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.122.85  netmask 255.255.255.0  broadcast 192.168.122.255
        inet6 fe80::5054:ff:fe2a:de6f  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:2a:de:6f  txqueuelen 1000  (Ethernet)
...

enp0s6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.122.251  netmask 255.255.255.0  broadcast 192.168.122.255
        inet6 fe80::5054:ff:fe7f:7405  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:7f:74:05  txqueuelen 1000  (Ethernet)
...

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.122.194  netmask 255.255.255.0  broadcast 192.168.122.255
        inet6 fe80::5054:ff:fec4:e728  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:c4:e7:28  txqueuelen 1000  (Ethernet)
...

# lspci
...
00:05.0 Ethernet controller: Red Hat, Inc Virtio network device
00:06.0 Ethernet controller: Red Hat, Inc Virtio network device

In host, both ssh work.
ssh root.122.251
ssh root.122.85


3. Detach one interface w/o --mac when there are two network interfaces already
Pass.

# virsh detach-interface d1 --type bridge
error: Domain has 2 interfaces. Please specify which one to detach using --mac

# virsh detach-interface d1 --type bridge --mac 52:54:00:7f:74:05
Interface detached successfully

XML is updated.


4. test --type network without --model
Pass.

# virsh attach-interface d1 --type network --target dznet3 --source default
Interface attached successfully

  <interface type='network'>
      <mac address='52:54:00:25:14:8e'/>
      <source network='default' bridge='virbr0'/>
      <target dev='dznet3'/>
      <model type='virtio'/>
      <alias name='net2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </interface>

# lspci
...
00:07.0 Ethernet controller: Red Hat, Inc Virtio network device


enp0s7: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.122.207  netmask 255.255.255.0  broadcast 192.168.122.255
        inet6 fe80::5054:ff:fe25:148e  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:25:14:8e  txqueuelen 1000  (Ethernet)


5. attach one with --current, then detach one with --live
Pass.

# virsh attach-interface d1 --type bridge --source virbr0 --current
Interface attached sucocessfully 
 <interface type='bridge'>
      <mac address='52:54:00:21:7a:49'/>
      <source bridge='virbr0'/>
      <target dev='vnet1'/>
      <model type='virtio'/>
      <alias name='net3'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </interface>

# virsh detach-interface d1 --type bridge  --live --mac 52:54:00:47:4a:3f
Interface detached successfully

XML is updated.

6.attach with --persistent, then destroy with --config
Pass.

# virsh attach-interface d1 --type bridge  --source virbr0  --persistent
Interface attached sucocessfully

# virsh dumpxml d1 | grep interface
    <interface type='bridge'>
      <mac address='52:54:00:1e:da:85'/>
      <source bridge='virbr0'/>
      <target dev='vnet1'/>
      <model type='virtio'/>
      <alias name='net3'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </interface>


# virsh detach-interface d1 --type bridge   --config
Interface detached successfully

XML is not updated that 'vnet1' section still exists.

Guest destroy, then start.
XML is updated that only 'net0' interface section exists now.

Comment 11 errata-xmlrpc 2015-11-19 06:51:26 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2202.html