[libvirt] [BUG] When PLUG a bridge interface to an active VM, the generated LIVE and CONFIG mac address are different

Xu Yandong (Yandong Xu) xuyandong2 at huawei.com
Thu Aug 22 08:43:15 UTC 2019


Hi,

When plug a bridge interface to an active VM with both LIVE AND CONFIG flags,
libvirt generate different mac address to LIVE and CONFIG instance, so After
I reboot the VM, DHCP server doesn't assign the same IP address to the new
bridge interface.


Steps:
1. Having running VM
## virsh list
 Id   Name            State
-------------------------------
 1    centos_7.6_64   running

2. Prepare a bridge interface xml
## cat interface.xml
    <interface type='bridge'>
      <source bridge='br0-int'/>
      <virtualport type='openvswitch'>
      </virtualport>
      <model type='virtio'/>
      <target dev='ovsvnet4'/>
    </interface>

3. Plug interface with --live and --config
##virsh attach-device centos_7.6_64 interface.xml --config --live
Device attached successfully

4. Check LIVE XML
## cat /var/run/libvirt/qemu/centos_7.6_64.xml | grep ovsvnet4 -A 4 -B 6
      <interface type='bridge'>
        <mac address='52:54:00:23:7d:fb'/>
        <source bridge='br0-int'/>
        <virtualport type='openvswitch'>
          <parameters interfaceid='c9f07f2b-3888-4f25-bd80-f5ba04d07bf8'/>
        </virtualport>
        <target dev='ovsvnet4'/>
        <model type='virtio'/>
        <alias name='net0'/>
        <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
      </interface>

5. Check Config XML
## cat /etc/libvirt/qemu/centos_7.6_64.xml | grep ovsvnet4 -A 3 -B 6
    <interface type='bridge'>
      <mac address='52:54:00:bb:d4:53'/>
      <source bridge='br0-int'/>
      <virtualport type='openvswitch'>
        <parameters interfaceid='189234ea-878e-4e8a-9f63-f43fac50aebd'/>
      </virtualport>
      <target dev='ovsvnet4'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
    </interface>


The mac address and virtualport interfaceid does not match in LIVE and CONFIG XML.

This phenomenon was introduced by the commit:

commit 55ce65646348884656fd7bf3f109ebf8f7603494
Author: John Ferlan <jferlan at redhat.com>
Date:   Tue Jun 12 08:44:21 2018 -0400

    qemu: Use the correct vm def on cold attach

    https://bugzilla.redhat.com/show_bug.cgi?id=1559867

    When attaching a device to the domain we need to be sure
    to use the correct domain definition (vm->def or vm->newDef)
    when calling virDomainDeviceDefParse because the post parse
    processing algorithms that may assign an address for the
    device will use whatever domain definition was passed in.




More information about the libvir-list mailing list