> On 7. Mar 2026, at 16:53, Philippe Mathieu-Daudé <[email protected]> wrote:
>
> On 7/3/26 16:41, Mohamed Mediouni wrote:
>> Have them be a machine option instead of a CPU one, to have something
>> available, even if not ideal...
>> The existing Hyper-V enlightenments configuration mechanism is part of
>> per-CPU configuration, which happens too late for this.
>> Signed-off-by: Mohamed Mediouni <[email protected]>
>> ---
>> accel/whpx/whpx-common.c | 44 ++++++++++++++++++++++++++++++++++
>> include/system/whpx-internal.h | 4 ++++
>> target/i386/whpx/whpx-all.c | 20 +++++++++-------
>> 3 files changed, 59 insertions(+), 9 deletions(-)
>> diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c
>> index 4863fc8663..dae9ff0800 100644
>> --- a/accel/whpx/whpx-common.c
>> +++ b/accel/whpx/whpx-common.c
>> @@ -25,6 +25,7 @@
>> #include "qapi/qapi-visit-common.h"
>> #include "migration/blocker.h"
>> #include "accel/accel-cpu-target.h"
>> +#include "qemu/target-info.h"
>
> I suppose you meant "qapi/qapi-types-common.h”?
Skipping including the line at all :)
Context: in an earlier iteration added an arch check added here with using the
target_aarch64() function*,
but changed it for this rev.
* at the end, decided to use a bifurcated
hyperv_enlightenments_allowed/hyperv_enlightenments_required
design like for kernel-irqchip, with enlightenments off by default on arm64 but
on by default for x86, because
arm64 virt is cleaner architecturally by enough that enlightenments don’t
really matter there.
>
>> #include <winerror.h>
>> #include "system/whpx-internal.h"
>> @@ -470,6 +471,41 @@ static void whpx_set_kernel_irqchip(Object *obj,
>> Visitor *v,
>> }
>> }
>> +static void whpx_set_hyperv(Object *obj, Visitor *v,
>> + const char *name, void *opaque,
>> + Error **errp)
>> +{
>> + struct whpx_state *whpx = &whpx_global;
>> + OnOffAuto mode;
>> +
>> + if (!visit_type_OnOffAuto(v, name, &mode, errp)) {
>> + return;
>> + }
>> +
>> + switch (mode) {
>> + case ON_OFF_AUTO_ON:
>> + whpx->hyperv_enlightenments_allowed = true;
>> + whpx->hyperv_enlightenments_required = true;
>> + break;
>> +
>> + case ON_OFF_AUTO_OFF:
>> + whpx->hyperv_enlightenments_allowed = false;
>> + whpx->hyperv_enlightenments_required = false;
>> + break;
>> +
>> + case ON_OFF_AUTO_AUTO:
>> + whpx->hyperv_enlightenments_allowed = true;
>> + whpx->hyperv_enlightenments_required = false;
>> + break;
>> + default:
>> + /*
>> + * The value was checked in visit_type_OnOffAuto() above. If
>> + * we get here, then something is wrong in QEMU.
>> + */
>> + abort();
>> + }
>> +}
>> +
>> static void whpx_cpu_accel_class_init(ObjectClass *oc, const void *data)
>> {
>> AccelCPUClass *acc = ACCEL_CPU_CLASS(oc);
>> @@ -498,6 +534,11 @@ static void whpx_accel_class_init(ObjectClass *oc,
>> const void *data)
>> NULL, NULL);
>> object_class_property_set_description(oc, "kernel-irqchip",
>> "Configure WHPX in-kernel irqchip");
>> + object_class_property_add(oc, "hyperv", "OnOffAuto",
>> + NULL, whpx_set_hyperv,
>> + NULL, NULL);
>> + object_class_property_set_description(oc, "hyperv",
>> + "Configure Hyper-V enlightenments");
>> }
>> static void whpx_accel_instance_init(Object *obj)
>> @@ -507,6 +548,9 @@ static void whpx_accel_instance_init(Object *obj)
>> memset(whpx, 0, sizeof(struct whpx_state));
>> /* Turn on kernel-irqchip, by default */
>> whpx->kernel_irqchip_allowed = true;
>> +
>> + whpx->hyperv_enlightenments_allowed = true;
>> + whpx->hyperv_enlightenments_required = false;
>> }
>