diff mbox

[4/3] vmstate: complain about devices without vmstate

Message ID 1310132637-20611-1-git-send-email-kraxel@redhat.com
State New
Headers show

Commit Message

Gerd Hoffmann July 8, 2011, 1:43 p.m. UTC
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/hw.h   |    2 ++
 hw/qdev.c |    7 ++++++-
 2 files changed, 8 insertions(+), 1 deletions(-)
diff mbox

Patch

diff --git a/hw/hw.h b/hw/hw.h
index 1eb3486..6d6c493 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -336,6 +336,8 @@  struct VMStateDescription {
     const VMStateSubsection *subsections;
 };
 
+#define VMSD_NONE ((const VMStateDescription*)1)
+
 extern const VMStateInfo vmstate_info_bool;
 
 extern const VMStateInfo vmstate_info_int8;
diff --git a/hw/qdev.c b/hw/qdev.c
index 292b52f..fafbbae 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -283,7 +283,12 @@  int qdev_init(DeviceState *dev)
         qdev_free(dev);
         return rc;
     }
-    if (dev->info->vmsd) {
+    if (dev->info->vmsd == NULL) {
+        /* TODO: fixup qemu source code, then make this an assert() */
+        error_report("WARNING: device %s has no vmstate\n", dev->info->name);
+    } else if (dev->info->vmsd == VMSD_NONE) {
+        /* device doesn't need vmstate */;
+    } else {
         vmstate_register_with_alias_id(dev, -1, dev->info->vmsd, dev,
                                        dev->instance_id_alias,
                                        dev->alias_required_for_version);