[RFC 3/9] whpx: common: use whpx_cpu_instance_init on x86 only

Mohamed Mediouni posted 9 patches 3 months, 2 weeks ago
Maintainers: Peter Maydell <peter.maydell@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Sunil Muthuswamy <sunilmut@microsoft.com>
There is a newer version of this series
[RFC 3/9] whpx: common: use whpx_cpu_instance_init on x86 only
Posted by Mohamed Mediouni 3 months, 2 weeks ago
We aren't using it on arm64.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
 accel/whpx/whpx-common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c
index 0b23deb7c4..43d0200afd 100644
--- a/accel/whpx/whpx-common.c
+++ b/accel/whpx/whpx-common.c
@@ -486,9 +486,10 @@ static void whpx_set_kernel_irqchip(Object *obj, Visitor *v,
 
 static void whpx_cpu_accel_class_init(ObjectClass *oc, const void *data)
 {
+#ifdef __x86_64__
     AccelCPUClass *acc = ACCEL_CPU_CLASS(oc);
-
     acc->cpu_instance_init = whpx_cpu_instance_init;
+#endif
 }
 
 static const TypeInfo whpx_cpu_accel_type = {
-- 
2.39.5 (Apple Git-154)
Re: [RFC 3/9] whpx: common: use whpx_cpu_instance_init on x86 only
Posted by Philippe Mathieu-Daudé 3 months, 2 weeks ago
Hi Mohamed,

On 31/7/25 07:27, Mohamed Mediouni wrote:
> We aren't using it on arm64.
> 
> Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
> ---
>   accel/whpx/whpx-common.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c
> index 0b23deb7c4..43d0200afd 100644
> --- a/accel/whpx/whpx-common.c
> +++ b/accel/whpx/whpx-common.c
> @@ -486,9 +486,10 @@ static void whpx_set_kernel_irqchip(Object *obj, Visitor *v,
>   
>   static void whpx_cpu_accel_class_init(ObjectClass *oc, const void *data)
>   {
> +#ifdef __x86_64__
>       AccelCPUClass *acc = ACCEL_CPU_CLASS(oc);
> -
>       acc->cpu_instance_init = whpx_cpu_instance_init;
> +#endif
>   }

I'd rather keep whpx-*common* without any #ifdef'ry: add hooks
when architecture-specific code need to be handled, and add empty
arch stub when nothing to be done there (preferably with a comment
in the stub).