diff mbox series

[RFC,03/10] hw/misc/vmcoreinfo: Un-inline vmcoreinfo_find()

Message ID 20241219153857.57450-4-philmd@linaro.org (mailing list archive)
State New
Headers show
Series hw/misc/vmcoreinfo: Convert from QDev to plain Object | expand

Commit Message

Philippe Mathieu-Daudé Dec. 19, 2024, 3:38 p.m. UTC
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/misc/vmcoreinfo.h | 13 ++++++-------
 hw/misc/vmcoreinfo.c         | 16 +++++++++++++---
 2 files changed, 19 insertions(+), 10 deletions(-)

Comments

Daniel P. Berrangé Dec. 19, 2024, 4:57 p.m. UTC | #1
On Thu, Dec 19, 2024 at 04:38:50PM +0100, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  include/hw/misc/vmcoreinfo.h | 13 ++++++-------
>  hw/misc/vmcoreinfo.c         | 16 +++++++++++++---
>  2 files changed, 19 insertions(+), 10 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


> diff --git a/hw/misc/vmcoreinfo.c b/hw/misc/vmcoreinfo.c
> index ad5a4dec596..c5bb5c9fa52 100644
> --- a/hw/misc/vmcoreinfo.c
> +++ b/hw/misc/vmcoreinfo.c
> @@ -42,11 +42,12 @@ static void vmcoreinfo_realize(DeviceState *dev, Error **errp)
>      /* for gdb script dump-guest-memory.py */
>      static VMCoreInfoState * volatile vmcoreinfo_state G_GNUC_UNUSED;
>  
> -    /* Given that this function is executing, there is at least one VMCOREINFO
> -     * device. Check if there are several.
> +    /*
> +     * Given that this function is executing, there is at least one
> +     * VMCOREINFO instance. Check if there are several.
>       */
>      if (!vmcoreinfo_find()) {
> -        error_setg(errp, "at most one %s device is permitted",
> +        error_setg(errp, "at most one %s instance is permitted",
>                     VMCOREINFO_DEVICE);
>          return;
>      }

This chunk is unrelated to the claimed goal of this
commit. It makes sense as a change though, so feel
free to add my R-B when splitting into a separate
commit.

> @@ -103,3 +104,12 @@ static const TypeInfo vmcoreinfo_types[] = {
>  };
>  
>  DEFINE_TYPES(vmcoreinfo_types)
> +
> +VMCoreInfoState *vmcoreinfo_find(void)
> +{
> +    Object *obj;
> +
> +    obj = object_resolve_path_type("", TYPE_VMCOREINFO_DEVICE, NULL);
> +
> +    return obj ? (VMCoreInfoState *)obj : NULL;
> +}

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


> -- 
> 2.47.1
> 

With regards,
Daniel
diff mbox series

Patch

diff --git a/include/hw/misc/vmcoreinfo.h b/include/hw/misc/vmcoreinfo.h
index 0b7b55d400a..da1066d540c 100644
--- a/include/hw/misc/vmcoreinfo.h
+++ b/include/hw/misc/vmcoreinfo.h
@@ -30,12 +30,11 @@  struct VMCoreInfoState {
     FWCfgVMCoreInfo vmcoreinfo;
 };
 
-/* returns NULL unless there is exactly one device */
-static inline VMCoreInfoState *vmcoreinfo_find(void)
-{
-    Object *o = object_resolve_path_type("", VMCOREINFO_DEVICE, NULL);
-
-    return o ? VMCOREINFO(o) : NULL;
-}
+/**
+ * vmcoreinfo_find:
+ *
+ * Returns NULL unless there is exactly one instance.
+ */
+VMCoreInfoState *vmcoreinfo_find(void);
 
 #endif
diff --git a/hw/misc/vmcoreinfo.c b/hw/misc/vmcoreinfo.c
index ad5a4dec596..c5bb5c9fa52 100644
--- a/hw/misc/vmcoreinfo.c
+++ b/hw/misc/vmcoreinfo.c
@@ -42,11 +42,12 @@  static void vmcoreinfo_realize(DeviceState *dev, Error **errp)
     /* for gdb script dump-guest-memory.py */
     static VMCoreInfoState * volatile vmcoreinfo_state G_GNUC_UNUSED;
 
-    /* Given that this function is executing, there is at least one VMCOREINFO
-     * device. Check if there are several.
+    /*
+     * Given that this function is executing, there is at least one
+     * VMCOREINFO instance. Check if there are several.
      */
     if (!vmcoreinfo_find()) {
-        error_setg(errp, "at most one %s device is permitted",
+        error_setg(errp, "at most one %s instance is permitted",
                    VMCOREINFO_DEVICE);
         return;
     }
@@ -103,3 +104,12 @@  static const TypeInfo vmcoreinfo_types[] = {
 };
 
 DEFINE_TYPES(vmcoreinfo_types)
+
+VMCoreInfoState *vmcoreinfo_find(void)
+{
+    Object *obj;
+
+    obj = object_resolve_path_type("", TYPE_VMCOREINFO_DEVICE, NULL);
+
+    return obj ? (VMCoreInfoState *)obj : NULL;
+}