Convert the ignore-unknown-msr, intercept-msr-gp, and ssd OnOffAuto properties from manual visitor-based callbacks to property_add_qapi_enum().
Signed-off-by: Marc-André Lureau <[email protected]> --- target/i386/whpx/whpx-all.c | 102 +++++++++++++++----------------------------- 1 file changed, 34 insertions(+), 68 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 9d0c391e36f..6826ac5bb18 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -30,7 +30,7 @@ #include "qemu/error-report.h" #include "qapi/error.h" #include "qapi/qapi-types-common.h" -#include "qapi/qapi-visit-common.h" +#include "qapi/qapi-type-infos-common.h" #include "migration/blocker.h" #include "host-cpu.h" #include "accel/accel-cpu-target.h" @@ -1853,7 +1853,7 @@ void whpx_apply_breakpoints( } } -bool whpx_arch_supports_guest_debug(void) +bool whpx_arch_supports_guest_debug(void) { return true; } @@ -1938,7 +1938,7 @@ static int whpx_handle_hyperv_guestidle(CPUState *cpu) return whpx_handle_halt(cpu); } -static void whpx_vcpu_kick_out_of_hlt(CPUState *cpu) +static void whpx_vcpu_kick_out_of_hlt(CPUState *cpu) { WHV_REGISTER_VALUE reg; whpx_get_reg(cpu, WHvRegisterInternalActivityState, ®); @@ -2042,7 +2042,7 @@ static void whpx_vcpu_pre_run(CPUState *cpu) .Vector = irq, }; reg_count += 1; - /* + /* * When the Hyper-V APIC is enabled, to get out of HLT we * either have to request an interrupt or manually get it away * from HLT. @@ -2342,7 +2342,7 @@ int whpx_vcpu_run(CPUState *cpu) WHV_REGISTER_VALUE reg_values[3] = {0}; WHV_REGISTER_NAME reg_names[3]; UINT32 reg_count; - bool is_known_msr = 0; + bool is_known_msr = 0; bool raises_gpf = false; uint64_t val; @@ -2898,120 +2898,86 @@ void whpx_cpu_instance_init(CPUState *cs) * Partition support */ -static void whpx_set_unknown_msr(Object *obj, Visitor *v, - const char *name, void *opaque, - Error **errp) +static void whpx_set_unknown_msr(Object *obj, int value, Error **errp) { struct whpx_state *whpx = &whpx_global; - OnOffAuto mode; - - if (!visit_type_OnOffAuto(v, name, &mode, errp)) { - return; - } - switch (mode) { + switch (value) { case ON_OFF_AUTO_ON: whpx->ignore_unknown_msr = true; break; - case ON_OFF_AUTO_OFF: whpx->ignore_unknown_msr = false; break; - case ON_OFF_AUTO_AUTO: whpx->ignore_unknown_msr = true; break; default: - /* - * The value was checked in visit_type_OnOffAuto() above. If - * we get here, then something is wrong in QEMU. - */ - abort(); + g_assert_not_reached(); } } -static void whpx_set_intercept_msr_gp(Object *obj, Visitor *v, - const char *name, void *opaque, - Error **errp) +static void whpx_set_intercept_msr_gp(Object *obj, int value, Error **errp) { struct whpx_state *whpx = &whpx_global; - OnOffAuto mode; - - if (!visit_type_OnOffAuto(v, name, &mode, errp)) { - return; - } - switch (mode) { + switch (value) { case ON_OFF_AUTO_ON: whpx->intercept_msr_gp = true; break; - case ON_OFF_AUTO_OFF: whpx->intercept_msr_gp = false; break; - case ON_OFF_AUTO_AUTO: whpx->intercept_msr_gp = false; break; default: - /* - * The value was checked in visit_type_OnOffAuto() above. If - * we get here, then something is wrong in QEMU. - */ - abort(); + g_assert_not_reached(); } } -static void whpx_set_ssd(Object *obj, Visitor *v, - const char *name, void *opaque, - Error **errp) +static void whpx_set_ssd(Object *obj, int value, Error **errp) { struct whpx_state *whpx = &whpx_global; - OnOffAuto mode; - - if (!visit_type_OnOffAuto(v, name, &mode, errp)) { - return; - } - switch (mode) { + switch (value) { case ON_OFF_AUTO_ON: whpx->separate_security_domain = true; break; - case ON_OFF_AUTO_OFF: whpx->separate_security_domain = false; break; - case ON_OFF_AUTO_AUTO: whpx->separate_security_domain = true; break; default: - /* - * The value was checked in visit_type_OnOffAuto() above. If - * we get here, then something is wrong in QEMU. - */ - abort(); + g_assert_not_reached(); } } void whpx_arch_accel_class_init(ObjectClass *oc) { - object_class_property_add(oc, "ignore-unknown-msr", "OnOffAuto", - NULL, whpx_set_unknown_msr, - NULL, NULL); - object_class_property_set_description(oc, "ignore-unknown-msr", - "Configure unknown MSR behavior"); - object_class_property_add(oc, "intercept-msr-gp", "OnOffAuto", - NULL, whpx_set_intercept_msr_gp, - NULL, NULL); - object_class_property_set_description(oc, "intercept-msr-gp", - "Intercept #GP to log erroring MSR accesses."); - object_class_property_add(oc, "ssd", "OnOffAuto", - NULL, whpx_set_ssd, - NULL, NULL); - object_class_property_set_description(oc, "ssd", - "Separate security domain"); + object_class_property_add_qapi_enum(oc, QAPI_ENUM_PROP( + .name = "ignore-unknown-msr", + .description = "Configure unknown MSR behavior", + .qapi_type = &OnOffAuto_type_info, + .set = whpx_set_unknown_msr, + )); + + object_class_property_add_qapi_enum(oc, QAPI_ENUM_PROP( + .name = "intercept-msr-gp", + .description = "Intercept #GP to log erroring MSR accesses.", + .qapi_type = &OnOffAuto_type_info, + .set = whpx_set_intercept_msr_gp, + )); + + object_class_property_add_qapi_enum(oc, QAPI_ENUM_PROP( + .name = "ssd", + .description = "Separate security domain", + .qapi_type = &OnOffAuto_type_info, + .set = whpx_set_ssd, + )); } int whpx_accel_init(AccelState *as, MachineState *ms) -- 2.54.0
