mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-03-09 08:58:27 +03:00
xmlbuilder: Make clear() remove unknown XML properties
This commit is contained in:
parent
16c8c31cbd
commit
9f5a842a3a
20
tests/xmlparse-xml/clear-cpu-unknown-vals-in.xml
Normal file
20
tests/xmlparse-xml/clear-cpu-unknown-vals-in.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<domain type="test">
|
||||
<name>test-cpu-unknown-clear</name>
|
||||
<memory unit="KiB">8388608</memory>
|
||||
<currentMemory unit="KiB">2097152</currentMemory>
|
||||
<vcpu placement="static">2</vcpu>
|
||||
<os>
|
||||
<type arch="i686">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<cpu>
|
||||
<foo bar="baz"/>
|
||||
<blah/>
|
||||
</cpu>
|
||||
<clock offset="utc"/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
</devices>
|
||||
</domain>
|
16
tests/xmlparse-xml/clear-cpu-unknown-vals-out.xml
Normal file
16
tests/xmlparse-xml/clear-cpu-unknown-vals-out.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<domain type="test">
|
||||
<name>test-cpu-unknown-clear</name>
|
||||
<memory unit="KiB">8388608</memory>
|
||||
<currentMemory unit="KiB">2097152</currentMemory>
|
||||
<vcpu placement="static">2</vcpu>
|
||||
<os>
|
||||
<type arch="i686">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<clock offset="utc"/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
</devices>
|
||||
</domain>
|
@ -1104,6 +1104,16 @@ class XMLParseTest(unittest.TestCase):
|
||||
# Misc tests #
|
||||
##############
|
||||
|
||||
def testCPUUnknownClear(self):
|
||||
# Make sure .clear() even removes XML elements we don't know about
|
||||
basename = "clear-cpu-unknown-vals"
|
||||
infile = "tests/xmlparse-xml/%s-in.xml" % basename
|
||||
outfile = "tests/xmlparse-xml/%s-out.xml" % basename
|
||||
guest = virtinst.Guest(conn, parsexml=file(infile).read())
|
||||
|
||||
guest.cpu.clear()
|
||||
utils.diff_compare(guest.get_xml_config(), outfile)
|
||||
|
||||
def testzzzzCheckProps(self):
|
||||
# pylint: disable=W0212
|
||||
# Access to protected member, needed to unittest stuff
|
||||
|
@ -855,6 +855,9 @@ class XMLBuilder(object):
|
||||
for prop in props:
|
||||
prop.clear(self)
|
||||
|
||||
_remove_xpath_node(self._xmlstate.xml_ctx,
|
||||
self.get_root_xpath())
|
||||
|
||||
def validate(self):
|
||||
"""
|
||||
Validate any set values and raise an exception if there's
|
||||
|
Loading…
x
Reference in New Issue
Block a user