On 10/5/22 16:02, Stefan Berger wrote: > Do not create storage if TPM_SHARED_STORAGE migration flag is set and on > incoming migration since in this case the storage directory must already > exist. Also do not run swtpm_setup in this case. > > Pass the migration flag from migration related functions all the way down > to TPM related functions. If no migration flags exist on higher layers, > pass down '0'. > > Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxxxxx> > --- > src/qemu/qemu_driver.c | 4 ++-- > src/qemu/qemu_extdevice.c | 5 +++-- > src/qemu/qemu_extdevice.h | 3 ++- > src/qemu/qemu_migration.c | 2 +- > src/qemu/qemu_process.c | 10 ++++++---- > src/qemu/qemu_process.h | 6 ++++-- > src/qemu/qemu_saveimage.c | 2 +- > src/qemu/qemu_snapshot.c | 4 ++-- > src/qemu/qemu_tpm.c | 27 +++++++++++++++++++++------ > src/qemu/qemu_tpm.h | 3 ++- > 10 files changed, 44 insertions(+), 22 deletions(-) > > diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c > index 40d23b5723..3f163a4664 100644 > --- a/src/qemu/qemu_driver.c > +++ b/src/qemu/qemu_driver.c > @@ -1633,7 +1633,7 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn, > if (qemuProcessStart(conn, driver, vm, NULL, VIR_ASYNC_JOB_START, > NULL, -1, NULL, NULL, > VIR_NETDEV_VPORT_PROFILE_OP_CREATE, > - start_flags) < 0) { > + start_flags, 0) < 0) { > virDomainAuditStart(vm, "booted", false); > qemuDomainRemoveInactive(driver, vm, 0); > qemuProcessEndJob(vm); > @@ -6555,7 +6555,7 @@ qemuDomainObjStart(virConnectPtr conn, > > ret = qemuProcessStart(conn, driver, vm, NULL, asyncJob, > NULL, -1, NULL, NULL, > - VIR_NETDEV_VPORT_PROFILE_OP_CREATE, start_flags); > + VIR_NETDEV_VPORT_PROFILE_OP_CREATE, start_flags, 0); > virDomainAuditStart(vm, "booted", ret >= 0); > if (ret >= 0) { > virObjectEvent *event = > diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c > index 24a57b0f74..0bafe2b7b0 100644 > --- a/src/qemu/qemu_extdevice.c > +++ b/src/qemu/qemu_extdevice.c > @@ -168,7 +168,8 @@ qemuExtDevicesCleanupHost(virQEMUDriver *driver, > int > qemuExtDevicesStart(virQEMUDriver *driver, > virDomainObj *vm, > - bool incomingMigration) > + bool incomingMigration, > + virDomainMigrateFlags flags) > { > virDomainDef *def = vm->def; > size_t i; > @@ -186,7 +187,7 @@ qemuExtDevicesStart(virQEMUDriver *driver, > virDomainTPMDef *tpm = def->tpms[i]; > > if (tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR && > - qemuExtTPMStart(driver, vm, tpm, incomingMigration) < 0) > + qemuExtTPMStart(driver, vm, tpm, incomingMigration, flags) < 0) > return -1; > } > > diff --git a/src/qemu/qemu_extdevice.h b/src/qemu/qemu_extdevice.h > index 6b05b59cd6..723e21d42c 100644 > --- a/src/qemu/qemu_extdevice.h > +++ b/src/qemu/qemu_extdevice.h > @@ -47,7 +47,8 @@ void qemuExtDevicesCleanupHost(virQEMUDriver *driver, > > int qemuExtDevicesStart(virQEMUDriver *driver, > virDomainObj *vm, > - bool incomingMigration) > + bool incomingMigration, > + virDomainMigrateFlags flags) > ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) > G_GNUC_WARN_UNUSED_RESULT; > > diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c > index 33105cf07b..efb27a24aa 100644 > --- a/src/qemu/qemu_migration.c > +++ b/src/qemu/qemu_migration.c > @@ -3095,7 +3095,7 @@ qemuMigrationDstPrepareActive(virQEMUDriver *driver, > rv = qemuProcessLaunch(dconn, driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, > incoming, NULL, > VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_START, > - startFlags); > + startFlags, flags); > if (rv < 0) { > if (rv == -2) > relabel = true; > diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c > index 97336e2622..f278b73858 100644 > --- a/src/qemu/qemu_process.c > +++ b/src/qemu/qemu_process.c > @@ -7421,7 +7421,8 @@ qemuProcessLaunch(virConnectPtr conn, > qemuProcessIncomingDef *incoming, > virDomainMomentObj *snapshot, > virNetDevVPortProfileOp vmop, > - unsigned int flags) > + unsigned int flags, > + virDomainMigrateFlags migFlags) To avoid having to invent new argument, we have @flags already which is a mixture of internal and public flags. Then, each caller has a logic that sets internal flags and possibly translates public ones. The same applies to qemuProcessStart(). Michal