The vm state change notifier needs to be added only once and not every time upon sev state initialization. This is important when the SEV guest can be reset and the initialization needs to happen once per every reset. Therefore, move addition of vm state change notifier to sev_common_instance_init() as its called only once.
Signed-off-by: Ani Sinha <[email protected]> --- target/i386/sev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index c260c162b1..cb2213a32a 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -1917,8 +1917,6 @@ static int sev_common_kvm_init(ConfidentialGuestSupport *cgs, Error **errp) return -1; } - qemu_add_vm_change_state_handler(sev_vm_state_change, sev_common); - cgs->ready = true; return 0; @@ -2754,6 +2752,8 @@ sev_common_instance_init(Object *obj) error_setg(&sev_mig_blocker, "SEV: Migration is not implemented"); migrate_add_blocker(&sev_mig_blocker, &error_fatal); + + qemu_add_vm_change_state_handler(sev_vm_state_change, sev_common); } /* sev guest info common to sev/sev-es/sev-snp */ -- 2.42.0
