Skip to content

Commit

Permalink
Merge pull request avocado-framework#4016 from liang-cong-red-hat/vir…
Browse files Browse the repository at this point in the history
…ttest_migration_template_fix_xml_realted_option_early_destruction

Return the local varriable to delay the desctruction of the xml file
  • Loading branch information
dzhengfy authored Jan 13, 2025
2 parents a9b09f4 + 4991531 commit fc37acd
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions virttest/migration_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def _migrate(self):
self._create_disk_image_on_dest()

# Set xml file path for --xml and --persistent-xml in migrate options
self._update_xmlfile_path_in_migrate_options()
_, _ = self._update_xmlfile_path_in_migrate_options()

# Set selinux state before migration
# NOTE: if selinux state is set too early, it may be changed
Expand Down Expand Up @@ -652,21 +652,24 @@ def _update_xmlfile_path_in_migrate_options(self):
LOG.info("Generate and replace xml file path for --xml and/or --persistent-xml")

new_options = self.virsh_migrate_options

dest_vmxml, persist_vmxml = None, None
if self.migrate_flags & VIR_MIGRATE_DEST_XML:
vmxml_path = vm_xml.VMXML.new_from_dumpxml(
dest_vmxml = vm_xml.VMXML.new_from_dumpxml(
self.main_vm.name, "--security-info --migratable"
)
new_options = new_options.replace("DEST_XML", vmxml_path)
new_options = new_options.replace("DEST_XML", dest_vmxml.xml)

if self.migrate_flags & VIR_MIGRATE_PERSIST_DEST_XML:
vmxml_path = vm_xml.VMXML.new_from_dumpxml(
persist_vmxml = vm_xml.VMXML.new_from_dumpxml(
self.main_vm.name, "--security-info --migratable"
)
new_options = new_options.replace("DEST_PERSIST_XML", vmxml_path)
new_options = new_options.replace("DEST_PERSIST_XML", persist_vmxml.xml)

self.virsh_migrate_options = new_options

# Return dest_vmxml and persist_vmxml is to avoid the local variables including the xml file released
return dest_vmxml, persist_vmxml

def _migrate_flags(self):
"""
Generate migrate flags
Expand Down

0 comments on commit fc37acd

Please sign in to comment.