diff --git a/virttest/libvirt_xml/accessors.py b/virttest/libvirt_xml/accessors.py index 768d7192e9..43367f2f50 100644 --- a/virttest/libvirt_xml/accessors.py +++ b/virttest/libvirt_xml/accessors.py @@ -786,7 +786,12 @@ def __call__(self, value): # Allow other classes to generate parent structure parent = self.xmltreefile().find(self.parent_xpath) if parent is None: - raise xcepts.LibvirtXMLNotFoundError + # Create parent xpath if not exists + self.xmltreefile().create_by_xpath(self.parent_xpath) + parent = self.xmltreefile().find(self.parent_xpath) + if parent is None: + raise xcepts.LibvirtXMLNotFoundError( + 'Parent xpath %s not found.' % self.parent_xpath) # Remove existing by calling accessor method, allowing # any "untouchable" or "filtered" elements (by marshal) # to be ignored and left as-is.