Skip to contentSkip to conversation

multi-target: restrict whpx-accel-*-cpu to matching target

PATCH In review Pierrick Bouvier 2 participants 5 messages Nov 6

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 multi-target: restrict whpx-accel-*-cpu to matching target

On windows x64 host:

$ ./build/tests/unit/test-multi-target
Type 'whpx-accel-x86_64-cpu' is missing its parent 'accel-x86_64-cpu'
(same for windows-arm64 hosts and whpx-accel-aarch64-cpu)

Parent type is conditionally registered from current target:
register_accel_target_type uses '"accel-" + target_cpu_type()' as type name. Since whpx-common.c is shared between arm and x86_64 targets, only register whpx accelerator cpu type when current target cpu type matches the one it was compiled for.

---
 accel/whpx/whpx-common.c | 8 ++++++++
 1 file changed, 8 insertions(+)
accel/whpx/whpx-common.c +8 -0
index 78d2827809b..20c684638b0 100644
@@ -20,6 +20,7 @@
 #include "hw/core/boards.h"
 #include "hw/intc/ioapic.h"
 #include "qemu/error-report.h"
+#include "qemu/target-info.h"
 #include "qapi/error.h"
 #include "qapi/qapi-types-common.h"
 #include "qapi/qapi-type-infos-common.h"
@@ -492,11 +493,18 @@ static void whpx_cpu_accel_class_init(ObjectClass *oc, const void *data)
     acc->cpu_instance_init = whpx_cpu_instance_init;
 }
 
+/* TYPE_ACCEL_CPU is only registered for current target cpu type */
+static bool whpx_cpu_accel_is_available(void)
+{
+    return !strcmp(target_cpu_type(), CPU_RESOLVING_TYPE);
+}
+
 static const TypeInfo whpx_cpu_accel_type = {
     .name = ACCEL_CPU_NAME("whpx"),
 
     .parent = TYPE_ACCEL_CPU,
     .class_init = whpx_cpu_accel_class_init,
+    .is_available = whpx_cpu_accel_is_available,
     .abstract = true,
 };
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 50 lines · Pierrick Bouvier

On windows x64 host:

$ ./build/tests/unit/test-multi-target
Type 'whpx-accel-x86_64-cpu' is missing its parent 'accel-x86_64-cpu'
(same for windows-arm64 hosts and whpx-accel-aarch64-cpu)

Parent type is conditionally registered from current target:
register_accel_target_type uses '"accel-" + target_cpu_type()' as type name. Since whpx-common.c is shared between arm and x86_64 targets, only register whpx accelerator cpu type when current target cpu type matches the one it was compiled for.

---
 accel/whpx/whpx-common.c | 8 ++++++++
 1 file changed, 8 insertions(+)
accel/whpx/whpx-common.c +8 -1
index 78d2827809b..20c684638b0 100644
@@ -20,6 +20,7 @@
 #include "hw/core/boards.h"
 #include "hw/intc/ioapic.h"
 #include "qemu/error-report.h"
+#include "qemu/target-info.h"
 #include "qapi/error.h"
 #include "qapi/qapi-types-common.h"
 #include "qapi/qapi-type-infos-common.h"
@@ -492,11 +493,18 @@ static void whpx_cpu_accel_class_init(ObjectClass *oc, const void *data)
     acc->cpu_instance_init = whpx_cpu_instance_init;
 }
 
+/* TYPE_ACCEL_CPU is only registered for current target cpu type */
+static bool whpx_cpu_accel_is_available(void)
+{
+    return !strcmp(target_cpu_type(), CPU_RESOLVING_TYPE);
+}
+
 static const TypeInfo whpx_cpu_accel_type = {
     .name = ACCEL_CPU_NAME("whpx"),
 
     .parent = TYPE_ACCEL_CPU,
     .class_init = whpx_cpu_accel_class_init,
+    .is_available = whpx_cpu_accel_is_available,
     .abstract = true,
 };
 
--
Quoted 3 lines

2.43.0

Hi, I think

[PATCH v5 0/3] Register accel-$cpu_type for all targets
https://lore.kernel.org/qemu-devel/[email protected]/

should also handled this. so this is_available do not need anymore.

Signature · 6 lines
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
#2 lore raw
Quoted 58 lines · Yonggang Luo
Quoted 50 lines · Pierrick Bouvier

On windows x64 host:

$ ./build/tests/unit/test-multi-target
Type 'whpx-accel-x86_64-cpu' is missing its parent 'accel-x86_64-cpu'
(same for windows-arm64 hosts and whpx-accel-aarch64-cpu)

Parent type is conditionally registered from current target:
register_accel_target_type uses '"accel-" + target_cpu_type()' as type name. Since whpx-common.c is shared between arm and x86_64 targets, only register whpx accelerator cpu type when current target cpu type matches the one it was compiled for.

---
 accel/whpx/whpx-common.c | 8 ++++++++
 1 file changed, 8 insertions(+)
accel/whpx/whpx-common.c +8 -1
index 78d2827809b..20c684638b0 100644
@@ -20,6 +20,7 @@
 #include "hw/core/boards.h"
 #include "hw/intc/ioapic.h"
 #include "qemu/error-report.h"
+#include "qemu/target-info.h"
 #include "qapi/error.h"
 #include "qapi/qapi-types-common.h"
 #include "qapi/qapi-type-infos-common.h"
@@ -492,11 +493,18 @@ static void whpx_cpu_accel_class_init(ObjectClass *oc, const void *data)
     acc->cpu_instance_init = whpx_cpu_instance_init;
 }
 
+/* TYPE_ACCEL_CPU is only registered for current target cpu type */
+static bool whpx_cpu_accel_is_available(void)
+{
+    return !strcmp(target_cpu_type(), CPU_RESOLVING_TYPE);
+}
+
 static const TypeInfo whpx_cpu_accel_type = {
     .name = ACCEL_CPU_NAME("whpx"),
 
     .parent = TYPE_ACCEL_CPU,
     .class_init = whpx_cpu_accel_class_init,
+    .is_available = whpx_cpu_accel_is_available,
     .abstract = true,
 };
 
--
Quoted 3 lines

2.43.0

Hi, I think

Quoted 5 lines

[PATCH v5 0/3] Register accel-$cpu_type for all targets
https://lore.kernel.org/qemu-devel/[email protected]/

should also handled this. so this is_available do not need anymore.

I would prefer to send the accel series later, giving time for additional reviews, if anyone has an objection.

the whpx fix is needed now as the test fails on windows at the moment. the patch can be removed after, no problem.

Regards,
Pierrick

#3 lore raw
Quoted 60 lines · Pierrick Bouvier
Quoted 58 lines · Yonggang Luo
Quoted 50 lines · Pierrick Bouvier

On windows x64 host:

$ ./build/tests/unit/test-multi-target
Type 'whpx-accel-x86_64-cpu' is missing its parent 'accel-x86_64-cpu'
(same for windows-arm64 hosts and whpx-accel-aarch64-cpu)

Parent type is conditionally registered from current target:
register_accel_target_type uses '"accel-" + target_cpu_type()' as type name. Since whpx-common.c is shared between arm and x86_64 targets, only register whpx accelerator cpu type when current target cpu type matches the one it was compiled for.

---
 accel/whpx/whpx-common.c | 8 ++++++++
 1 file changed, 8 insertions(+)
accel/whpx/whpx-common.c +8 -1
index 78d2827809b..20c684638b0 100644
@@ -20,6 +20,7 @@
 #include "hw/core/boards.h"
 #include "hw/intc/ioapic.h"
 #include "qemu/error-report.h"
+#include "qemu/target-info.h"
 #include "qapi/error.h"
 #include "qapi/qapi-types-common.h"
 #include "qapi/qapi-type-infos-common.h"
@@ -492,11 +493,18 @@ static void whpx_cpu_accel_class_init(ObjectClass *oc, const void *data)
     acc->cpu_instance_init = whpx_cpu_instance_init;
 }
 
+/* TYPE_ACCEL_CPU is only registered for current target cpu type */
+static bool whpx_cpu_accel_is_available(void)
+{
+    return !strcmp(target_cpu_type(), CPU_RESOLVING_TYPE);
+}
+
 static const TypeInfo whpx_cpu_accel_type = {
     .name = ACCEL_CPU_NAME("whpx"),
 
     .parent = TYPE_ACCEL_CPU,
     .class_init = whpx_cpu_accel_class_init,
+    .is_available = whpx_cpu_accel_is_available,
     .abstract = true,
 };
 
--
Quoted 3 lines

2.43.0

Hi, I think

Quoted 8 lines
Quoted 5 lines

[PATCH v5 0/3] Register accel-$cpu_type for all targets
https://lore.kernel.org/qemu-devel/[email protected]/

should also handled this. so this is_available do not need anymore.

I would prefer to send the accel series later, giving time for additional reviews, if anyone has an objection.

Thanks, I got your intention now, it's fine to revert this after the new release.

Quoted 6 lines

the whpx fix is needed now as the test fails on windows at the moment. the patch can be removed after, no problem.

Regards,
Pierrick

Signature · 6 lines
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
#4 lore raw
In reply to Pierrick Bouvier
Quoted 11 lines · Pierrick Bouvier

On windows x64 host:

$ ./build/tests/unit/test-multi-target
Type 'whpx-accel-x86_64-cpu' is missing its parent 'accel-x86_64-cpu'
(same for windows-arm64 hosts and whpx-accel-aarch64-cpu)

Parent type is conditionally registered from current target:
register_accel_target_type uses '"accel-" + target_cpu_type()' as type name. Since whpx-common.c is shared between arm and x86_64 targets, only register whpx accelerator cpu type when current target cpu type matches the one it was compiled for.

Quoted 6 lines
---
 accel/whpx/whpx-common.c | 8 ++++++++
 1 file changed, 8 insertions(+)

This was merged into master (71f25c75417d31c214ba2cd26b273c114fc99987).

Regards,
Pierrick