Mark Wu has posted comments on this change. Change subject: Improve dom xml gereration ......................................................................
Patch Set 3: (3 inline comments) @Vinzenz, we already have test cases for libvirtvm xml generation. Please see tests/libvirtvmTests.py .................................................... File vdsm/libvirtvm.py Line 552: class XMLElem(object): Line 553: Line 554: def __init__(self, tagName, text=None, attrs={}): Line 555: self.doc = xml.dom.minidom.Document() Line 556: self.elem = self.doc.createElement(tagName) When we built libvirt xml definition for a vm, we just use the dom object to convert vm's conf dict into xml string. The operations we need are just creating new element, adding attributes and append sub-element. Actually, we already used multiple Document object. Please see the code of libvirtVmDevice's getXML function. So I think we don't need make sure all elements are owned by one document. How do you think of it? Line 557: self.setAttrs(attrs) Line 558: if text is not None: Line 559: self.addTextNode(text) Line 560: Line 595: self.log = log Line 596: Line 597: self.doc = xml.dom.minidom.Document() Line 598: domType = ('kvm' if utils.tobool(self.conf.get('kvmEnable', 'true')) Line 599: else 'qemu') Done Line 600: self.dom = XMLElem('domain', attrs={'type': domType}) Line 601: self.doc.appendChild(self.dom) Line 602: Line 603: self.dom.addChild('name', text=self.conf['vmName']) Line 595: self.log = log Line 596: Line 597: self.doc = xml.dom.minidom.Document() Line 598: domType = ('kvm' if utils.tobool(self.conf.get('kvmEnable', 'true')) Line 599: else 'qemu') Done Line 600: self.dom = XMLElem('domain', attrs={'type': domType}) Line 601: self.doc.appendChild(self.dom) Line 602: Line 603: self.dom.addChild('name', text=self.conf['vmName']) -- To view, visit http://gerrit.ovirt.org/10054 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib936740fcbeeee551e13abfed7fd91f2a159e351 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Mark Wu <wu...@linux.vnet.ibm.com> Gerrit-Reviewer: Mark Wu <wu...@linux.vnet.ibm.com> Gerrit-Reviewer: ShaoHe Feng <shao...@linux.vnet.ibm.com> Gerrit-Reviewer: Vinzenz Feenstra <vfeen...@redhat.com> Gerrit-Reviewer: Zhou Zheng Sheng <zhshz...@linux.vnet.ibm.com> Gerrit-Reviewer: oVirt Jenkins CI Server _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches