Skip to contentSkip to conversation

runstate: allow inmigrate -> debug transition on snapshot restore

PATCH In review Trieu Huynh 2 participants 3 messages Apr 2 – Apr 7

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 runstate: allow inmigrate -> debug transition on snapshot restore

From: Trieu Huynh <[email protected]>

When a VM snapshot is taken while the guest is paused by a gdbstub (RUN_STATE_DEBUG), the saved runstate is 'debug', for instance:
(gdb) monitor info status
VM status: paused (debug)

On restore, the destination starts in 'inmigrate' and transitions to the saved runstate, but the 'inmigrate -> debug' transition was missing from the table, causing an abort:

  $ ./qemu-system-x86_64 -machine pc,accel=kvm:tcg  -m 128M
  -display none -gdb tcp::1235 -incoming "exec:cat /tmp/snap.img"
Quoted 1 line

/tmp/qemu-restore.log 2>&1

Aborted (core dumped)

  $ cat /tmp/qemu-restore.log
  qemu-system-x86_64: invalid runstate transition: 'inmigrate'
  -> 'debug'

Fix it by adding the missing one (Point out by the author Dustin Spicuzza)

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1231

---
 system/runstate.c | 1 +
 1 file changed, 1 insertion(+)
system/runstate.c +1 -0
index 2d4e95a216..97a6a1c736 100644
@@ -94,6 +94,7 @@ static const RunStateTransition runstate_transitions_def[] = {
     { RUN_STATE_INMIGRATE, RUN_STATE_PRELAUNCH },
     { RUN_STATE_INMIGRATE, RUN_STATE_POSTMIGRATE },
     { RUN_STATE_INMIGRATE, RUN_STATE_COLO },
+    { RUN_STATE_INMIGRATE, RUN_STATE_DEBUG },
 
     { RUN_STATE_INTERNAL_ERROR, RUN_STATE_PAUSED },
     { RUN_STATE_INTERNAL_ERROR, RUN_STATE_FINISH_MIGRATE },
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Trieu Huynh

From: Trieu Huynh <[email protected]>

When a VM snapshot is taken while the guest is paused by a gdbstub (RUN_STATE_DEBUG), the saved runstate is 'debug', for instance:
(gdb) monitor info status
VM status: paused (debug)

On restore, the destination starts in 'inmigrate' and transitions to the saved runstate, but the 'inmigrate -> debug' transition was missing from the table, causing an abort:

  $ ./qemu-system-x86_64 -machine pc,accel=kvm:tcg  -m 128M
  -display none -gdb tcp::1235 -incoming "exec:cat /tmp/snap.img"
Quoted 1 line

/tmp/qemu-restore.log 2>&1

Aborted (core dumped)

Quoted 8 lines
  $ cat /tmp/qemu-restore.log
  qemu-system-x86_64: invalid runstate transition: 'inmigrate'
  -> 'debug'

Fix it by adding the missing one (Point out by the author Dustin Spicuzza)

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1231

(note to self: stop giving time estimates)

Quoted 2 lines

I think this is reasonable as a standalone change:

As I mentioned in the Gitlab issue, it raises the question of whether there's more to be done in terms of migrating the gdbstub connection. Probably too niche of an use-case?

Quoted 16 lines
---
 system/runstate.c | 1 +
 1 file changed, 1 insertion(+)
system/runstate.c +1 -0
index 2d4e95a216..97a6a1c736 100644
@@ -94,6 +94,7 @@ static const RunStateTransition runstate_transitions_def[] = {
     { RUN_STATE_INMIGRATE, RUN_STATE_PRELAUNCH },
     { RUN_STATE_INMIGRATE, RUN_STATE_POSTMIGRATE },
     { RUN_STATE_INMIGRATE, RUN_STATE_COLO },
+    { RUN_STATE_INMIGRATE, RUN_STATE_DEBUG },
 
     { RUN_STATE_INTERNAL_ERROR, RUN_STATE_PAUSED },
     { RUN_STATE_INTERNAL_ERROR, RUN_STATE_FINISH_MIGRATE },
#2 lore raw
Quoted 26 lines · Fabiano Rosas
Quoted 15 lines · Trieu Huynh

From: Trieu Huynh <[email protected]>

When a VM snapshot is taken while the guest is paused by a gdbstub (RUN_STATE_DEBUG), the saved runstate is 'debug', for instance:
(gdb) monitor info status
VM status: paused (debug)

On restore, the destination starts in 'inmigrate' and transitions to the saved runstate, but the 'inmigrate -> debug' transition was missing from the table, causing an abort:

  $ ./qemu-system-x86_64 -machine pc,accel=kvm:tcg  -m 128M
  -display none -gdb tcp::1235 -incoming "exec:cat /tmp/snap.img"
Quoted 1 line

/tmp/qemu-restore.log 2>&1

Aborted (core dumped)

Quoted 8 lines
  $ cat /tmp/qemu-restore.log
  qemu-system-x86_64: invalid runstate transition: 'inmigrate'
  -> 'debug'

Fix it by adding the missing one (Point out by the author Dustin Spicuzza)

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1231

Quoted 9 lines

(note to self: stop giving time estimates)

Quoted 2 lines

I think this is reasonable as a standalone change:

Thanks for the review.

Quoted 4 lines

As I mentioned in the Gitlab issue, it raises the question of whether there's more to be done in terms of migrating the gdbstub connection. Probably too niche of an use-case?

Agreed that it's a niche use-case. The immediate pain point was the hard abort on restore, which this patch addresses. Migrating the actual gdbstub connection state across snapshots would be a separate and considerably more involved effort. Since the restored VM would still need the user to re-attach gdb manually anyway, so the practical value is limited.

Quoted 16 lines
Quoted 16 lines
---
 system/runstate.c | 1 +
 1 file changed, 1 insertion(+)
system/runstate.c +1 -0
index 2d4e95a216..97a6a1c736 100644
@@ -94,6 +94,7 @@ static const RunStateTransition runstate_transitions_def[] = {
     { RUN_STATE_INMIGRATE, RUN_STATE_PRELAUNCH },
     { RUN_STATE_INMIGRATE, RUN_STATE_POSTMIGRATE },
     { RUN_STATE_INMIGRATE, RUN_STATE_COLO },
+    { RUN_STATE_INMIGRATE, RUN_STATE_DEBUG },
 
     { RUN_STATE_INTERNAL_ERROR, RUN_STATE_PAUSED },
     { RUN_STATE_INTERNAL_ERROR, RUN_STATE_FINISH_MIGRATE },