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

Philippe Mathieu-Daudé posted 10 patches 2 days, 10 hours ago
There is a newer version of this series
[RFC PATCH 03/10] hw/misc/vmcoreinfo: Un-inline vmcoreinfo_find()
Posted by Philippe Mathieu-Daudé 2 days, 10 hours ago
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(-)

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;
+}
-- 
2.47.1
Re: [RFC PATCH 03/10] hw/misc/vmcoreinfo: Un-inline vmcoreinfo_find()
Posted by Daniel P. Berrangé 2 days, 9 hours ago
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
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|