diff mbox

[20/24] qdev: add weak aliases for vmstate handling on qdev.c

Message ID 1352473012-20500-21-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost Nov. 9, 2012, 2:56 p.m. UTC
Add weak alias to vmstate stub functions on qdev.c, so that qdev.o can
be used without savevm.o when vmstate support is not necessary (i.e. by
*-user).

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Originally submitted as:
  Subject: qdev-core: isolate vmstate handling into separate functions

Changes v1 -> v2:
 - Add GCC_WEAK_DECL to function declarations

Changes v2 -> v3:
 - Make vmstate_register_with_alias_id()/vmstate_unregister()
   have GCC_WEAK versions, instead of creating a new function
 - Kept qdev_get_vmsd() inside qdev.c

Changess v3 -> v4:
 - Use the new QEMU_WEAK_ALIAS system instead of GCC_WEAK
---
 hw/qdev.c | 24 ++++++++++++++++++++++++
 vmstate.h |  2 ++
 2 files changed, 26 insertions(+)
diff mbox

Patch

diff --git a/hw/qdev.c b/hw/qdev.c
index c242097..94ae1cd 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -76,6 +76,30 @@  void qemu_devices_reset(void)
     }
 }
 
+/* vmstate register/unregister:
+ *
+ * The real implementations are on qdev-system.c and savevm.c.
+ * Those are weak symbols used by *-user.
+ */
+
+static int stub_vmstate_register_with_alias_id(DeviceState *dev,
+                                               int instance_id,
+                                               const VMStateDescription *vmsd,
+                                               void *base, int alias_id,
+                                               int required_for_version)
+{
+    return 0;
+}
+QEMU_WEAK_ALIAS(vmstate_register_with_alias_id,
+                stub_vmstate_register_with_alias_id);
+
+static void stub_vmstate_unregister(DeviceState *dev,
+                                    const VMStateDescription *vmsd,
+                                    void *opaque)
+{
+}
+QEMU_WEAK_ALIAS(vmstate_unregister, stub_vmstate_unregister);
+
 const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
 {
     DeviceClass *dc = DEVICE_GET_CLASS(dev);
diff --git a/vmstate.h b/vmstate.h
index 623af0a..114c994 100644
--- a/vmstate.h
+++ b/vmstate.h
@@ -624,6 +624,8 @@  void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
                         void *opaque);
 int vmstate_register(DeviceState *dev, int instance_id,
                      const VMStateDescription *vmsd, void *base);
+
+/* The following functions have weak aliases on qdev-core, for *-user: */
 int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
                                    const VMStateDescription *vmsd,
                                    void *base, int alias_id,