From fe1fd1039e92b50bcfab654e03ccf6a6950dbf10 Mon Sep 17 00:00:00 2001 From: Pranjal Vachaspati Date: Wed, 12 Jun 2024 19:23:09 +0000 Subject: [PATCH] Don't create MAC address for networks that don't allow it --- tool/nixvirt.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tool/nixvirt.py b/tool/nixvirt.py index 89b40cf..6c0c5b2 100644 --- a/tool/nixvirt.py +++ b/tool/nixvirt.py @@ -169,13 +169,14 @@ def _getDependents(self,obj): def _fixDefinitionETree(self,objid,specDefETree): addresses = specDefETree.xpath("/network/mac/@address") if len(addresses) == 0: - addr = self._assignMacAddress(objid,0) - mac = lxml.etree.Element("mac") - mac.attrib["address"] = addr - specDefETree.append(mac) - return specDefETree - else: - return None + fwdMode = specDefETree.xpath("/network/forward/@mode") + if fwdMode in [None, 'route', 'nat']: + addr = self._assignMacAddress(objid,0) + mac = lxml.etree.Element("mac") + mac.attrib["address"] = addr + specDefETree.append(mac) + return specDefETree + return None # https://libvirt.org/html/libvirt-libvirt-storage.html class PoolConnection(ObjectConnection):