diff mbox series

[RFC,RESEND,05/42] accel/split: Expose 'hw' and 'sw' properties

Message ID 20250620172751.94231-6-philmd@linaro.org
State New
Headers show
Series accel/split/arm: Run EL2 using TCG and EL1/EL0 in hardware with HVF | expand

Commit Message

Philippe Mathieu-Daudé June 20, 2025, 5:27 p.m. UTC
In preparation of other accelerator (or potential emulator),
expose the "hw" and "sw" keys. Only HVF and TCG allowed so far.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/split/split-all.c | 46 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

Comments

Richard Henderson June 22, 2025, 2:26 a.m. UTC | #1
On 6/20/25 10:27, Philippe Mathieu-Daudé wrote:
> In preparation of other accelerator (or potential emulator),
> expose the "hw" and "sw" keys. Only HVF and TCG allowed so far.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   accel/split/split-all.c | 46 +++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 46 insertions(+)
> 
> diff --git a/accel/split/split-all.c b/accel/split/split-all.c
> index 7cbe32ea768..28f626d0ff4 100644
> --- a/accel/split/split-all.c
> +++ b/accel/split/split-all.c
> @@ -8,6 +8,7 @@
>   
>   #include "qemu/osdep.h"
>   #include "qemu/accel.h"
> +#include "qapi/error.h"
>   #include "hw/boards.h"
>   #include "accel/accel-internal.h"
>   #include "split-accel.h"
> @@ -78,6 +79,42 @@ static void split_get_stats(AccelState *as, GString *buf)
>       g_assert_not_reached();
>   }
>   
> +static char *split_get_hw(Object *obj, Error **errp)
> +{
> +    SplitAccelState *s = SPLIT_ACCEL(obj);
> +
> +    return g_strdup(s->hw_name);
> +}
> +
> +static void split_set_hw(Object *obj, const char *value, Error **errp)
> +{
> +    SplitAccelState *s = SPLIT_ACCEL(obj);
> +
> +    if (strcmp(value, "hvf") == 0) {
> +        s->hw_name = g_strdup(value);

Since you've compared, you could assign the literal and not strdup.
I.e.

     if (strcmp(value, "hvf") == 0) {
         s->hw_name = "hvf";


> +    } else {
> +        error_setg(errp, "'%s' accelerator no supported", value);

not

> +static char *split_get_sw(Object *obj, Error **errp)
> +{
> +    SplitAccelState *s = SPLIT_ACCEL(obj);
> +
> +    return g_strdup(s->sw_name);
> +}
> +
> +static void split_set_sw(Object *obj, const char *value, Error **errp)
> +{
> +    SplitAccelState *s = SPLIT_ACCEL(obj);
> +
> +    if (strcmp(value, "tcg") == 0) {
> +        s->hw_name = g_strdup(value);
> +    } else {
> +        error_setg(errp, "'%s' emulator no supported", value);
> +    }
> +}

Maybe just skip this until such time as there really is a second sw emulator.


r~
diff mbox series

Patch

diff --git a/accel/split/split-all.c b/accel/split/split-all.c
index 7cbe32ea768..28f626d0ff4 100644
--- a/accel/split/split-all.c
+++ b/accel/split/split-all.c
@@ -8,6 +8,7 @@ 
 
 #include "qemu/osdep.h"
 #include "qemu/accel.h"
+#include "qapi/error.h"
 #include "hw/boards.h"
 #include "accel/accel-internal.h"
 #include "split-accel.h"
@@ -78,6 +79,42 @@  static void split_get_stats(AccelState *as, GString *buf)
     g_assert_not_reached();
 }
 
+static char *split_get_hw(Object *obj, Error **errp)
+{
+    SplitAccelState *s = SPLIT_ACCEL(obj);
+
+    return g_strdup(s->hw_name);
+}
+
+static void split_set_hw(Object *obj, const char *value, Error **errp)
+{
+    SplitAccelState *s = SPLIT_ACCEL(obj);
+
+    if (strcmp(value, "hvf") == 0) {
+        s->hw_name = g_strdup(value);
+    } else {
+        error_setg(errp, "'%s' accelerator no supported", value);
+    }
+}
+
+static char *split_get_sw(Object *obj, Error **errp)
+{
+    SplitAccelState *s = SPLIT_ACCEL(obj);
+
+    return g_strdup(s->sw_name);
+}
+
+static void split_set_sw(Object *obj, const char *value, Error **errp)
+{
+    SplitAccelState *s = SPLIT_ACCEL(obj);
+
+    if (strcmp(value, "tcg") == 0) {
+        s->hw_name = g_strdup(value);
+    } else {
+        error_setg(errp, "'%s' emulator no supported", value);
+    }
+}
+
 static void split_accel_instance_init(Object *obj)
 {
     SplitAccelState *sas = SPLIT_ACCEL(obj);
@@ -100,6 +137,15 @@  static void split_accel_class_init(ObjectClass *oc, const void *data)
     ac->get_stats = split_get_stats;
     ac->allowed = &split_allowed;
     ac->compat_props = NULL;
+
+    object_class_property_add_str(oc, "hw",
+                                  split_get_hw,
+                                  split_set_hw);
+    object_class_property_set_description(oc, "hw", "Hardware accelerator");
+    object_class_property_add_str(oc, "sw",
+                                  split_get_sw,
+                                  split_set_sw);
+    object_class_property_set_description(oc, "sw", "Software emulator");
 }
 
 static const TypeInfo split_accel_type = {