Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return the local varriable to delay the desctruction of the xml file #4016

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading