Patchwork [06/12] qdev: move vmstate handling to qdev-system.c

login
register
mail settings
Submitter Igor Mammedov
Date Oct. 16, 2012, 1:57 a.m.
Message ID <1350352644-14436-7-git-send-email-imammedo@redhat.com>
Download mbox | patch
Permalink /patch/191711/
State New
Headers show

Comments

Igor Mammedov - Oct. 16, 2012, 1:57 a.m.
From: Eduardo Habkost <ehabkost@redhat.com>

Add GCC_WEAK symbols to qdev-core.c, so that qdev-core.o can be used
without qdev-system.o (i.e. by *-user).

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/qdev-core.c   | 23 +++++++----------------
 hw/qdev-core.h   |  2 ++
 hw/qdev-system.c | 22 ++++++++++++++++++++++
 3 files changed, 31 insertions(+), 16 deletions(-)

Patch

diff --git a/hw/qdev-core.c b/hw/qdev-core.c
index 92c3021..af0af52 100644
--- a/hw/qdev-core.c
+++ b/hw/qdev-core.c
@@ -34,26 +34,17 @@  int qdev_hotplug = 0;
 static bool qdev_hot_added = false;
 static bool qdev_hot_removed = false;
 
-const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
-{
-    DeviceClass *dc = DEVICE_GET_CLASS(dev);
-    return dc->vmsd;
-}
-
-static void qdev_init_vmstate(DeviceState *dev)
+/* vmstate handling:
+ *
+ * The real implementations are on qdev-system.c. Those are weak symbols
+ * used by *-user.
+ */
+void GCC_WEAK qdev_init_vmstate(DeviceState *dev)
 {
-    if (qdev_get_vmsd(dev)) {
-        vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev,
-                                       dev->instance_id_alias,
-                                       dev->alias_required_for_version);
-    }
 }
 
-static void qdev_finalize_vmstate(DeviceState *dev)
+void GCC_WEAK qdev_finalize_vmstate(DeviceState *dev)
 {
-    if (qdev_get_vmsd(dev)) {
-        vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
-    }
 }
 
 const char *qdev_fw_name(DeviceState *dev)
diff --git a/hw/qdev-core.h b/hw/qdev-core.h
index fce9e22..924c6ea 100644
--- a/hw/qdev-core.h
+++ b/hw/qdev-core.h
@@ -223,6 +223,8 @@  void qdev_machine_init(void);
 void device_reset(DeviceState *dev);
 
 const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev);
+void qdev_init_vmstate(DeviceState *dev);
+void qdev_finalize_vmstate(DeviceState *dev);
 
 const char *qdev_fw_name(DeviceState *dev);
 
diff --git a/hw/qdev-system.c b/hw/qdev-system.c
index 490821f..27d1fc9 100644
--- a/hw/qdev-system.c
+++ b/hw/qdev-system.c
@@ -66,3 +66,25 @@  DeviceState *qdev_try_create(BusState *bus, const char *type)
 
     return dev;
 }
+
+const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
+{
+    DeviceClass *dc = DEVICE_GET_CLASS(dev);
+    return dc->vmsd;
+}
+
+void qdev_init_vmstate(DeviceState *dev)
+{
+    if (qdev_get_vmsd(dev)) {
+        vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev,
+                                       dev->instance_id_alias,
+                                       dev->alias_required_for_version);
+    }
+}
+
+void qdev_finalize_vmstate(DeviceState *dev)
+{
+    if (qdev_get_vmsd(dev)) {
+        vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
+    }
+}