All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] migration/savevm: Allow stub VMSDs
@ 2026-03-16 19:47 Fabiano Rosas
  2026-03-16 21:08 ` Peter Maydell
  2026-03-16 21:13 ` Peter Xu
  0 siblings, 2 replies; 5+ messages in thread
From: Fabiano Rosas @ 2026-03-16 19:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Xu, Zhao Liu, Paolo Bonzini, Roman Kiryanov,
	Philippe Mathieu-Daudé, Peter Maydell

After the referenced commit, empty VMStateDescription objects declared
as part of stubs have started reaching the vmstate code.

A valid VMStateDescription must at minimum have a name and either the
.fields or .unmigratable fields set. Stubs, being empty, have
none. Code that assumes a non-NULL name field will now cause a
crash. E.g.

$ ./build/mips/qemu-system-mipsel -nographic -drive if=none,format=qcow2,file=dummy.qcow2
    [Type "C-a c" to get the "(qemu)" monitor prompt)]
    (qemu) savevm foo

    Backtrace from doing this under gdb:

      #0  0x0000555555df7d4d in vmsd_can_compress (field=0x5555564f78a0
      <__compound_literal.3>) at ../../migration/vmstate.c:339
      #1  0x0000555555df7dbb in vmsd_desc_field_start
          (vmsd=0x555556431ba0 <vmstate_cpuhp_state>, vmdesc=0x555556918690,
      field=0x5555564f78a0 <__compound_literal.3>, i=0, max=1) at
      ../../migration/vmstate.c:362
      #2  0x0000555555df85a7 in vmstate_save_state_v
          (f=0x555556b5a0c0, vmsd=0x555556431ba0 <vmstate_cpuhp_state>,
      opaque=0x555556c9aac0, vmdesc=0x555556918690, version_id=1,
      errp=0x7fffffffc948) at ../../migration/vmstate.c:528
      #3  0x0000555555df8032 in vmstate_save_state
          (f=0x555556b5a0c0, vmsd=0x555556431ba0 <vmstate_cpuhp_state>,
      opaque=0x555556c9aac0, vmdesc_id=0x555556918690, errp=0x7fffffffc948)
      at ../../migration/vmstate.c:427
      #4  0x0000555555df8f83 in vmstate_subsection_save
          (f=0x555556b5a0c0, vmsd=0x555556431c40 <vmstate_acpi>,
      opaque=0x555556c9aac0, vmdesc=0x555556918690, errp=0x7fffffffc948)
          at ../../migration/vmstate.c:695

Due to their very nature, it's better to allow stubs to be
completely empty instead of forcing any rules. Teach the code to skip
them.

Fixes: 7aa563630b ("pc: Start with modern CPU hotplug interface by default")
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 migration/savevm.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/migration/savevm.c b/migration/savevm.c
index dd58f2a705..e8d3360877 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -861,6 +861,10 @@ static void vmstate_check(const VMStateDescription *vmsd)
     const VMStateField *field = vmsd->fields;
     const VMStateDescription * const *subsection = vmsd->subsections;
 
+    if (!vmsd->name) {
+        return;
+    }
+
     if (field) {
         while (field->name) {
             if (field->flags & (VMS_STRUCT | VMS_VSTRUCT)) {
@@ -897,6 +901,11 @@ int vmstate_register_with_alias_id(VMStateIf *obj, uint32_t instance_id,
 {
     SaveStateEntry *se;
 
+    if (!vmsd->name) {
+        /* assume it's a stub and ignore */
+        return 0;
+    }
+
     /* If this triggers, alias support can be dropped for the vmsd. */
     assert(alias_id == -1 || required_for_version >= vmsd->minimum_version_id);
 
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-16 21:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-16 19:47 [PATCH v1] migration/savevm: Allow stub VMSDs Fabiano Rosas
2026-03-16 21:08 ` Peter Maydell
2026-03-16 21:13 ` Peter Xu
2026-03-16 21:28   ` Peter Maydell
2026-03-16 21:53   ` Fabiano Rosas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.