This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 986248 - Hot plugging a NIC fails, however a bogus successful message is thrown on the stdout.
Hot plugging a NIC fails, however a bogus successful message is thrown on the...
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt (Show other bugs)
7.0
Unspecified Linux
unspecified Severity unspecified
: rc
: ---
Assigned To: Libvirt Maintainers
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-19 06:06 EDT by Kashyap Chamarthy
Modified: 2013-07-20 07:54 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-07-19 10:48:36 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Kashyap Chamarthy 2013-07-19 06:06:36 EDT
Description 
-----------

Adding (& defining) a new libvirt network, and attempting to hot plug a
NIC fails silently. The command 'virsh attach-interface' throws a
message on stdout that the interface is added successfully, however the
just added NIC doesn't reflect inside the guest.


Version info
------------

Host: RHEL-7
Guest: Fedora19

  $ uname -r ; rpm -q qemu-kvm libvirt-daemon-kvm
  3.10.0-0.rc7.64.el7.x86_64
  qemu-kvm-1.5.1-2.el7.x86_64
  libvirt-daemon-kvm-1.1.0-2.el7.x86_64


Steps to reproduce
------------------

(1) Define a new libvirt NAT network:

  $ cat testnetw.xml
  <network connections='1'>
    <name>testnetw</name>
    <uuid>d0e9964a-f91a-40c0-b769-a609aee41bf2</uuid>
    <forward mode='nat'>
      <nat>
        <port start='1024' end='65535'/>
      </nat>
    </forward>
    <bridge name='virbr1' stp='on' delay='0' />
    <mac address='52:54:00:60:f8:6e'/>
    <ip address='192.169.142.1' netmask='255.255.255.0'>
      <dhcp>
        <range start='192.169.142.2' end='192.169.142.254' />
      </dhcp>
    </ip>
  </network>

(2) Define, and start it:

  $ virsh net-define testnetw.xml 
  Network testnetw defined from testnetw.xml

  $ virsh net-start testnetw
  Network testnetw started

(3) Dump the just defined network XML:

  $ virsh net-dumpxml testnetw
  <network>
    <name>testnetw</name>
    <uuid>d0e9964a-f91a-40c0-b769-a609aee41bf2</uuid>
    <forward mode='nat'>
      <nat>
        <port start='1024' end='65535'/>
      </nat>
    </forward>
    <bridge name='virbr1' stp='on' delay='0' />
    <mac address='52:54:00:60:f8:6e'/>
    <ip address='192.169.142.1' netmask='255.255.255.0'>
      <dhcp>
        <range start='192.169.142.2' end='192.169.142.254' />
      </dhcp>
    </ip>
  </network>

(4) List the networks and bridges:

  $ virsh net-list
   Name                 State      Autostart     Persistent
  ----------------------------------------------------------
   default              active     yes           yes
   testnetw             active     yes           yes

  $ brctl show
  bridge name     bridge id               STP enabled     interfaces
  br0             8000.441ea1767fe6       no              em1
  virbr0          8000.525400b91ad3       yes             virbr0-nic
                                                          vnet1
                                                          vnet2
  virbr1          8000.52540060f86e       yes             virbr1-nic

(5) Start a guest, list its interfaces

  $ virsh start fedostk

  $ virsh domiflist fedostk
  Interface  Type       Source     Model       MAC
  -------------------------------------------------------
  vnet1      bridge     virbr0     virtio      52:54:00:26:38:76

(6) Attach a NIC to the LIVE guest above, associating it to the new
    network (virbr1):

  $ virsh attach-interface --domain fedostk \
    --type bridge --source virbr1  --model  \
    virtio --mac 52:54:00:4e:72:6e --config
  Interface attached successfully


Actual results
--------------

Just attached new NIC doesn't reflect.

List the guest network interfaces again (note - just attached interface
doesn't reflcet):

  $ virsh domiflist fedostk
  Interface  Type       Source     Model       MAC
  -------------------------------------------------------
  vnet1      bridge     virbr0     virtio      52:54:00:26:38:76

List the bridges:

  $ brctl show
  bridge name     bridge id               STP enabled     interfaces
  br0             8000.441ea1767fe6       no              em1
  virbr0          8000.525400b91ad3       yes             virbr0-nic
                                                        vnet1
                                                        vnet2
  virbr1          8000.52540060f86e       yes             virbr1-nic

'grep' the live guest's XML for brdige interfaces (only one interface is
reflected):

  $ virsh dumpxml fedostk | egrep -i 'vnet|virbr1'
      <target dev='vnet1'/>

(Also, verify in the guest by listing interfaces)

Expected results
----------------

Newly hot plugged NIC should successfully reflect in the guest.
Comment 2 Kashyap Chamarthy 2013-07-19 06:17:30 EDT
Guest qemu CLI:

  $ tail /var/log/libvirt/qemu/fedostk.log 
  qemu: terminating on signal 15 from pid 63841
  2013-07-17 13:03:25.074+0000: shutting down
  2013-07-17 13:03:48.288+0000: starting up
  LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin /usr/libexec/qemu-kvm -name fedostk -S -machine pc-i440fx-rhel7.0.0,accel=kvm,usb=off -m 20480 -realtime mlock=off -smp 20,sockets=20,cores=1,threads=1 -uuid fe4a3ddc-6ad6-b54c-82b5-368f71ea1723 -nographic -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/fedostk.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/export/vmstore/fedostk-overlay1.qcow2,if=none,id=drive-virtio-disk0,format=qcow2,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -netdev tap,fd=23,id=hostnet0,vhost=on,vhostfd=25 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:26:38:76,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
  char device redirected to /dev/pts/3 (label charserial0)
  qemu: terminating on signal 15 from pid 63841
  2013-07-17 13:05:14.673+0000: shutting down
  2013-07-17 13:06:41.426+0000: starting up
  LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin /usr/libexec/qemu-kvm -name fedostk -S -machine pc-i440fx-rhel7.0.0,accel=kvm,usb=off -m 20480 -realtime mlock=off -smp 20,sockets=20,cores=1,threads=1 -uuid fe4a3ddc-6ad6-b54c-82b5-368f71ea1723 -nographic -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/fedostk.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/export/vmstore/fedostk-overlay1.qcow2,if=none,id=drive-virtio-disk0,format=qcow2,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -netdev tap,fd=23,id=hostnet0,vhost=on,vhostfd=25 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:26:38:76,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
  char device redirected to /dev/pts/3 (label charserial0)
Comment 3 Kashyap Chamarthy 2013-07-19 06:23:23 EDT
Host CPU model: Intel(R) Xeon(R) CPU E7- 4807  @ 1.87GHz

Guest XML:

  $ virsh dumpxml fedostk
  <domain type='kvm' id='70'>  
    <name>fedostk</name>
    <uuid>fe4a3ddc-6ad6-b54c-82b5-368f71ea1723</uuid>
    <memory unit='KiB'>20971520</memory>
    <currentMemory unit='KiB'>20971520</currentMemory>
    <vcpu placement='static'>20</vcpu>
    <resource>
      <partition>/machine</partition>
    </resource>
    <os>
      <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
      <boot dev='hd'/>
    </os>
    <features>
      <acpi/>
      <apic/>
      <pae/>
    </features>
    <clock offset='utc'/>
    <on_poweroff>destroy</on_poweroff>
    <on_reboot>restart</on_reboot>
    <on_crash>restart</on_crash>
    <devices>
      <emulator>/usr/libexec/qemu-kvm</emulator>
      <disk type='file' device='disk'>
        <driver name='qemu' type='qcow2' cache='none'/>
        <source file='/export/vmstore/fedostk-overlay1.qcow2'>
          <seclabel model='selinux' relabel='no'/>
        </source>
        <target dev='vda' bus='virtio'/>
        <alias name='virtio-disk0'/>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
      </disk>
      <controller type='usb' index='0'>
        <alias name='usb0'/>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
      </controller>
      <controller type='pci' index='0' model='pci-root'>
        <alias name='pci0'/>
      </controller>
      <interface type='bridge'>
        <mac address='52:54:00:26:38:76'/>
        <source bridge='virbr0'/>
        <target dev='vnet1'/>
        <model type='virtio'/>
        <alias name='net0'/>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
      </interface>
      <serial type='pty'>
        <source path='/dev/pts/3'/>
        <target port='0'/>
        <alias name='serial0'/>
      </serial>
      <console type='pty' tty='/dev/pts/3'>
        <source path='/dev/pts/3'/>
        <target type='serial' port='0'/>
        <alias name='serial0'/>
      </console>
      <input type='tablet' bus='usb'>
        <alias name='input0'/>
      </input>
      <memballoon model='virtio'>
        <alias name='balloon0'/>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
      </memballoon>
    </devices>
    <seclabel type='dynamic' model='selinux' relabel='yes'>
      <label>system_u:system_r:svirt_t:s0:c861,c877</label>
      <imagelabel>system_u:object_r:svirt_image_t:s0:c861,c877</imagelabel>
    </seclabel>
  </domain>
Comment 4 Jiri Denemark 2013-07-19 10:48:36 EDT
(In reply to Kashyap Chamarthy from comment #0)
> (6) Attach a NIC to the LIVE guest above, associating it to the new
>     network (virbr1):
> 
>   $ virsh attach-interface --domain fedostk \
>     --type bridge --source virbr1  --model  \
>     virtio --mac 52:54:00:4e:72:6e --config
>   Interface attached successfully

Oh, you're using --config, which means you're asking libvirt to attach the network interface to the domain configuration only (so that it will take effect when the domain is started next time). "virsh dumpxml --inactive fedostk" should contain the new interface. You need to specify --live (or nothing) to hotplug the device into a running domain. I'm closing this as not a bug. Feel free to reopen if it doesn't work using my suggestions.
Comment 5 Kashyap Chamarthy 2013-07-20 07:54:41 EDT
You're right.

For some reason on F19, with these versions:

  $ rpm -q libvirt-daemon-kvm qemu-kvm
  libvirt-daemon-kvm-1.0.6-3.fc19.x86_64
  qemu-kvm-1.5.1-1.fc19.x86_64

The interface seems to be added even when I provided --config. I (incorrectly)assumed that was the correct behavior.


I retried on a different F19 machine, indeed --config works as expected (take effect on next boot).

    $ virsh attach-interface --domain el7-testvm3 \
      --type bridge --source virbr1 --model virtio \
      --mac 52:54:00:3c:34:6f --config

    # Only one interface should be listed
    $ virsh domiflist el7-testvm3
    Interface  Type       Source     Model       MAC
    -------------------------------------------------------
    vnet3      bridge     br0        virtio      52:54:00:59:4e:29

    # Connect to the guest console
    $ virsh console el7-testvm3

    # Inside the guest
    $ init 0

    # Start the guest
    $ virsh start el7-testvm3
    
    $ virsh domiflist el7-testvm3
    Interface  Type       Source     Model       MAC
    -------------------------------------------------------
    vnet3      bridge     br0        virtio      52:54:00:59:4e:29
    vnet4      bridge     virbr1     virtio      52:54:00:3c:34:6f


Sorry for the noise.

Note You need to log in before you can comment on or make changes to this bug.