diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index a6f31f9773..954cb323a4 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -190,7 +190,18 @@ qemuExtDevicesStart(virQEMUDriver *driver, for (i = 0; i < def->ntpms; i++) { virDomainTPMDef *tpm = def->tpms[i]; - virDomainTPMDef *persistentTPMDef = persistentDef->tpms[i]; + virDomainTPMDef *persistentTPMDef = NULL; + + if (persistentDef) { + /* do not try to update the profile in the persistent definition + * if the device does not match */ + if (persistentDef->ntpms == def->ntpms) + persistentTPMDef = persistentDef->tpms[i]; + if (persistentTPMDef && + (persistentTPMDef->type != tpm->type || + persistentTPMDef->model != tpm->model)) + persistentTPMDef = NULL; + } if (tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR && qemuExtTPMStart(driver, vm, tpm, persistentTPMDef, diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index f223dcb9ae..f5e0184e54 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -773,7 +773,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, incomingMigration) < 0) goto error; - if (run_setup && !incomingMigration && + if (run_setup && !incomingMigration && persistentTPMDef && qemuTPMEmulatorUpdateProfileName(&tpm->data.emulator, persistentTPMDef, cfg, saveDef) < 0) goto error;