The Primary VM can be shut down when it is in COLO state, which may trigger this bug. About 'shutdown' -> 'colo' -> 'running', I think you are right, I did have the problems you said. For 'shutdown'->'colo', The fixed patch(5647051f432b7c9b57525470b0a79a31339062d2) have been merged. Recently, I found another bug as follows in the test. qemu-system-x86_64: invalid runstate transition: 'shutdown' -> 'running' Aborted (core dumped) The gdb bt as following: #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 #1 0x00007faa3d613859 in __GI_abort () at abort.c:79 #2 0x000055c5a21268fd in runstate_set (new_state=RUN_STATE_RUNNING) at vl.c:723 #3 0x000055c5a1f8cae4 in vm_prepare_start () at /home/workspace/colo-qemu/cpus.c:2206 #4 0x000055c5a1f8cb1b in vm_start () at /home/workspace/colo-qemu/cpus.c:2213 #5 0x000055c5a2332bba in migration_iteration_finish (s=0x55c5a4658810) at migration/migration.c:3376 #6 0x000055c5a2332f3b in migration_thread (opaque=0x55c5a4658810) at migration/migration.c:3527 #7 0x000055c5a251d68a in qemu_thread_start (args=0x55c5a5491a70) at util/qemu-thread-posix.c:519 #8 0x00007faa3d7e9609 in start_thread (arg=<optimized out>) at pthread_create.c:477 #9 0x00007faa3d710293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
For the bug, I made the following changes: @@ -3379,7 +3379,9 @@ static void migration_iteration_finish(MigrationState *s) case MIGRATION_STATUS_CANCELLED: case MIGRATION_STATUS_CANCELLING: if (s->vm_was_running) { - vm_start(); + if (!runstate_check(RUN_STATE_SHUTDOWN)) { + vm_start(); + } } else { if (runstate_check(RUN_STATE_FINISH_MIGRATE)) { runstate_set(RUN_STATE_POSTMIGRATE); I will send the patch to community after more test. Thanks, Lei. -----Original Message----- From: Lukas Straub <lukasstra...@web.de> Sent: Thursday, January 21, 2021 3:13 AM To: Rao, Lei <lei....@intel.com> Cc: Zhang, Chen <chen.zh...@intel.com>; lizhij...@cn.fujitsu.com; jasow...@redhat.com; zhang.zhanghaili...@huawei.com; quint...@redhat.com; dgilb...@redhat.com; qemu-devel@nongnu.org Subject: Re: [PATCH 02/10] Fix the qemu crash when guest shutdown during checkpoint On Wed, 13 Jan 2021 10:46:27 +0800 leirao <lei....@intel.com> wrote: > From: "Rao, Lei" <lei....@intel.com> > > This patch fixes the following: > qemu-system-x86_64: invalid runstate transition: 'colo' ->'shutdown' > Aborted (core dumped) > > Signed-off-by: Lei Rao <lei....@intel.com> I wonder how that is possible, since the VM is stopped during 'colo' state. Unrelated to this patch, I think this area needs some work since the following unintended runstate transition is possible: 'shutdown' -> 'colo' -> 'running'. > --- > softmmu/runstate.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/softmmu/runstate.c b/softmmu/runstate.c index > 636aab0..455ad0d 100644 > --- a/softmmu/runstate.c > +++ b/softmmu/runstate.c > @@ -125,6 +125,7 @@ static const RunStateTransition > runstate_transitions_def[] = { > { RUN_STATE_RESTORE_VM, RUN_STATE_PRELAUNCH }, > > { RUN_STATE_COLO, RUN_STATE_RUNNING }, > + { RUN_STATE_COLO, RUN_STATE_SHUTDOWN}, > > { RUN_STATE_RUNNING, RUN_STATE_DEBUG }, > { RUN_STATE_RUNNING, RUN_STATE_INTERNAL_ERROR }, --