0

I'm unable to figure out the XPath syntax to add a second tagged vlan when using virt-install to provision a guest:

srv01:~$ sudo virt-install\
 --name=ds-controller01.iwc.ig24\
 --disk source.dev=/dev/vg_ig24.iwc.srv01_ssd/lv_ig24.iwc.ds-controller01_root\
 --graphics spice\
 --vcpu=2\
 --ram=2048\
 --os-type=debian10\
 --accelerate\
 --cdrom=/srv/iso/debian-11.iso\
 --network bridge=br0,model=virtio,virtualport_type=openvswitch,mac=$(newmac)\
 --xml './devices/interface/vlan[@trunk=yes]/tag/@id=100'\
 --xml './devices/interface/target/@dev=ds-controller01'

The domxml goal is this:

    <interface type='bridge'>
      <mac address='52:54:00:57:df:60'/>
      <source bridge='br0'/>
      <vlan trunk='yes'>
        <tag id='100'/>
        <tag id='200'/>
        <tag id='300'/>
      </vlan>
      <virtualport type='openvswitch'>
        <parameters interfaceid='23f46a9d-4abf-443e-bdea-6915b95c0042'/>
      </virtualport>
      <target dev='ds-controller01'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>

I've tried to add additional '--xml' for the vlan/trunk/tag, but it just over-wrote the first --xml statement.

1
  • According to the manual of vist-install, using multiple --xml arguments is allowed, so the problem is in your XPath expressions
    – Fravadona
    Commented Jul 5 at 9:15

1 Answer 1

0

Not really understanding XPath, I found two online XML to XPath converters, XPath Generator Online and XMLToolBox. I cobbled together their outputs I found this works:

srv01:~$ sudo virt-install\
 --name=ds-controller01.iwc.ig24\
 --disk source.dev=/dev/vg_ig24.iwc.srv01_ssd/lv_ig24.iwc.ds-controller01_root\
 --graphics spice\
 --vcpu=2\
 --ram=2048\
 --os-type=debian10\
 --accelerate\
 --cdrom=/srv/iso/debian-11.iso\
 --network bridge=br0,model=virtio,virtualport_type=openvswitch,mac=$(newmac)\
 --xml './devices/interface/vlan[@trunk=yes]/tag/@id=100'\
 --xml './devices/interface/vlan/tag[2]/@id=200' \
 --xml './devices/interface/vlan/tag[3]/@id=300' \
 --xml './devices/interface/target/@dev=ds-controller01'

What doesn't work, is including [@trunk=yes] in the subsequent tagging of vlan 200 & 300.

 --xml './devices/interface/vlan[@trunk=yes]/tag/@id=100'\
 --xml './devices/interface/vlan[@trunk=yes]/tag[2]/@id=200' \
 --xml './devices/interface/vlan[@trunk=yes]/tag[3]/@id=300' \

The result is that only vlan 300 gets included:

<interface type='bridge'>
  <mac address='52:54:00:9d:15:fd'/>
  <source bridge='br0'/>
  <vlan trunk='yes'>
    <tag id='300'/>
  </vlan>
  <virtualport type='openvswitch'>
    <parameters interfaceid='cedd5495-27b0-4e3c-a109-434f1db8dbc4'/>
  </virtualport>
  <target dev='ds-controller01'/>
  <model type='virtio'/>
  <alias name='net0'/>
  <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
</interface>

Not the answer you're looking for? Browse other questions tagged or ask your own question.