xmlvirtual-machinekvmlibvirtopenvswitch

How to add the VLAN information using virt-install to VM xml file?


I'm trying to automate virtual machine creation but I'm having troubles adding the VLAN tag to the xml file via virt-install.

sudo virt-install --name hosp10 --memory 16384 --vcpus 4 \
  --disk /var/lib/libvirt/images/cloud-full.qcow2,format=qcow2,cache=none,target=vda \
  --boot kernel=/var/lib/libvirt/images/full.vmlinuz,initrd=/var/lib/libvirt/images/full.initrd,kernel_args="root=/dev/vda" \
  --network bridge=br-mgmt,model=virtio,virtualport_type=openvswitch,mac=XX:XX:XX:XX:XX:XX

I'm looking to add to --network something like vlan_id=100 but seems such option doesn't exist. Is there a way to have xml generated like the following?

<interface type="bridge">
      <source bridge="ovs-internal"/>
      <target dev='ext01'/>
      <vlan>
        <tag id='100'/>
      </vlan>
      <model type="virtio"/>
      <virtualport type="openvswitch"/>
      <mac address='vv:vv:vv:vv:vv:vv' />
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>

Thanks in advance.


Solution

  • There doesn't seem to be a way to do that directly using virt-install, but why don't you configure the VLAN tag using Open vSwitch?

    # after running virt-install:
    ovs-vsctl set port ext01 tag=100