qemu: Introduce qemuTPMEmulatorCleanupHost()

This leaves qemuExtTPMCleanupHost() to only deal with looping
over TPM devices, same as other qemuExtTPMDoThing() functions.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
Andrea Bolognani 2022-02-04 17:57:53 +01:00
parent 5d35e2f2cc
commit c2c8cf3ed4

View File

@ -259,6 +259,20 @@ qemuTPMEmulatorGetPid(const char *swtpmStateDir,
}
/**
* qemuTPMEmulatorCleanupHost:
* @tpm: TPM definition
*
* Clean up persistent storage for the swtpm.
*/
static void
qemuTPMEmulatorCleanupHost(virDomainTPMDef *tpm)
{
if (!tpm->data.emulator.persistent_state)
qemuTPMEmulatorDeleteStorage(tpm);
}
/*
* qemuTPMEmulatorPrepareHost:
*
@ -885,8 +899,7 @@ qemuExtTPMCleanupHost(virDomainDef *def)
if (def->tpms[i]->type != VIR_DOMAIN_TPM_TYPE_EMULATOR)
continue;
if (!def->tpms[i]->data.emulator.persistent_state)
qemuTPMEmulatorDeleteStorage(def->tpms[i]);
qemuTPMEmulatorCleanupHost(def->tpms[i]);
}
}