On Wed, 20 May 2020 15:20:02 +0200 Gerd Hoffmann <kra...@redhat.com> wrote:
> Allow setting acpi default value for each machine type. > > Signed-off-by: Gerd Hoffmann <kra...@redhat.com> > --- > include/hw/i386/x86.h | 1 + > hw/i386/x86.c | 21 ++++++++++++++++++--- > 2 files changed, 19 insertions(+), 3 deletions(-) > > diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h > index b52285481687..d2fffa8252ff 100644 > --- a/include/hw/i386/x86.h > +++ b/include/hw/i386/x86.h > @@ -37,6 +37,7 @@ typedef struct { > bool save_tsc_khz; > /* Enables contiguous-apic-ID mode */ > bool compat_apic_id_mode; > + bool acpi_default; > } X86MachineClass; > > typedef struct { > diff --git a/hw/i386/x86.c b/hw/i386/x86.c > index ac7a0a958781..3a56a157c5f0 100644 > --- a/hw/i386/x86.c > +++ b/hw/i386/x86.c > @@ -940,10 +940,22 @@ static void x86_machine_set_smm(Object *obj, Visitor > *v, const char *name, > > bool x86_machine_is_acpi_enabled(X86MachineState *x86ms) > { > - if (x86ms->acpi == ON_OFF_AUTO_OFF) { > - return false; > + X86MachineClass *x86mc = X86_MACHINE_GET_CLASS(x86ms); > + bool enabled; > + > + switch (x86ms->acpi) { > + case ON_OFF_AUTO_ON: > + enabled = true; > + break; > + case ON_OFF_AUTO_OFF: > + enabled = false; > + break; > + case ON_OFF_AUTO_AUTO: > + default: > + enabled = x86mc->acpi_default; > + break; > } > - return true; > + return enabled; why not make x86ms->acpi a boolean and move logic from here to x86_machine_[get|set]_acpi() to avoid extra helper, the external users would use property acessesors and internal (microvm code) can just access x86ms->acpi directly > } > > static void x86_machine_get_acpi(Object *obj, Visitor *v, const char *name, > @@ -991,6 +1003,9 @@ static void x86_machine_class_init(ObjectClass *oc, void > *data) > x86mc->save_tsc_khz = true; > nc->nmi_monitor_handler = x86_nmi; > > + /* acpi is on by default */ > + x86mc->acpi_default = true; > + > object_class_property_add(oc, X86_MACHINE_MAX_RAM_BELOW_4G, "size", > x86_machine_get_max_ram_below_4g, x86_machine_set_max_ram_below_4g, > NULL, NULL);