KVM instance creation - juju/juju GitHub Wiki

With the new MAAS (1.8) devices API, to allocate an IP address for a container we need to know the MAC address of the container. To setup routing for the container we need to know the IP address before we create the container. So we need to know (i.e. generate) the MAC address before container creation.

In order to specify a MAC address for a KVM image we need to create a libvirt domain xml template to pass as the template argument to uvt-kvm.

References:

Ideally we'd like to specify as little as possible in the template and have the generated libvirt xml (i.e. the created image) be identical to what uvt-kvm would have created for us without the template. The only change being that the image will have a network interface with the MAC address we specify.

A "minimal" xml template, that uvt-kvm will use to create an instance functionally equivalent to our existing kvm instances, looks like this (memory and architecture still to be specified to uvt-kvm as command line parameters as before):

<domain type='kvm'>                                                         
  <name>new-machine</name>                                                  
  <vcpu placement='static'>1</vcpu>                                         
  <os>                                                                      
    <type>hvm</type>                                                        
  </os>                                                                     
  <features>                                                                
    <acpi/>                                                                 
    <apic/>                                                                 
    <pae/>                                                                  
  </features>                                                               
  <devices>                                                                 
    <controller type='usb' index='0'>                                       
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>                                                           
    <controller type='pci' index='0' model='pci-root'/>                     
    <serial type='stdio'>                                                   
      <target port='0'/>                                                    
    </serial>                                                               
    <console type='stdio'>                                                  
      <target type='serial' port='0'/>                                      
    </console>                                                              
    <input type='mouse' bus='ps2'/>                                         
    <input type='keyboard' bus='ps2'/>                                      
    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'>       
      <listen type='address' address='127.0.0.1'/>                          
    </graphics>                                                             
    <video>                                                                 
      <model type='cirrus' vram='9216' heads='1'/>                          
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>                                                                
    <interface type='network'>                                              
      <mac address='52:54:00:7a:ef:cf'/>                                    
      <model type='virtio'/>                                                
      <source network='maas'/>                                              
    </interface>                                                            
  </devices>                                                                
</domain>                                                                   
⚠️ **GitHub.com Fallback** ⚠️