diff mbox series

[2/6] migration/colo.c: Use cpu_synchronize_all_states()

Message ID 9675031ce557b73ebd10e7bd20ebbf57f30b177c.1589193382.git.lukasstraub2@web.de (mailing list archive)
State New, archived
Headers show
Series colo: migration related bugfixes | expand

Commit Message

Lukas Straub May 11, 2020, 11:10 a.m. UTC
cpu_synchronize_all_pre_loadvm() marks all vcpus as dirty, so the
registers are loaded from CPUState before we continue running
the vm. However if we failover during checkpoint, CPUState is not
initialized and the registers are loaded with garbage. This causes
guest hangs and crashes.

Fix this by using cpu_synchronize_all_states(), which initializes
CPUState from the current cpu registers additionally to marking
the vcpus as dirty.

Signed-off-by: Lukas Straub <lukasstraub2@web.de>
---
 migration/colo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dr. David Alan Gilbert May 13, 2020, 9:47 a.m. UTC | #1
* Lukas Straub (lukasstraub2@web.de) wrote:
> cpu_synchronize_all_pre_loadvm() marks all vcpus as dirty, so the
> registers are loaded from CPUState before we continue running
> the vm. However if we failover during checkpoint, CPUState is not
> initialized and the registers are loaded with garbage. This causes
> guest hangs and crashes.
> 
> Fix this by using cpu_synchronize_all_states(), which initializes
> CPUState from the current cpu registers additionally to marking
> the vcpus as dirty.
> 
> Signed-off-by: Lukas Straub <lukasstraub2@web.de>

OK, so I think you're saying that if the qemu_loadvm_state_main fails
because we failover, we now have duff CPU state, where we should just
carry on running on the secondary with the current state, so yes


Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  migration/colo.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/migration/colo.c b/migration/colo.c
> index 09168627bc..6b2ad35aa4 100644
> --- a/migration/colo.c
> +++ b/migration/colo.c
> @@ -696,7 +696,7 @@ static void colo_incoming_process_checkpoint(MigrationIncomingState *mis,
>      }
>  
>      qemu_mutex_lock_iothread();
> -    cpu_synchronize_all_pre_loadvm();
> +    cpu_synchronize_all_states();
>      ret = qemu_loadvm_state_main(mis->from_src_file, mis);
>      qemu_mutex_unlock_iothread();
>  
> -- 
> 2.20.1
> 


--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Lukas Straub May 13, 2020, 7:15 p.m. UTC | #2
On Wed, 13 May 2020 10:47:02 +0100
"Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:

> * Lukas Straub (lukasstraub2@web.de) wrote:
> > cpu_synchronize_all_pre_loadvm() marks all vcpus as dirty, so the
> > registers are loaded from CPUState before we continue running
> > the vm. However if we failover during checkpoint, CPUState is not
> > initialized and the registers are loaded with garbage. This causes
> > guest hangs and crashes.
> > 
> > Fix this by using cpu_synchronize_all_states(), which initializes
> > CPUState from the current cpu registers additionally to marking
> > the vcpus as dirty.
> > 
> > Signed-off-by: Lukas Straub <lukasstraub2@web.de>  
> 
> OK, so I think you're saying that if the qemu_loadvm_state_main fails
> because we failover, we now have duff CPU state, where we should just
> carry on running on the secondary with the current state, so yes

Exactly, Sorry for my bad wording.

> 
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> 
> > ---
> >  migration/colo.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/migration/colo.c b/migration/colo.c
> > index 09168627bc..6b2ad35aa4 100644
> > --- a/migration/colo.c
> > +++ b/migration/colo.c
> > @@ -696,7 +696,7 @@ static void colo_incoming_process_checkpoint(MigrationIncomingState *mis,
> >      }
> >  
> >      qemu_mutex_lock_iothread();
> > -    cpu_synchronize_all_pre_loadvm();
> > +    cpu_synchronize_all_states();
> >      ret = qemu_loadvm_state_main(mis->from_src_file, mis);
> >      qemu_mutex_unlock_iothread();
> >  
> > -- 
> > 2.20.1
> >   
> 
> 
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
>
diff mbox series

Patch

diff --git a/migration/colo.c b/migration/colo.c
index 09168627bc..6b2ad35aa4 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -696,7 +696,7 @@  static void colo_incoming_process_checkpoint(MigrationIncomingState *mis,
     }
 
     qemu_mutex_lock_iothread();
-    cpu_synchronize_all_pre_loadvm();
+    cpu_synchronize_all_states();
     ret = qemu_loadvm_state_main(mis->from_src_file, mis);
     qemu_mutex_unlock_iothread();