salt icon indicating copy to clipboard operation
salt copied to clipboard

Interface ordering in kvm.

Open oyvjel opened this issue 12 years ago • 4 comments

I try to provision a kvm-guest with 3 interfaces. virt.nic is correctly reflected in hypervisors pillar.items:

       triple:
            ----------
            eth0:
                ----------
                bridge:
                    xbr0
            eth1:
                ----------
                bridge:
                    virbr1
            eth2:
                ----------
                bridge:
                    virbr2

However the guest will reverse or randomize the bridge to interface order, assigning eth0 to virbr2. How can I force a match between pillar data and guest interfaces and make sure the external bridge xbr0 always ends up as eth0 in the guest?

oyvjel avatar Nov 06 '14 23:11 oyvjel

Thanks for reporting this; we'll look into the best way to handle this dynamic network device handling issue.

jfindlay avatar Nov 07 '14 17:11 jfindlay

@oyvjel are you using the virt runner here or what? I'm not super familiar with our KVM support, but if you could include more information, including your actual pillar data, the commands you are running, etc, that would be helpful.

basepi avatar Nov 11 '14 19:11 basepi

Sorry for late answer, have not had much time for this at the moment. I have tried both runner on the saltmaster and virt.init module targeting the kvm host with slightly different results. I also had to change seed.py from 2014.1.13 back to sometting like 2014.1.7 (there is an issue on this) Examples:

salt-run virt.init nictest 1 2048 salt://images/linux-inc.qcow2  seed=True install=True nic=triple 

Searches for hypervisor and installs and seeds salt. Key is accepted, host is not spun up, must be done manually.

salt kvm-01 virt.init nictest 1 2048 salt://images/linux-inc.qcow2 start=True seed=True install=True nic=triple

Installs and starts host nictest on hypervisor kvm-01. The host-key must be manually accepted, but this could be a consequence of my fix in seed.py

In both cases an xml for libvirt containing definitions for 3 interfaces is generated.

    <interface type='bridge'>
      <mac address='ac:de:48:26:c2:2d'/>
      <source bridge='virbr2'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <interface type='bridge'>
      <mac address='ac:de:48:0d:ee:b2'/>
      <source bridge='virbr1'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </interface>
    <interface type='bridge'>
      <mac address='ac:de:48:ac:df:d5'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </interface>

This matches my pillar/kvm_nics.sls, but the ethX name info is lost:

virt.nic:
  default:
    eth0:
      bridge: br0
      model: virtio
  dual:
    eth0:
      bridge: br0
    eth1:
      bridge: virbr1
  triple:
    eth0:
      bridge: br0
    eth1:
      bridge: virbr1
    eth2:
      bridge: virbr2

I have experimented with the ordering of the interfaces in the xml and this does not make any difference. Apparently changing names to force different lexical sorting of the interface names does not help. I can not figure out how libvirt/qemu passes information to the guest to establish a predictable assignment of host- to guest- interface.

Possible workarounds:

  1. Create guest with only 1 interface. This will force Linux to establish a relation between mac address and interface name in /etc/udev/rules.d/70-persistent-net.rules. Then add second device and so on. This will require a new method to (virt.)change/update a libvirt config in saltstack to automate.

2 Alternative: create a proper /etc/udev/rules.d/70-persistent-net.rules on seed or install.

This will be guest-OS specific, but I can not see support for seeding or installing windows anyway.

oyvjel avatar Nov 19 '14 12:11 oyvjel

@oyvjel did you intend to close this issue?

basepi avatar Nov 19 '14 18:11 basepi