On 10/5/22 16:02, Stefan Berger wrote:
> When migrating the TPM in a setup that has shared storage for the TPM state
> files setup between hosts we never remove the state.
> 
> Signed-off-by: Stefan Berger <stef...@linux.ibm.com>
> ---
>  src/qemu/qemu_tpm.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c
> index 2b2d2eba5a..59de13061a 100644
> --- a/src/qemu/qemu_tpm.c
> +++ b/src/qemu/qemu_tpm.c
> @@ -737,6 +737,10 @@ static void
>  qemuTPMEmulatorCleanupHost(virDomainTPMDef *tpm,
>                             virDomainUndefineFlagsValues flags)
>  {
> +    /* Never remove the state in case of migration with shared storage. */
> +    if ((flags & VIR_MIGRATE_TPM_SHARED_STORAGE))
> +        return;

This is testing a flag from a different enum. If there's ever an
undefine flag like:

  VIR_DOMAIN_UNDEFINE_EXAMPLE = (1<<21)

then this is going to be wrongly evaluated. Can't callers just pass
VIR_DOMAIN_UNDEFINE_KEEP_TPM?

Alternatively, if we invent private data (see my comment to one of
previous patches), this can be plain:

  if (QEMU_DOMAIN_TPM_PRIVATE(tpm)->migrating)
    return;

(or whatever member I suggested).

Michal

Reply via email to