add support for boot 'network' from a vagrant public_network

when use a public_network in vagrant, this is how libvirt domain xml looks like (notice that the interface type is 'direct'):

    <interface type="direct">
      <mac address="08:00:27:00:00:01"/>
      <source dev="br-rpi" mode="bridge"/>
      <model type="virtio"/>
      <boot order="2"/> <!-- this boot xml node will be inserted with this commit -->
      <address type="pci" domain="0x0000" bus="0x00" slot="0x05" function="0x0"/>
    </interface>
This commit is contained in:
Rui Lopes
2021-05-26 07:59:47 +01:00
parent 7ce85f2216
commit dba31833a4

View File

@@ -86,9 +86,13 @@ module VagrantPlugins
def search_network(nets, xml)
str = '/domain/devices/interface'
str += "[(@type='network' or @type='udp' or @type='bridge')"
str += "[(@type='network' or @type='udp' or @type='bridge' or @type='direct')"
unless nets.empty?
str += " and source[@network='#{nets.first['network']}']"
net = nets.first
network = net['network']
dev = net['dev']
str += " and source[@network='#{network}']" if network
str += " and source[@dev='#{dev}']" if dev
end
str += ']'
@logger.debug(str)