Fix bug in VM network list with SR-IOV

This commit is contained in:
Joshua Boniface 2021-07-05 15:14:01 -04:00
parent 37cd278bc2
commit 54f82a3ea0
1 changed files with 8 additions and 1 deletions

View File

@ -713,7 +713,14 @@ def vm_networks_get(config, vm):
for interface in parsed_xml.devices.find('interface'):
mac_address = interface.mac.attrib.get('address')
model = interface.model.attrib.get('type')
network = re.match(r'[vm]*br([0-9a-z]+)', interface.source.attrib.get('bridge')).group(1)
interface_type = interface.attrib.get('type')
if interface_type == 'bridge':
network = re.search(r'[vm]*br([0-9a-z]+)', interface.source.attrib.get('bridge')).group(1)
elif interface_type == 'direct':
network = 'macvtap:{}'.format(interface.source.attrib.get('dev'))
elif interface_type == 'hostdev':
network = 'hostdev:{}'.format(interface.source.attrib.get('dev'))
network_data.append((network, mac_address, model))
return True, network_data