Patchwork [20/24] qdev: add stub vmstate handling to qdev.c

login
register
mail settings
Submitter Eduardo Habkost
Date Nov. 9, 2012, 1:08 p.m.
Message ID <1352466519-5779-21-git-send-email-ehabkost@redhat.com>
Download mbox | patch
Permalink /patch/198065/
State New
Headers show

Comments

Eduardo Habkost - Nov. 9, 2012, 1:08 p.m.
Add GCC_WEAK vmstate symbols to qdev.c, so that qdev.o can be used
without savevm.o (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
---
 hw/qdev.c | 21 +++++++++++++++++++++
 vmstate.h |  6 ++++--
 2 files changed, 25 insertions(+), 2 deletions(-)
Eduardo Habkost - Nov. 9, 2012, 2:39 p.m.
On Fri, Nov 09, 2012 at 11:08:35AM -0200, Eduardo Habkost wrote:
> Add GCC_WEAK vmstate symbols to qdev.c, so that qdev.o can be used
> without savevm.o (i.e. by *-user).
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

So, this is now broken as GCC_WEAK is gone and now I have to use
QEMU_WEAK_ALIAS instead. I will send v7 of the series soon.

> ---
> 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
> ---
>  hw/qdev.c | 21 +++++++++++++++++++++
>  vmstate.h |  6 ++++--
>  2 files changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/qdev.c b/hw/qdev.c
> index c242097..fe4de96 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
> @@ -76,6 +76,27 @@ 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.
> + */
> +
> +GCC_WEAK int vmstate_register_with_alias_id(DeviceState *dev,
> +                                            int instance_id,
> +                                            const VMStateDescription *vmsd,
> +                                            void *base, int alias_id,
> +                                            int required_for_version)
> +{
> +    return 0;
> +}
> +
> +GCC_WEAK void vmstate_unregister(DeviceState *dev,
> +                                 const VMStateDescription *vmsd,
> +                                 void *opaque)
> +{
> +}
> +
>  const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
>  {
>      DeviceClass *dc = DEVICE_GET_CLASS(dev);
> diff --git a/vmstate.h b/vmstate.h
> index 623af0a..7a56b88 100644
> --- a/vmstate.h
> +++ b/vmstate.h
> @@ -624,11 +624,13 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
>                          void *opaque);
>  int vmstate_register(DeviceState *dev, int instance_id,
>                       const VMStateDescription *vmsd, void *base);
> -int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
> +
> +/* The following functions have GCC_WEAK stubs on qdev-core, for *-user: */
> +GCC_WEAK_DECL int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
>                                     const VMStateDescription *vmsd,
>                                     void *base, int alias_id,
>                                     int required_for_version);
> -void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,
> +GCC_WEAK_DECL void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,
>                          void *opaque);
>  
>  struct MemoryRegion;
> -- 
> 1.7.11.4
> 
>

Patch

diff --git a/hw/qdev.c b/hw/qdev.c
index c242097..fe4de96 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -76,6 +76,27 @@  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.
+ */
+
+GCC_WEAK int vmstate_register_with_alias_id(DeviceState *dev,
+                                            int instance_id,
+                                            const VMStateDescription *vmsd,
+                                            void *base, int alias_id,
+                                            int required_for_version)
+{
+    return 0;
+}
+
+GCC_WEAK void vmstate_unregister(DeviceState *dev,
+                                 const VMStateDescription *vmsd,
+                                 void *opaque)
+{
+}
+
 const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
 {
     DeviceClass *dc = DEVICE_GET_CLASS(dev);
diff --git a/vmstate.h b/vmstate.h
index 623af0a..7a56b88 100644
--- a/vmstate.h
+++ b/vmstate.h
@@ -624,11 +624,13 @@  void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
                         void *opaque);
 int vmstate_register(DeviceState *dev, int instance_id,
                      const VMStateDescription *vmsd, void *base);
-int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
+
+/* The following functions have GCC_WEAK stubs on qdev-core, for *-user: */
+GCC_WEAK_DECL int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
                                    const VMStateDescription *vmsd,
                                    void *base, int alias_id,
                                    int required_for_version);
-void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,
+GCC_WEAK_DECL void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,
                         void *opaque);
 
 struct MemoryRegion;