Skip to content

Commit

Permalink
Merge pull request avocado-framework#3567 from PaulYuuu/tpm-migration…
Browse files Browse the repository at this point in the history
…-naming

qemu_vm: Fix swtpm path too long for vTPM + ping-pong migration
  • Loading branch information
YongxueHong authored Dec 20, 2022
2 parents 04abeca + 2264604 commit 2387dd4
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions virttest/qemu_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4488,21 +4488,27 @@ def _set_migrate_capability(vm, capability, value, is_src_vm=True):
swtpm_dir = os.path.join(data_dir.get_data_dir(), "swtpm")
tpms = clone.params.objects("tpms")
tpms_copy = []
for tpm in tpms:
tpm_name = "%s_%s" % (self.name, tpm)
tpm_path = os.path.join(swtpm_dir, '%s_state' % tpm_name)
tpm_copied_path = os.path.join(swtpm_dir, '%s_copied_state' %
tpm_name)
if os.path.exists(tpm_copied_path):
shutil.rmtree(tpm_copied_path)
shutil.copytree(tpm_path, tpm_copied_path)
tpms_copy.append(tpm + "_copied")
for param in clone.params.copy():
if param.endswith("_" + tpm):
clone.params[param + "_copied"] = clone.params[param]
del clone.params[param]
clone.params["tpm_overwrite_%s_copied" % tpm] = "no"
clone.params["tpms"] = " ".join(tpms_copy)
_rollback_tpms = clone.params.get("_rollback_tpms")

if _rollback_tpms:
clone.params["tpms"] = clone.params.pop("_rollback_tpms")
else:
# Backup vTPM resources for ping-pong migration
clone.params["_rollback_tpms"] = clone.params["tpms"]
for tpm in tpms:
tpm_name = "%s_%s" % (self.name, tpm)
tpm_path = os.path.join(swtpm_dir, '%s_state' % tpm_name)
tpm_copied_path = os.path.join(swtpm_dir, '%s_copied_state' %
tpm_name)
if os.path.exists(tpm_copied_path):
shutil.rmtree(tpm_copied_path)
shutil.copytree(tpm_path, tpm_copied_path)
tpms_copy.append(tpm + "_copied")
for param in clone.params.copy():
if param.endswith("_" + tpm):
clone.params[param + "_copied"] = clone.params[param]
clone.params["tpm_overwrite_%s_copied" % tpm] = "no"
clone.params["tpms"] = " ".join(tpms_copy)

try:
if (local and not (migration_exec_cmd_src and
Expand Down

0 comments on commit 2387dd4

Please sign in to comment.