Patchwork [RFC,09/13] qdev: move reset register/unregister code to qdev-system.c

login
register
mail settings
Submitter Eduardo Habkost
Date Oct. 4, 2012, 7:15 p.m.
Message ID <1349378133-25644-10-git-send-email-ehabkost@redhat.com>
Download mbox | patch
Permalink /patch/189284/
State New
Headers show

Comments

Eduardo Habkost - Oct. 4, 2012, 7:15 p.m.
Also, add weak symbols that will be used if qdev-system.o is not
compiled in (i.e. on *-user).

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/qdev-core.c   | 16 +++++++---------
 hw/qdev-core.h   |  3 +++
 hw/qdev-system.c | 15 +++++++++++++++
 3 files changed, 25 insertions(+), 9 deletions(-)
Anthony Liguori - Oct. 16, 2012, 2:13 p.m.
Eduardo Habkost <ehabkost@redhat.com> writes:

> Also, add weak symbols that will be used if qdev-system.o is not
> compiled in (i.e. on *-user).
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  hw/qdev-core.c   | 16 +++++++---------
>  hw/qdev-core.h   |  3 +++
>  hw/qdev-system.c | 15 +++++++++++++++
>  3 files changed, 25 insertions(+), 9 deletions(-)
>
> diff --git a/hw/qdev-core.c b/hw/qdev-core.c
> index 1b45e51..46ab239 100644
> --- a/hw/qdev-core.c
> +++ b/hw/qdev-core.c
> @@ -47,19 +47,17 @@ void GCC_WEAK qdev_finalize_vmstate(DeviceState *dev)
>  {
>  }
>  
> -static void qbus_register_reset(BusState *bus)
> +/* reset handler register/unregister:
> + *
> + * The real implementations are on qdev-system.c. Those are weak symbols
> + * used by *-user.
> + */
> +void GCC_WEAK qbus_register_reset(BusState *bus)
>  {
> -    if (bus != sysbus_get_default()) {
> -        /* TODO: once all bus devices are qdevified,
> -           only reset handler for main_system_bus should be registered here. */
> -        qemu_register_reset(qbus_reset_all_fn, bus);
> -    }
>  }
>  
> -static void qbus_unregister_reset(BusState *bus)
> +void GCC_WEAK qbus_unregister_reset(BusState *bus)
>  {
> -    assert(bus != sysbus_get_default()); /* main_system_bus is never freed */
> -    qemu_unregister_reset(qbus_reset_all_fn, bus);
>  }
>  
>  const char *qdev_fw_name(DeviceState *dev)
> diff --git a/hw/qdev-core.h b/hw/qdev-core.h
> index e9b6d6d..e10021d 100644
> --- a/hw/qdev-core.h
> +++ b/hw/qdev-core.h
> @@ -228,6 +228,9 @@ const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev);
>  void qdev_init_vmstate(DeviceState *dev);
>  void qdev_finalize_vmstate(DeviceState *dev);
>  
> +void qbus_register_reset(BusState *bus);
> +void qbus_unregister_reset(BusState *bus);

You also need to use GCC_WEAK_DECL here.

Regards,

Anthony Liguori

> +
>  const char *qdev_fw_name(DeviceState *dev);
>  
>  Object *qdev_get_machine(void);
> diff --git a/hw/qdev-system.c b/hw/qdev-system.c
> index b4d40e8..eca5fd5 100644
> --- a/hw/qdev-system.c
> +++ b/hw/qdev-system.c
> @@ -113,3 +113,18 @@ void qdev_finalize_vmstate(DeviceState *dev)
>          vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
>      }
>  }
> +
> +void qbus_register_reset(BusState *bus)
> +{
> +    if (bus != sysbus_get_default()) {
> +        /* TODO: once all bus devices are qdevified,
> +           only reset handler for main_system_bus should be registered here. */
> +        qemu_register_reset(qbus_reset_all_fn, bus);
> +    }
> +}
> +
> +void qbus_unregister_reset(BusState *bus)
> +{
> +    assert(bus != sysbus_get_default()); /* main_system_bus is never freed */
> +    qemu_unregister_reset(qbus_reset_all_fn, bus);
> +}
> -- 
> 1.7.11.4

Patch

diff --git a/hw/qdev-core.c b/hw/qdev-core.c
index 1b45e51..46ab239 100644
--- a/hw/qdev-core.c
+++ b/hw/qdev-core.c
@@ -47,19 +47,17 @@  void GCC_WEAK qdev_finalize_vmstate(DeviceState *dev)
 {
 }
 
-static void qbus_register_reset(BusState *bus)
+/* reset handler register/unregister:
+ *
+ * The real implementations are on qdev-system.c. Those are weak symbols
+ * used by *-user.
+ */
+void GCC_WEAK qbus_register_reset(BusState *bus)
 {
-    if (bus != sysbus_get_default()) {
-        /* TODO: once all bus devices are qdevified,
-           only reset handler for main_system_bus should be registered here. */
-        qemu_register_reset(qbus_reset_all_fn, bus);
-    }
 }
 
-static void qbus_unregister_reset(BusState *bus)
+void GCC_WEAK qbus_unregister_reset(BusState *bus)
 {
-    assert(bus != sysbus_get_default()); /* main_system_bus is never freed */
-    qemu_unregister_reset(qbus_reset_all_fn, bus);
 }
 
 const char *qdev_fw_name(DeviceState *dev)
diff --git a/hw/qdev-core.h b/hw/qdev-core.h
index e9b6d6d..e10021d 100644
--- a/hw/qdev-core.h
+++ b/hw/qdev-core.h
@@ -228,6 +228,9 @@  const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev);
 void qdev_init_vmstate(DeviceState *dev);
 void qdev_finalize_vmstate(DeviceState *dev);
 
+void qbus_register_reset(BusState *bus);
+void qbus_unregister_reset(BusState *bus);
+
 const char *qdev_fw_name(DeviceState *dev);
 
 Object *qdev_get_machine(void);
diff --git a/hw/qdev-system.c b/hw/qdev-system.c
index b4d40e8..eca5fd5 100644
--- a/hw/qdev-system.c
+++ b/hw/qdev-system.c
@@ -113,3 +113,18 @@  void qdev_finalize_vmstate(DeviceState *dev)
         vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
     }
 }
+
+void qbus_register_reset(BusState *bus)
+{
+    if (bus != sysbus_get_default()) {
+        /* TODO: once all bus devices are qdevified,
+           only reset handler for main_system_bus should be registered here. */
+        qemu_register_reset(qbus_reset_all_fn, bus);
+    }
+}
+
+void qbus_unregister_reset(BusState *bus)
+{
+    assert(bus != sysbus_get_default()); /* main_system_bus is never freed */
+    qemu_unregister_reset(qbus_reset_all_fn, bus);
+}