def test_update_memory_backing_discard_keep(self): data = objects.LibvirtLiveMigrateData( dst_wants_file_backed_memory=True, file_backed_memory_discard=True) xml = """<domain> <memoryBacking> <source type="file"/> <access mode="shared"/> <allocation mode="immediate"/> <discard /> </memoryBacking> </domain>""" doc = etree.fromstring(xml) res = etree.tostring(migration._update_memory_backing_xml(doc, data), encoding='unicode') self.assertThat( res, matchers.XMLMatches("""<domain> <memoryBacking> <source type="file"/> <access mode="shared"/> <allocation mode="immediate"/> <discard /> </memoryBacking> </domain>"""))
def test_update_memory_backing_xml_add(self): data = objects.LibvirtLiveMigrateData( dst_wants_file_backed_memory=True) xml = """<domain/>""" doc = etree.fromstring(xml) res = etree.tostring(migration._update_memory_backing_xml(doc, data), encoding='unicode') self.assertXmlEqual(res, """<domain> <memoryBacking> <source type="file"/> <access mode="shared"/> <allocation mode="immediate"/> </memoryBacking> </domain>""")
def test_update_memory_backing_xml_add(self): data = objects.LibvirtLiveMigrateData( dst_wants_file_backed_memory=True) xml = """<domain/>""" doc = etree.fromstring(xml) res = etree.tostring(migration._update_memory_backing_xml(doc, data), encoding='unicode') self.assertThat(res, matchers.XMLMatches("""<domain> <memoryBacking> <source type="file"/> <access mode="shared"/> <allocation mode="immediate"/> </memoryBacking> </domain>"""))
def test_update_memory_backing_xml_remove(self): data = objects.LibvirtLiveMigrateData( dst_wants_file_backed_memory=False) xml = """<domain> <memoryBacking> <source type="file"/> <access mode="shared"/> <allocation mode="immediate"/> </memoryBacking> </domain>""" doc = etree.fromstring(xml) res = etree.tostring(migration._update_memory_backing_xml(doc, data), encoding='unicode') self.assertXmlEqual(res, """<domain> <memoryBacking/> </domain>""")