Skip to contentSkip to conversation

hw: Mark the device with no migratable fields

PATCH Superseded Philippe Mathieu-Daudé 6 participants 33 messages Jul 3, 2020 – Jan 18, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover hw: Mark the device with no migratable fields

This is a proof-of-concept after chatting with Peter Maydell on IRC earlier.

Introduce the vmstate_no_state_to_migrate structure, and a reference to it: vmstate_qdev_no_state_to_migrate. Use this reference in devices with no fields to migrate.

This is useful to catch devices missing vmstate, such:
- ads7846
- mcf-uart
- mcf-fec
- versatile_i2c
- ...

I am not sure about:
- gpex-pcihost

Philippe Mathieu-Daudé (18):
migration/vmstate: Document vmstate_dummy migration/vmstate: Introduce vmstate_no_state_to_migrate hw/core/qdev: Add vmstate_qdev_no_state_to_migrate hw/arm/armv7m: Mark the device with no migratable fields hw/arm/aspeed_soc: Mark the device with no migratable fields hw/arm/bcm283x: Mark devices with no migratable fields hw/arm/msf2-soc: Mark the device with no migratable fields hw/core/split-irq: Mark the device with no migratable fields hw/cpu/a9mpcore: Mark the device with no migratable fields hw/cpu/cluster: Mark the device with no migratable fields hw/usb/hcd-ohci: Mark the device with no migratable fields hw/intc/arm_gicv2m: Mark the device with no migratable fields hw/misc/armsse-cpuid: Mark the device with no migratable fields hw/misc/iotkit-sysinfo: Mark the device with no migratable fields hw/misc/unimp: Mark the device with no migratable fields hw/nubus/mac-nubus-bridge: Mark the device with no migratable fields hw/sparc64/sun4u: Mark devices with no migratable fields hw/core/qdev: Display warning for devices missing migration state

 configure                    |  9 +++++++++
 hw/usb/hcd-ohci.h            |  2 ++
 include/hw/arm/bcm2836.h     |  7 ++++---
 include/hw/arm/msf2-soc.h    | 11 ++++++-----
 include/hw/cpu/a9mpcore.h    |  3 ++-
 include/hw/qdev-core.h       |  2 ++
 include/migration/vmstate.h  |  3 ++-
 hw/arm/armv7m.c              |  1 +
 hw/arm/aspeed_soc.c          |  1 +
 hw/arm/bcm2835_peripherals.c |  1 +
 hw/arm/bcm2836.c             |  1 +
 hw/arm/msf2-soc.c            |  1 +
 hw/core/qdev.c               |  8 ++++++++
 hw/core/split-irq.c          |  1 +
 hw/cpu/a9mpcore.c            |  1 +
 hw/cpu/cluster.c             |  1 +
 hw/intc/arm_gicv2m.c         |  2 ++
 hw/misc/armsse-cpuid.c       |  1 +
 hw/misc/iotkit-sysinfo.c     |  1 +
 hw/misc/unimp.c              |  1 +
 hw/nubus/mac-nubus-bridge.c  |  1 +
 hw/sparc64/sun4u.c           |  7 ++++++-
 hw/usb/hcd-ohci.c            |  1 +
 migration/vmstate.c          |  7 +++++++
 24 files changed, 63 insertions(+), 11 deletions(-)
Signature · 1 line
2.21.3
#1 lore raw

PATCH 1/18 migration/vmstate: Document vmstate_dummy

vmstate_dummy is special and restricted to linux-user. See commit c71c3e99b8 ("Add a vmstate_dummy struct for CONFIG_USER_ONLY").

---
 include/migration/vmstate.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/migration/vmstate.h +1 -1
index f68ed7db13..af7d80cd4e 100644
@@ -194,7 +194,7 @@ struct VMStateDescription {
     const VMStateDescription **subsections;
 };
 
-extern const VMStateDescription vmstate_dummy;
+extern const VMStateDescription vmstate_dummy; /* Exclusively for linux-user */
 
 extern const VMStateInfo vmstate_info_bool;
 
Signature · 1 line
2.21.3
#2 lore raw

Re: [PATCH 01/18] migration/vmstate: Document vmstate_dummy

Quoted 13 lines · * Philippe Mathieu-Daudé ([email protected]) wrote:

vmstate_dummy is special and restricted to linux-user. See commit c71c3e99b8 ("Add a vmstate_dummy struct for CONFIG_USER_ONLY").

---
 include/migration/vmstate.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/migration/vmstate.h +0 -0
index f68ed7db13..af7d80cd4e 100644

include/migration/vmstate.h struct VMStateDescription { · line 197

Quoted 5 lines
include/migration/vmstate.h +1 -1
@@ -194,7 +194,7 @@ struct VMStateDescription {
     const VMStateDescription **subsections;
 };
 
-extern const VMStateDescription vmstate_dummy;
+extern const VMStateDescription vmstate_dummy; /* Exclusively for linux-user */

Which does mean it's a unfortunate name I guess for something so specific.
(It's also very weird having a vmsd defined with no VMSTATE_END_OF_LIST marker).

Dave

Quoted 5 lines
include/migration/vmstate.h +0 -0
 extern const VMStateInfo vmstate_info_bool;
 
Signature · 1 line
2.21.3

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#3 lore raw

Re: [PATCH 01/18] migration/vmstate: Document vmstate_dummy

In reply to Philippe Mathieu-Daudé
Quoted 13 lines · Philippe Mathieu-Daudé

vmstate_dummy is special and restricted to linux-user. See commit c71c3e99b8 ("Add a vmstate_dummy struct for CONFIG_USER_ONLY").

---
 include/migration/vmstate.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/migration/vmstate.h +0 -0
index f68ed7db13..af7d80cd4e 100644

include/migration/vmstate.h struct VMStateDescription { · line 197

Quoted 5 lines
include/migration/vmstate.h +1 -1
@@ -194,7 +194,7 @@ struct VMStateDescription {
     const VMStateDescription **subsections;
 };
 
-extern const VMStateDescription vmstate_dummy;
+extern const VMStateDescription vmstate_dummy; /* Exclusively for linux-user */

Originally in the commit mentioned above, this was enforced at build time:

+#ifdef CONFIG_USER_ONLY
+extern const VMStateDescription vmstate_dummy;
+#endif

but this was removed in

commit 6afc14e92ac81b29c25f097468f7751d5df1b5bc
Author: Stefan Weil <[email protected]>
Date: Fri Feb 6 22:43:10 2015 +0100

migration: Fix warning caused by missing declaration of vmstate_dummy

Warning from the Sparse static analysis tool:

stubs/vmstate.c:4:26: warning:
symbol 'vmstate_dummy' was not declared. Should it be static?

So if this is really intended to only be used by linux-user, then I suggest we put CONFIG_USER_ONLY back, and figure out a different way to address the undeclared symbol problem. I guess the problem was that stub code is shared both both user/softmmu builds. So perhaps we need to stub this in linux-user only code, instead of having it in the main stub library that is common.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#4 lore raw

Re: [PATCH 01/18] migration/vmstate: Document vmstate_dummy

Quoted 41 lines · Daniel P. Berrangé
Quoted 13 lines · Philippe Mathieu-Daudé

vmstate_dummy is special and restricted to linux-user. See commit c71c3e99b8 ("Add a vmstate_dummy struct for CONFIG_USER_ONLY").

---
 include/migration/vmstate.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/migration/vmstate.h +0 -0
index f68ed7db13..af7d80cd4e 100644

include/migration/vmstate.h struct VMStateDescription { · line 197

Quoted 5 lines
include/migration/vmstate.h +1 -1
@@ -194,7 +194,7 @@ struct VMStateDescription {
     const VMStateDescription **subsections;
 };
 
-extern const VMStateDescription vmstate_dummy;
+extern const VMStateDescription vmstate_dummy; /* Exclusively for linux-user */

Originally in the commit mentioned above, this was enforced at build time:

+#ifdef CONFIG_USER_ONLY
+extern const VMStateDescription vmstate_dummy;
+#endif

but this was removed in

commit 6afc14e92ac81b29c25f097468f7751d5df1b5bc
Author: Stefan Weil <[email protected]>
Date: Fri Feb 6 22:43:10 2015 +0100

migration: Fix warning caused by missing declaration of vmstate_dummy

Warning from the Sparse static analysis tool:

stubs/vmstate.c:4:26: warning:
symbol 'vmstate_dummy' was not declared. Should it be static?

Quoted 6 lines

So if this is really intended to only be used by linux-user, then I suggest we put CONFIG_USER_ONLY back, and figure out a different way to address the undeclared symbol problem. I guess the problem was that stub code is shared both both user/softmmu builds. So perhaps we need to stub this in linux-user only code, instead of having it in the main stub library that is common.

Good idea, I'll look at it.

Thanks,

Phil.

#5 lore raw

PATCH 2/18 migration/vmstate: Introduce vmstate_no_state_to_migrate

In reply to Philippe Mathieu-Daudé

Introduce a special state to indicate when an object doesn't have anything in its state to migrate.

---
 include/migration/vmstate.h | 1 +
 migration/vmstate.c         | 7 +++++++
 2 files changed, 8 insertions(+)
include/migration/vmstate.h +1 -0
index af7d80cd4e..0922bc8efa 100644
@@ -195,6 +195,7 @@ struct VMStateDescription {
 };
 
 extern const VMStateDescription vmstate_dummy; /* Exclusively for linux-user */
+extern const VMStateDescription vmstate_no_state_to_migrate;
 
 extern const VMStateInfo vmstate_info_bool;
 
migration/vmstate.c +7 -0
index bafa890384..d640cafad3 100644
@@ -20,6 +20,13 @@
 #include "trace.h"
 #include "qjson.h"
 
+const VMStateDescription vmstate_no_state_to_migrate = {
+    .name = "empty-state",
+    .fields = (VMStateField[]) {
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static int vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd,
                                    void *opaque, QJSON *vmdesc);
 static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *vmsd,
Signature · 1 line
2.21.3
#6 lore raw

Re: [PATCH 02/18] migration/vmstate: Introduce vmstate_no_state_to_migrate

Quoted 28 lines · Philippe Mathieu-Daudé

Introduce a special state to indicate when an object doesn't have anything in its state to migrate.

---
 include/migration/vmstate.h | 1 +
 migration/vmstate.c         | 7 +++++++
 2 files changed, 8 insertions(+)
include/migration/vmstate.h +1 -0
index af7d80cd4e..0922bc8efa 100644
@@ -195,6 +195,7 @@ struct VMStateDescription {
 };
 
 extern const VMStateDescription vmstate_dummy; /* Exclusively for linux-user */
+extern const VMStateDescription vmstate_no_state_to_migrate;
 
 extern const VMStateInfo vmstate_info_bool;
 
migration/vmstate.c +0 -0
index bafa890384..d640cafad3 100644

migration/vmstate.c line 28

Quoted 9 lines
migration/vmstate.c +6 -0
@@ -20,6 +20,13 @@
 #include "trace.h"
 #include "qjson.h"
 
+const VMStateDescription vmstate_no_state_to_migrate = {
+    .name = "empty-state",
+    .fields = (VMStateField[]) {
+        VMSTATE_END_OF_LIST()
+    }
+};

Does this definitely not put any data into the migration stream? We don't want to change what's on the wire for machines that use devices that start using this. (If it does by default, it would be easy to make the migration code special case the magic symbol to act like "no vmsd specified").

thanks
-- PMM

#7 lore raw

Re: [PATCH 02/18] migration/vmstate: Introduce vmstate_no_state_to_migrate

Quoted 32 lines · * Peter Maydell ([email protected]) wrote:
Quoted 31 lines · Philippe Mathieu-Daudé

Introduce a special state to indicate when an object doesn't have anything in its state to migrate.

---
 include/migration/vmstate.h | 1 +
 migration/vmstate.c         | 7 +++++++
 2 files changed, 8 insertions(+)
include/migration/vmstate.h +1 -0
index af7d80cd4e..0922bc8efa 100644
@@ -195,6 +195,7 @@ struct VMStateDescription {
 };
 
 extern const VMStateDescription vmstate_dummy; /* Exclusively for linux-user */
+extern const VMStateDescription vmstate_no_state_to_migrate;
 
 extern const VMStateInfo vmstate_info_bool;
 
migration/vmstate.c +0 -0
index bafa890384..d640cafad3 100644
@@ -20,6 +20,13 @@
 #include "trace.h"
 #include "qjson.h"
 
Quoted 12 lines

migration/vmstate.c line 28

Quoted 6 lines
migration/vmstate.c +6 -0
+const VMStateDescription vmstate_no_state_to_migrate = {
+    .name = "empty-state",
+    .fields = (VMStateField[]) {
+        VMSTATE_END_OF_LIST()
+    }
+};

Does this definitely not put any data into the migration stream? We don't want to change what's on the wire for machines that use devices that start using this. (If it does by default, it would be easy to make the migration code special case the magic symbol to act like "no vmsd specified").

I'd need to test it to be sure, but I think if we added a .needed to vmstate_no_state_to_migrate with a function that always returned false, then I think the stream would stay unchanged.

Dave

Quoted 3 lines

thanks
-- PMM

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#8 lore raw

PATCH 3/18 hw/core/qdev: Add vmstate_qdev_no_state_to_migrate

In reply to Philippe Mathieu-Daudé

Add vmstate_qdev_no_state_to_migrate, which is simply a pointer to vmstate_no_state_to_migrate. This way all qdev devices (including "hw/qdev-core.h") don't have to include "migration/vmstate.h".

---
 include/hw/qdev-core.h | 2 ++
 hw/core/qdev.c         | 3 +++
 2 files changed, 5 insertions(+)
include/hw/qdev-core.h +2 -0
index fe78073c70..2e4ddfd75f 100644
@@ -139,6 +139,8 @@ typedef struct DeviceClass {
     const char *bus_type;
 } DeviceClass;
 
+extern const VMStateDescription *vmstate_qdev_no_state_to_migrate;
+
 typedef struct NamedGPIOList NamedGPIOList;
 
 struct NamedGPIOList {
hw/core/qdev.c +3 -0
index 2131c7f951..0d18bc6d93 100644
@@ -45,6 +45,9 @@ bool qdev_hotplug = false;
 static bool qdev_hot_added = false;
 bool qdev_hot_removed = false;
 
+const VMStateDescription *vmstate_qdev_no_state_to_migrate =
+        &vmstate_no_state_to_migrate;
+
 const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
 {
     DeviceClass *dc = DEVICE_GET_CLASS(dev);
Signature · 1 line
2.21.3
#9 lore raw

PATCH 4/18 hw/arm/armv7m: Mark the device with no migratable fields

In reply to Philippe Mathieu-Daudé

This device doesn't have fields to migrate. Be explicit by using vmstate_qdev_no_state_to_migrate.

---
 hw/arm/armv7m.c | 1 +
 1 file changed, 1 insertion(+)
hw/arm/armv7m.c +1 -0
index 3308211e9c..3f78fccc12 100644
@@ -366,6 +366,7 @@ static void bitband_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = bitband_realize;
+    dc->vmsd = vmstate_qdev_no_state_to_migrate;
     device_class_set_props(dc, bitband_properties);
 }
 
Signature · 1 line
2.21.3
Reviewed-by on v1 4/18
#10 lore raw

Re: [PATCH 04/18] hw/arm/armv7m: Mark the device with no migratable fields

Quoted 14 lines · Philippe Mathieu-Daudé

This device doesn't have fields to migrate. Be explicit by using vmstate_qdev_no_state_to_migrate.

---
 hw/arm/armv7m.c | 1 +
 1 file changed, 1 insertion(+)
hw/arm/armv7m.c +0 -0
index 3308211e9c..3f78fccc12 100644

hw/arm/armv7m.c static void bitband_class_init(ObjectClass *klass, void *data) · line 371

Quoted 6 lines
hw/arm/armv7m.c +1 -0
@@ -366,6 +366,7 @@ static void bitband_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = bitband_realize;
+    dc->vmsd = vmstate_qdev_no_state_to_migrate;
     device_class_set_props(dc, bitband_properties);
 }

The commit message implies that this is changing the TYPE_ARMV7M device, but it's actually affecting TYPE_BITBAND. Code change looks good.

thanks
-- PMM

#11 lore raw

PATCH 5/18 hw/arm/aspeed_soc: Mark the device with no migratable fields

In reply to Philippe Mathieu-Daudé

This device doesn't have fields to migrate. Be explicit by using vmstate_qdev_no_state_to_migrate.

---
 hw/arm/aspeed_soc.c | 1 +
 1 file changed, 1 insertion(+)
hw/arm/aspeed_soc.c +1 -0
index 311458aa76..b15984e4d3 100644
@@ -442,6 +442,7 @@ static void aspeed_soc_class_init(ObjectClass *oc, void *data)
     dc->realize = aspeed_soc_realize;
     /* Reason: Uses serial_hds and nd_table in realize() directly */
     dc->user_creatable = false;
+    dc->vmsd = vmstate_qdev_no_state_to_migrate;
     device_class_set_props(dc, aspeed_soc_properties);
 }
 
Signature · 1 line
2.21.3
#12 lore raw

PATCH 6/18 hw/arm/bcm283x: Mark devices with no migratable fields

In reply to Philippe Mathieu-Daudé

These devices don't have fields to migrate. Be explicit by using vmstate_qdev_no_state_to_migrate.

Add a more descriptive comment to keep a clear separation between static property vs runtime changeable.

---
 include/hw/arm/bcm2836.h     | 7 ++++---
 hw/arm/bcm2835_peripherals.c | 1 +
 hw/arm/bcm2836.c             | 1 +
 3 files changed, 6 insertions(+), 3 deletions(-)
include/hw/arm/bcm2836.h +4 -3
index 024af8aae4..66e3621bb9 100644
@@ -33,14 +33,15 @@ typedef struct BCM283XState {
     DeviceState parent_obj;
     /*< public >*/
 
-    char *cpu_type;
-    uint32_t enabled_cpus;
-
     struct {
         ARMCPU core;
     } cpu[BCM283X_NCPUS];
     BCM2836ControlState control;
     BCM2835PeripheralState peripherals;
+
+    /* Properties */
+    char *cpu_type;
+    uint32_t enabled_cpus;
 } BCM283XState;
 
 typedef struct BCM283XInfo BCM283XInfo;
hw/arm/bcm2835_peripherals.c +1 -0
index 7ffdf62067..f33500dc27 100644
@@ -401,6 +401,7 @@ static void bcm2835_peripherals_class_init(ObjectClass *oc, void *data)
     DeviceClass *dc = DEVICE_CLASS(oc);
 
     dc->realize = bcm2835_peripherals_realize;
+    dc->vmsd = vmstate_qdev_no_state_to_migrate;
 }
 
 static const TypeInfo bcm2835_peripherals_type_info = {
hw/arm/bcm2836.c +1 -0
index ed1793f7b7..5fc67b6777 100644
@@ -173,6 +173,7 @@ static void bcm283x_class_init(ObjectClass *oc, void *data)
     device_class_set_props(dc, bcm2836_props);
     /* Reason: Must be wired up in code (see raspi_init() function) */
     dc->user_creatable = false;
+    dc->vmsd = vmstate_qdev_no_state_to_migrate;
 }
 
 static const TypeInfo bcm283x_type_info = {
Signature · 1 line
2.21.3
#13 lore raw

PATCH 7/18 hw/arm/msf2-soc: Mark the device with no migratable fields

In reply to Philippe Mathieu-Daudé

This device doesn't have fields to migrate. Be explicit by using vmstate_qdev_no_state_to_migrate.

Add a more descriptive comment to keep a clear separation between static property vs runtime changeable.

---
 include/hw/arm/msf2-soc.h | 11 ++++++-----
 hw/arm/msf2-soc.c         |  1 +
 2 files changed, 7 insertions(+), 5 deletions(-)
include/hw/arm/msf2-soc.h +6 -5
index c9cb214aa6..8f85ff8295 100644
@@ -51,6 +51,12 @@ typedef struct MSF2State {
 
     ARMv7MState armv7m;
 
+    MSF2SysregState sysreg;
+    MSSTimerState timer;
+    MSSSpiState spi[MSF2_NUM_SPIS];
+    MSF2EmacState emac;
+
+    /* Properties */
     char *cpu_type;
     char *part_name;
     uint64_t envm_size;
@@ -59,11 +65,6 @@ typedef struct MSF2State {
     uint32_t m3clk;
     uint8_t apb0div;
     uint8_t apb1div;
-
-    MSF2SysregState sysreg;
-    MSSTimerState timer;
-    MSSSpiState spi[MSF2_NUM_SPIS];
-    MSF2EmacState emac;
 } MSF2State;
 
 #endif
hw/arm/msf2-soc.c +1 -0
index 3235c76194..bcec389a01 100644
@@ -245,6 +245,7 @@ static void m2sxxx_soc_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = m2sxxx_soc_realize;
+    dc->vmsd = vmstate_qdev_no_state_to_migrate;
     device_class_set_props(dc, m2sxxx_soc_properties);
 }
 
Signature · 1 line
2.21.3
#14 lore raw

PATCH 8/18 hw/core/split-irq: Mark the device with no migratable fields

In reply to Philippe Mathieu-Daudé

This device doesn't have fields to migrate. Be explicit by using vmstate_qdev_no_state_to_migrate.

---
 hw/core/split-irq.c | 1 +
 1 file changed, 1 insertion(+)
hw/core/split-irq.c +1 -0
index 3b90af2e8f..a7072f922c 100644
@@ -71,6 +71,7 @@ static void split_irq_class_init(ObjectClass *klass, void *data)
     /* No state to reset or migrate */
     device_class_set_props(dc, split_irq_properties);
     dc->realize = split_irq_realize;
+    dc->vmsd = vmstate_qdev_no_state_to_migrate;
 
     /* Reason: Needs to be wired up to work */
     dc->user_creatable = false;
Signature · 1 line
2.21.3
#16 lore raw

PATCH 9/18 hw/cpu/a9mpcore: Mark the device with no migratable fields

In reply to Philippe Mathieu-Daudé

This device doesn't have fields to migrate. Be explicit by using vmstate_qdev_no_state_to_migrate.

Add a more descriptive comment to keep a clear separation between static property vs runtime changeable.

---
 include/hw/cpu/a9mpcore.h | 3 ++-
 hw/cpu/a9mpcore.c         | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
include/hw/cpu/a9mpcore.h +2 -1
index 5d67ca22c4..212f5db391 100644
@@ -25,10 +25,11 @@ typedef struct A9MPPrivState {
     SysBusDevice parent_obj;
     /*< public >*/
 
+    /* Properties */
     uint32_t num_cpu;
-    MemoryRegion container;
     uint32_t num_irq;
 
+    MemoryRegion container;
     A9SCUState scu;
     GICState gic;
     A9GTimerState gtimer;
hw/cpu/a9mpcore.c +1 -0
index 642363d2f4..5012c7a81a 100644
@@ -176,6 +176,7 @@ static void a9mp_priv_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = a9mp_priv_realize;
+    dc->vmsd = vmstate_qdev_no_state_to_migrate;
     device_class_set_props(dc, a9mp_priv_properties);
 }
 
Signature · 1 line
2.21.3
#17 lore raw

PATCH 10/18 hw/cpu/cluster: Mark the device with no migratable fields

In reply to Philippe Mathieu-Daudé

This device doesn't have fields to migrate. Be explicit by using vmstate_qdev_no_state_to_migrate.

---
 hw/cpu/cluster.c | 1 +
 1 file changed, 1 insertion(+)
hw/cpu/cluster.c +1 -0
index e444b7c29d..95653a643a 100644
@@ -80,6 +80,7 @@ static void cpu_cluster_class_init(ObjectClass *klass, void *data)
 
     device_class_set_props(dc, cpu_cluster_properties);
     dc->realize = cpu_cluster_realize;
+    dc->vmsd = vmstate_qdev_no_state_to_migrate;
 
     /* This is not directly for users, CPU children must be attached by code */
     dc->user_creatable = false;
Signature · 1 line
2.21.3
#18 lore raw

PATCH 11/18 hw/usb/hcd-ohci: Mark the device with no migratable fields

In reply to Philippe Mathieu-Daudé

This device doesn't have fields to migrate. Be explicit by using vmstate_qdev_no_state_to_migrate.

Add a more descriptive comment to keep a clear separation between static property vs runtime changeable.

---
 hw/usb/hcd-ohci.h | 2 ++
 hw/usb/hcd-ohci.c | 1 +
 2 files changed, 3 insertions(+)
hw/usb/hcd-ohci.h +2 -0
index 5c8819aedf..3bcbad1269 100644
@@ -100,6 +100,8 @@ typedef struct {
     /*< public >*/
 
     OHCIState ohci;
+
+    /* Properties */
     char *masterbus;
     uint32_t num_ports;
     uint32_t firstport;
hw/usb/hcd-ohci.c +1 -0
index 1e6e85e86a..6c76f65734 100644
@@ -1983,6 +1983,7 @@ static void ohci_sysbus_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = ohci_realize_pxa;
+    dc->vmsd = vmstate_qdev_no_state_to_migrate;
     set_bit(DEVICE_CATEGORY_USB, dc->categories);
     dc->desc = "OHCI USB Controller";
     device_class_set_props(dc, ohci_sysbus_properties);
Signature · 1 line
2.21.3
#19 lore raw

PATCH 12/18 hw/intc/arm_gicv2m: Mark the device with no migratable fields

In reply to Philippe Mathieu-Daudé

This device doesn't have fields to migrate. Be explicit by using vmstate_qdev_no_state_to_migrate.

Add a more descriptive comment to keep a clear separation between static property vs runtime changeable.

---
 hw/intc/arm_gicv2m.c | 2 ++
 1 file changed, 2 insertions(+)
hw/intc/arm_gicv2m.c +2 -0
index 0b7e2b4f84..c8b066066b 100644
@@ -54,6 +54,7 @@ typedef struct ARMGICv2mState {
     MemoryRegion iomem;
     qemu_irq spi[GICV2M_NUM_SPI_MAX];
 
+    /* Properties */
     uint32_t base_spi;
     uint32_t num_spi;
 } ARMGICv2mState;
@@ -181,6 +182,7 @@ static void gicv2m_class_init(ObjectClass *klass, void *data)
 
     device_class_set_props(dc, gicv2m_properties);
     dc->realize = gicv2m_realize;
+    dc->vmsd = vmstate_qdev_no_state_to_migrate;
 }
 
 static const TypeInfo gicv2m_info = {
Signature · 1 line
2.21.3
#20 lore raw

PATCH 13/18 hw/misc/armsse-cpuid: Mark the device with no migratable fields

In reply to Philippe Mathieu-Daudé

This device doesn't have fields to migrate. Be explicit by using vmstate_qdev_no_state_to_migrate.

---
 hw/misc/armsse-cpuid.c | 1 +
 1 file changed, 1 insertion(+)
hw/misc/armsse-cpuid.c +1 -0
index d58138dc28..61251d538b 100644
@@ -115,6 +115,7 @@ static void armsse_cpuid_class_init(ObjectClass *klass, void *data)
      * This device has no guest-modifiable state and so it
      * does not need a reset function or VMState.
      */
+    dc->vmsd = vmstate_qdev_no_state_to_migrate;
 
     device_class_set_props(dc, armsse_cpuid_props);
 }
Signature · 1 line
2.21.3
#21 lore raw

PATCH 14/18 hw/misc/iotkit-sysinfo: Mark the device with no migratable fields

In reply to Philippe Mathieu-Daudé

This device doesn't have fields to migrate. Be explicit by using vmstate_qdev_no_state_to_migrate.

---
 hw/misc/iotkit-sysinfo.c | 1 +
 1 file changed, 1 insertion(+)
hw/misc/iotkit-sysinfo.c +1 -0
index b2dcfc4376..8bb9a2ef8b 100644
@@ -120,6 +120,7 @@ static void iotkit_sysinfo_class_init(ObjectClass *klass, void *data)
      * This device has no guest-modifiable state and so it
      * does not need a reset function or VMState.
      */
+    dc->vmsd = vmstate_qdev_no_state_to_migrate;
 
     device_class_set_props(dc, iotkit_sysinfo_props);
 }
Signature · 1 line
2.21.3
#22 lore raw

PATCH 15/18 hw/misc/unimp: Mark the device with no migratable fields

In reply to Philippe Mathieu-Daudé

This device doesn't have fields to migrate. Be explicit by using vmstate_qdev_no_state_to_migrate.

---
 hw/misc/unimp.c | 1 +
 1 file changed, 1 insertion(+)
hw/misc/unimp.c +1 -0
index bc4084d344..8a0db25a77 100644
@@ -79,6 +79,7 @@ static void unimp_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = unimp_realize;
+    dc->vmsd = vmstate_qdev_no_state_to_migrate;
     device_class_set_props(dc, unimp_properties);
 }
 
Signature · 1 line
2.21.3
#23 lore raw

PATCH 16/18 hw/nubus/mac-nubus-bridge: Mark the device with no migratable fields

In reply to Philippe Mathieu-Daudé

This device doesn't have fields to migrate. Be explicit by using vmstate_qdev_no_state_to_migrate.

---
 hw/nubus/mac-nubus-bridge.c | 1 +
 1 file changed, 1 insertion(+)
hw/nubus/mac-nubus-bridge.c +1 -0
index 7c329300b8..ede36ccc5d 100644
@@ -27,6 +27,7 @@ static void mac_nubus_bridge_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->desc = "Nubus bridge";
+    dc->vmsd = vmstate_qdev_no_state_to_migrate;
 }
 
 static const TypeInfo mac_nubus_bridge_info = {
Signature · 1 line
2.21.3
#24 lore raw

PATCH 17/18 hw/sparc64/sun4u: Mark devices with no migratable fields

In reply to Philippe Mathieu-Daudé

These devices don't have fields to migrate. Be explicit by using vmstate_qdev_no_state_to_migrate.

Add a more descriptive comment to keep a clear separation between static property vs runtime changeable.

---
 hw/sparc64/sun4u.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
hw/sparc64/sun4u.c +6 -1
index 9c8655cffc..2653893625 100644
@@ -82,12 +82,15 @@ struct hwdef {
 typedef struct EbusState {
     /*< private >*/
     PCIDevice parent_obj;
+    /*< public >*/
 
     ISABus *isa_bus;
     qemu_irq isa_bus_irqs[ISA_NUM_IRQS];
-    uint64_t console_serial_base;
     MemoryRegion bar0;
     MemoryRegion bar1;
+
+    /* Properties */
+    uint64_t console_serial_base;
 } EbusState;
 
 #define TYPE_EBUS "ebus"
@@ -384,6 +387,7 @@ static void ebus_class_init(ObjectClass *klass, void *data)
     k->device_id = PCI_DEVICE_ID_SUN_EBUS;
     k->revision = 0x01;
     k->class_id = PCI_CLASS_BRIDGE_OTHER;
+    dc->vmsd = vmstate_qdev_no_state_to_migrate;
     device_class_set_props(dc, ebus_properties);
 }
 
@@ -476,6 +480,7 @@ static void prom_class_init(ObjectClass *klass, void *data)
 
     device_class_set_props(dc, prom_properties);
     dc->realize = prom_realize;
+    dc->vmsd = vmstate_qdev_no_state_to_migrate;
 }
 
 static const TypeInfo prom_info = {
Signature · 1 line
2.21.3
#25 lore raw

RFC PATCH 18/18 hw/core/qdev: Display warning for devices missing migration state

In reply to Philippe Mathieu-Daudé

When built with --enable-qdev-debug, QEMU displays warnings listing devices missing migration state:

  $ qemu-system-arm -S -M spitz
  qemu-system-arm: warning: missing migration state for type: 'pxa270-c0-arm-cpu'
  qemu-system-arm: warning: missing migration state for type: 'serial'
  qemu-system-arm: warning: missing migration state for type: 'pxa2xx-pcmcia'
  qemu-system-arm: warning: missing migration state for type: 'pxa2xx-pcmcia'
  qemu-system-arm: warning: missing migration state for type: 'pxa2xx-i2c-slave'
  qemu-system-arm: warning: missing migration state for type: 'pxa2xx-i2c-slave'
  qemu-system-arm: warning: missing migration state for type: 'ads7846'
  qemu-system-arm: warning: missing migration state for type: 'max1111'

---
RFC because there might be something simpler than --enable-qdev-debug.

 configure      | 9 +++++++++
 hw/core/qdev.c | 5 +++++
 2 files changed, 14 insertions(+)
configure +9 -0
index 8a65240d4a..d38efd5605 100755
@@ -441,6 +441,7 @@ edk2_blobs="no"
 pkgversion=""
 pie=""
 qom_cast_debug="yes"
+qdev_debug="no"
 trace_backends="log"
 trace_file="trace"
 spice=""
@@ -1124,6 +1125,10 @@ for opt do
   ;;
   --enable-qom-cast-debug) qom_cast_debug="yes"
   ;;
+  --disable-qdev-debug) qdev_debug="no"
+  ;;
+  --enable-qdev-debug) qdev_debug="yes"
+  ;;
   --disable-virtfs) virtfs="no"
   ;;
   --enable-virtfs) virtfs="yes"
@@ -6966,6 +6971,7 @@ echo "gcov enabled      $gcov"
 echo "TPM support       $tpm"
 echo "libssh support    $libssh"
 echo "QOM debugging     $qom_cast_debug"
+echo "QDEV debugging    $qdev_debug"
 echo "Live block migration $live_block_migration"
 echo "lzo support       $lzo"
 echo "snappy support    $snappy"
@@ -7594,6 +7600,9 @@ fi
 if test "$qom_cast_debug" = "yes" ; then
   echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
 fi
+if test "$qdev_debug" = "yes" ; then
+  echo "CONFIG_QDEV_DEBUG=y" >> $config_host_mak
+fi
 if test "$rbd" = "yes" ; then
   echo "CONFIG_RBD=m" >> $config_host_mak
   echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
hw/core/qdev.c +5 -0
index 0d18bc6d93..c2da1e0509 100644
@@ -932,6 +932,11 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
                                                &local_err) < 0) {
                 goto post_realize_fail;
             }
+        } else {
+#ifdef CONFIG_QDEV_DEBUG
+            warn_report("missing migration state for type: '%s'",
+                        object_get_typename(OBJECT(dev)));
+#endif
         }
 
         /*
Signature · 1 line
2.21.3
#26 lore raw

Re: [RFC PATCH 18/18] hw/core/qdev: Display warning for devices missing migration state

Quoted 14 lines · Philippe Mathieu-Daudé

When built with --enable-qdev-debug, QEMU displays warnings listing devices missing migration state:

  $ qemu-system-arm -S -M spitz
  qemu-system-arm: warning: missing migration state for type: 'pxa270-c0-arm-cpu'
  qemu-system-arm: warning: missing migration state for type: 'serial'
  qemu-system-arm: warning: missing migration state for type: 'pxa2xx-pcmcia'
  qemu-system-arm: warning: missing migration state for type: 'pxa2xx-pcmcia'
  qemu-system-arm: warning: missing migration state for type: 'pxa2xx-i2c-slave'
  qemu-system-arm: warning: missing migration state for type: 'pxa2xx-i2c-slave'
  qemu-system-arm: warning: missing migration state for type: 'ads7846'
  qemu-system-arm: warning: missing migration state for type: 'max1111'
Quoted 3 lines

---
RFC because there might be something simpler than --enable-qdev-debug.

I think where we'd like to get to is installing a migration blocker if the machine has any devices which don't have a vmsd. But for that we'd need to be pretty sure we'd got all the devices on machines where we care about migration, and we're clearly a fair way from that (eg we need to do something about the devices like the CPU which don't have a vmsd but handle their migration some other way so they don't trigger the condition for warning/migration-blocker).

I don't have a strong objection to this --enable-qdev-debug, I guess. Another option halfway between this and a full migration-blocker would be do a warn_report() for the relevant devices when savevm tries to migrate them.

thanks
-- PMM

#27 lore raw

Re: [RFC PATCH 18/18] hw/core/qdev: Display warning for devices missing migration state

Quoted 19 lines · Peter Maydell
Quoted 14 lines · Philippe Mathieu-Daudé

When built with --enable-qdev-debug, QEMU displays warnings listing devices missing migration state:

  $ qemu-system-arm -S -M spitz
  qemu-system-arm: warning: missing migration state for type: 'pxa270-c0-arm-cpu'
  qemu-system-arm: warning: missing migration state for type: 'serial'
  qemu-system-arm: warning: missing migration state for type: 'pxa2xx-pcmcia'
  qemu-system-arm: warning: missing migration state for type: 'pxa2xx-pcmcia'
  qemu-system-arm: warning: missing migration state for type: 'pxa2xx-i2c-slave'
  qemu-system-arm: warning: missing migration state for type: 'pxa2xx-i2c-slave'
  qemu-system-arm: warning: missing migration state for type: 'ads7846'
  qemu-system-arm: warning: missing migration state for type: 'max1111'
Quoted 3 lines

---
RFC because there might be something simpler than --enable-qdev-debug.

Quoted 8 lines

I think where we'd like to get to is installing a migration blocker if the machine has any devices which don't have a vmsd. But for that we'd need to be pretty sure we'd got all the devices on machines where we care about migration, and we're clearly a fair way from that (eg we need to do something about the devices like the CPU which don't have a vmsd but handle their migration some other way so they don't trigger the condition for warning/migration-blocker).

Dave made a comment about it, I'd rather let him have a look.

Quoted 4 lines

I don't have a strong objection to this --enable-qdev-debug, I guess. Another option halfway between this and a full migration-blocker would be do a warn_report() for the relevant devices when savevm tries to migrate them.

OK. The problem is vmstate_save_state() is not qdev specific, it migrates a blob, which we can not report much about. I'll repost using 2 warnings.

Thanks for your review,

Phil.

#28 lore raw
In reply to Philippe Mathieu-Daudé
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===

LINK tests/test-io-task
LINK tests/test-io-channel-socket
hw/core/qdev.o:(.data.rel+0x0): undefined reference to `vmstate_no_state_to_migrate'
collect2: error: ld returned 1 exit status
make: *** [tests/test-qdev-global-props] Error 1
make: *** Waiting for unfinished jobs....
TEST iotest-qcow2: 002
TEST iotest-qcow2: 003
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=ba983f0b8bc94d39a0a649a449a91f08', '-u', '1001', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-mg_r93vd/src/docker-src.2020-07-03-16.46.29.22759:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=ba983f0b8bc94d39a0a649a449a91f08
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-mg_r93vd/src'
make: *** [docker-run-test-quick@centos7] Error 2

real 16m8.994s
user 0m8.902s

The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#29 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 15 lines · Philippe Mathieu-Daudé

This is a proof-of-concept after chatting with Peter Maydell on IRC earlier.

Introduce the vmstate_no_state_to_migrate structure, and a reference to it: vmstate_qdev_no_state_to_migrate. Use this reference in devices with no fields to migrate.

This is useful to catch devices missing vmstate, such:
- ads7846
- mcf-uart
- mcf-fec
- versatile_i2c
- ...

Quoted 2 lines

I am not sure about:
- gpex-pcihost

I think it's correct that this has no internal state:
the only interesting state is in the GPEXRootState, which is a TYPE_GPEX_ROOT_DEVICE which migrates itself.

I made some comments on the "meaty" bits of the patchset, and reviewed one or two of the "mark this device as having no migration state" patches, but it doesn't seem worth reviewing all of them until the migration submaintainers have a chance to weigh in on whether they like the concept (I expect they're busy right now with freeze-related stuff :-))

thanks
-- PMM

#30 lore raw
Quoted 23 lines · Peter Maydell
Quoted 15 lines · Philippe Mathieu-Daudé

This is a proof-of-concept after chatting with Peter Maydell on IRC earlier.

Introduce the vmstate_no_state_to_migrate structure, and a reference to it: vmstate_qdev_no_state_to_migrate. Use this reference in devices with no fields to migrate.

This is useful to catch devices missing vmstate, such:
- ads7846
- mcf-uart
- mcf-fec
- versatile_i2c
- ...

Quoted 2 lines

I am not sure about:
- gpex-pcihost

I think it's correct that this has no internal state:
the only interesting state is in the GPEXRootState, which is a TYPE_GPEX_ROOT_DEVICE which migrates itself.

Quoted 6 lines

I made some comments on the "meaty" bits of the patchset, and reviewed one or two of the "mark this device as having no migration state" patches, but it doesn't seem worth reviewing all of them until the migration submaintainers have a chance to weigh in on whether they like the concept (I expect they're busy right now with freeze-related stuff :-))

Now that we are far from freeze-date is a good time to ping again on this concept :)

Most of the devices are ARM except:
- cpu-cluster (Eduardo/Marcel)
- hcd-ohci (Gerd)
- mac-nubus-bridge (Laurent)
- generic QOM (Daniel, Paolo)

Is someone against this proposal?

Regards,

Phil.

#31 lore raw

Le 14/01/2021 à 16:49, Philippe Mathieu-Daudé a écrit :

Quoted 34 lines · Peter Maydell
Quoted 23 lines · Philippe Mathieu-Daudé
Quoted 15 lines

This is a proof-of-concept after chatting with Peter Maydell on IRC earlier.

Introduce the vmstate_no_state_to_migrate structure, and a reference to it: vmstate_qdev_no_state_to_migrate. Use this reference in devices with no fields to migrate.

This is useful to catch devices missing vmstate, such:
- ads7846
- mcf-uart
- mcf-fec
- versatile_i2c
- ...

Quoted 2 lines

I am not sure about:
- gpex-pcihost

I think it's correct that this has no internal state:
the only interesting state is in the GPEXRootState, which is a TYPE_GPEX_ROOT_DEVICE which migrates itself.

Quoted 6 lines

I made some comments on the "meaty" bits of the patchset, and reviewed one or two of the "mark this device as having no migration state" patches, but it doesn't seem worth reviewing all of them until the migration submaintainers have a chance to weigh in on whether they like the concept (I expect they're busy right now with freeze-related stuff :-))

Now that we are far from freeze-date is a good time to ping again on this concept :)

Quoted 7 lines

Most of the devices are ARM except:
- cpu-cluster (Eduardo/Marcel)
- hcd-ohci (Gerd)
- mac-nubus-bridge (Laurent)
- generic QOM (Daniel, Paolo)

Is someone against this proposal?

I'm not against the proposal, but I don't understand why we need this.

Thanks,
Laurent

#32 lore raw

Hi Laurent,

Quoted 41 lines · Laurent Vivier

Le 14/01/2021 à 16:49, Philippe Mathieu-Daudé a écrit :

Quoted 40 lines · Peter Maydell
Quoted 23 lines · Philippe Mathieu-Daudé
Quoted 15 lines

This is a proof-of-concept after chatting with Peter Maydell on IRC earlier.

Introduce the vmstate_no_state_to_migrate structure, and a reference to it: vmstate_qdev_no_state_to_migrate. Use this reference in devices with no fields to migrate.

This is useful to catch devices missing vmstate, such:
- ads7846
- mcf-uart
- mcf-fec
- versatile_i2c
- ...

Quoted 2 lines

I am not sure about:
- gpex-pcihost

I think it's correct that this has no internal state:
the only interesting state is in the GPEXRootState, which is a TYPE_GPEX_ROOT_DEVICE which migrates itself.

Quoted 6 lines

I made some comments on the "meaty" bits of the patchset, and reviewed one or two of the "mark this device as having no migration state" patches, but it doesn't seem worth reviewing all of them until the migration submaintainers have a chance to weigh in on whether they like the concept (I expect they're busy right now with freeze-related stuff :-))

Now that we are far from freeze-date is a good time to ping again on this concept :)

Most of the devices are ARM except:
- cpu-cluster (Eduardo/Marcel)
- hcd-ohci (Gerd)
- mac-nubus-bridge (Laurent)
- generic QOM (Daniel, Paolo)

Quoted 3 lines
Quoted 1 line

Is someone against this proposal?

I'm not against the proposal, but I don't understand why we need this.

IIRC the IRC discussion followed this thread:
https://www.mail-archive.com/[email protected]/msg554453.html

Quoting Peter:

Quoted 10 lines

I think we should care about migration on all architectures and devices, in the sense that we want savevm/loadvm to work. This is a really useful debugging and user tool, and when I'm reviewing devices it's the minimum bar I think new devices should clear. You then get migration "for free" but I don't particularly expect it to be used compared to snapshot save/restore. (Of course some of our existing code doesn't support this, and we don't have a good way of testing so bugs creep in easily, but as a principle I think it's good.)

Currently there is no automatic way to catch missing vmstate, we rely on code review (mostly from Peter...).

To be able to add a code check to catch the future device added, we need to first clean the (old) devices missing VMState, justifying why each doesn't have any field to migrate.

Also IMO it is simpler to have an unified API, rather than explaining each experienced and new contributor why "old style qdev" are allowed to do things than "new introduced qdev" can't do anymore.

Regards,

Phil.