Message ID | 20200320100136.11717-1-kraxel@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | acpi: add acpi=OnOffAuto machine property to x86 and arm virt | expand |
On 3/20/20 11:01 AM, Gerd Hoffmann wrote: > Remove the global acpi_enabled bool and replace it with an > acpi OnOffAuto machine property. > > qemu throws an error now if you use -no-acpi while the machine > type you are using doesn't support acpi in the first place. > Suggested-by: Paolo Bonzini <pbonzini@redhat.com> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Nice cleanup. Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> > --- > include/hw/acpi/acpi.h | 1 - > include/hw/arm/virt.h | 2 ++ > include/hw/i386/x86.h | 3 +++ > hw/arm/virt-acpi-build.c | 2 +- > hw/arm/virt.c | 36 ++++++++++++++++++++++++++++++++++-- > hw/i386/acpi-build.c | 2 +- > hw/i386/pc.c | 4 ++-- > hw/i386/pc_piix.c | 2 +- > hw/i386/x86.c | 32 ++++++++++++++++++++++++++++++++ > softmmu/vl.c | 4 ++-- > 10 files changed, 78 insertions(+), 10 deletions(-) > > diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h > index 1f2dafbd7db6..4bef57531229 100644 > --- a/include/hw/acpi/acpi.h > +++ b/include/hw/acpi/acpi.h > @@ -181,7 +181,6 @@ void acpi_send_gpe_event(ACPIREGS *ar, qemu_irq irq, > void acpi_update_sci(ACPIREGS *acpi_regs, qemu_irq irq); > > /* acpi.c */ > -extern int acpi_enabled; > extern char unsigned *acpi_tables; > extern size_t acpi_tables_len; > > diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h > index 893796d3b06b..60b2f521eb47 100644 > --- a/include/hw/arm/virt.h > +++ b/include/hw/arm/virt.h > @@ -131,6 +131,7 @@ typedef struct { > bool highmem_ecam; > bool its; > bool virt; > + OnOffAuto acpi; > VirtGICType gic_version; > VirtIOMMUType iommu; > uint16_t virtio_iommu_bdf; > @@ -163,6 +164,7 @@ typedef struct { > OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_VIRT_MACHINE) > > void virt_acpi_setup(VirtMachineState *vms); > +bool virt_is_acpi_enabled(VirtMachineState *vms); > > /* Return the number of used redistributor regions */ > static inline int virt_gicv3_redist_region_count(VirtMachineState *vms) > diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h > index 22babcb3bb8d..54af8ab5cfae 100644 > --- a/include/hw/i386/x86.h > +++ b/include/hw/i386/x86.h > @@ -64,6 +64,7 @@ typedef struct { > unsigned smp_dies; > > OnOffAuto smm; > + OnOffAuto acpi; > > /* > * Address space used by IOAPIC device. All IOAPIC interrupts > @@ -74,6 +75,7 @@ typedef struct { > > #define X86_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g" > #define X86_MACHINE_SMM "smm" > +#define X86_MACHINE_ACPI "acpi" > > #define TYPE_X86_MACHINE MACHINE_TYPE_NAME("x86") > #define X86_MACHINE(obj) \ > @@ -104,6 +106,7 @@ void x86_load_linux(X86MachineState *x86ms, > bool linuxboot_dma_enabled); > > bool x86_machine_is_smm_enabled(X86MachineState *x86ms); > +bool x86_machine_is_acpi_enabled(X86MachineState *x86ms); > > /* Global System Interrupts */ > > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c > index fb4b166f82c7..7ef0733d7147 100644 > --- a/hw/arm/virt-acpi-build.c > +++ b/hw/arm/virt-acpi-build.c > @@ -910,7 +910,7 @@ void virt_acpi_setup(VirtMachineState *vms) > return; > } > > - if (!acpi_enabled) { > + if (!virt_is_acpi_enabled(vms)) { > trace_virt_acpi_setup(); > return; > } > diff --git a/hw/arm/virt.c b/hw/arm/virt.c > index 94f93dda54f2..7dc96abf72cf 100644 > --- a/hw/arm/virt.c > +++ b/hw/arm/virt.c > @@ -67,6 +67,7 @@ > #include "kvm_arm.h" > #include "hw/firmware/smbios.h" > #include "qapi/visitor.h" > +#include "qapi/qapi-visit-common.h" > #include "standard-headers/linux/input.h" > #include "hw/arm/smmuv3.h" > #include "hw/acpi/acpi.h" > @@ -1844,7 +1845,7 @@ static void machvirt_init(MachineState *machine) > > create_pcie(vms); > > - if (has_ged && aarch64 && firmware_loaded && acpi_enabled) { > + if (has_ged && aarch64 && firmware_loaded && virt_is_acpi_enabled(vms)) { > vms->acpi_dev = create_acpi_ged(vms); > } else { > create_gpio(vms); > @@ -1934,6 +1935,31 @@ static void virt_set_its(Object *obj, bool value, Error **errp) > vms->its = value; > } > > +bool virt_is_acpi_enabled(VirtMachineState *vms) > +{ > + if (vms->acpi == ON_OFF_AUTO_OFF) { > + return false; > + } > + return true; > +} > + > +static void virt_get_acpi(Object *obj, Visitor *v, const char *name, > + void *opaque, Error **errp) > +{ > + VirtMachineState *vms = VIRT_MACHINE(obj); > + OnOffAuto acpi = vms->acpi; > + > + visit_type_OnOffAuto(v, name, &acpi, errp); > +} > + > +static void virt_set_acpi(Object *obj, Visitor *v, const char *name, > + void *opaque, Error **errp) > +{ > + VirtMachineState *vms = VIRT_MACHINE(obj); > + > + visit_type_OnOffAuto(v, name, &vms->acpi, errp); > +} > + > static char *virt_get_gic_version(Object *obj, Error **errp) > { > VirtMachineState *vms = VIRT_MACHINE(obj); > @@ -2113,7 +2139,7 @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, > if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { > VirtMachineState *vms = VIRT_MACHINE(machine); > > - if (!vms->bootinfo.firmware_loaded || !acpi_enabled) { > + if (!vms->bootinfo.firmware_loaded || !virt_is_acpi_enabled(vms)) { > return HOTPLUG_HANDLER(machine); > } > } > @@ -2184,6 +2210,12 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) > mc->numa_mem_supported = true; > mc->auto_enable_numa_with_memhp = true; > mc->default_ram_id = "mach-virt.ram"; > + > + object_class_property_add(oc, "acpi", "OnOffAuto", > + virt_get_acpi, virt_set_acpi, > + NULL, NULL, &error_abort); > + object_class_property_set_description(oc, "acpi", > + "Enable ACPI", &error_abort); > } > > static void virt_instance_init(Object *obj) > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c > index 9a19c14e661b..2a7e55bae765 100644 > --- a/hw/i386/acpi-build.c > +++ b/hw/i386/acpi-build.c > @@ -3024,7 +3024,7 @@ void acpi_setup(void) > return; > } > > - if (!acpi_enabled) { > + if (!x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) { > ACPI_BUILD_DPRINTF("ACPI disabled. Bailing out.\n"); > return; > } > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > index 98ee763f68f8..0bf0aaca5201 100644 > --- a/hw/i386/pc.c > +++ b/hw/i386/pc.c > @@ -1297,7 +1297,7 @@ static void pc_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, > * but pcms->acpi_dev is still created. Check !acpi_enabled in > * addition to cover this case. > */ > - if (!pcms->acpi_dev || !acpi_enabled) { > + if (!pcms->acpi_dev || !x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) { > error_setg(errp, > "memory hotplug is not enabled: missing acpi device or acpi disabled"); > return; > @@ -1351,7 +1351,7 @@ static void pc_memory_unplug_request(HotplugHandler *hotplug_dev, > * but pcms->acpi_dev is still created. Check !acpi_enabled in > * addition to cover this case. > */ > - if (!pcms->acpi_dev || !acpi_enabled) { > + if (!pcms->acpi_dev || !x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) { > error_setg(&local_err, > "memory hotplug is not enabled: missing acpi device or acpi disabled"); > goto out; > diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c > index e6756216f9f4..9cceae3e2c35 100644 > --- a/hw/i386/pc_piix.c > +++ b/hw/i386/pc_piix.c > @@ -275,7 +275,7 @@ static void pc_init1(MachineState *machine, > pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci"); > } > > - if (pcmc->pci_enabled && acpi_enabled) { > + if (pcmc->pci_enabled && x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) { > DeviceState *piix4_pm; > > smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0); > diff --git a/hw/i386/x86.c b/hw/i386/x86.c > index 87b73fe33cd2..6ca3cf936f38 100644 > --- a/hw/i386/x86.c > +++ b/hw/i386/x86.c > @@ -904,11 +904,37 @@ static void x86_machine_set_smm(Object *obj, Visitor *v, const char *name, > visit_type_OnOffAuto(v, name, &x86ms->smm, errp); > } > > +bool x86_machine_is_acpi_enabled(X86MachineState *x86ms) > +{ > + if (x86ms->acpi == ON_OFF_AUTO_OFF) { > + return false; > + } > + return true; > +} > + > +static void x86_machine_get_acpi(Object *obj, Visitor *v, const char *name, > + void *opaque, Error **errp) > +{ > + X86MachineState *x86ms = X86_MACHINE(obj); > + OnOffAuto acpi = x86ms->acpi; > + > + visit_type_OnOffAuto(v, name, &acpi, errp); > +} > + > +static void x86_machine_set_acpi(Object *obj, Visitor *v, const char *name, > + void *opaque, Error **errp) > +{ > + X86MachineState *x86ms = X86_MACHINE(obj); > + > + visit_type_OnOffAuto(v, name, &x86ms->acpi, errp); > +} > + > static void x86_machine_initfn(Object *obj) > { > X86MachineState *x86ms = X86_MACHINE(obj); > > x86ms->smm = ON_OFF_AUTO_AUTO; > + x86ms->acpi = ON_OFF_AUTO_AUTO; > x86ms->max_ram_below_4g = 0; /* use default */ > x86ms->smp_dies = 1; > } > @@ -937,6 +963,12 @@ static void x86_machine_class_init(ObjectClass *oc, void *data) > NULL, NULL, &error_abort); > object_class_property_set_description(oc, X86_MACHINE_SMM, > "Enable SMM", &error_abort); > + > + object_class_property_add(oc, X86_MACHINE_ACPI, "OnOffAuto", > + x86_machine_get_acpi, x86_machine_set_acpi, > + NULL, NULL, &error_abort); > + object_class_property_set_description(oc, X86_MACHINE_ACPI, > + "Enable ACPI", &error_abort); > } > > static const TypeInfo x86_machine_info = { > diff --git a/softmmu/vl.c b/softmmu/vl.c > index 1d33a2834037..9f06bd4bf0a7 100644 > --- a/softmmu/vl.c > +++ b/softmmu/vl.c > @@ -144,7 +144,6 @@ static Chardev **serial_hds; > Chardev *parallel_hds[MAX_PARALLEL_PORTS]; > int win2k_install_hack = 0; > int singlestep = 0; > -int acpi_enabled = 1; > int no_hpet = 0; > int fd_bootchk = 1; > static int no_reboot; > @@ -3513,7 +3512,8 @@ void qemu_init(int argc, char **argv, char **envp) > vnc_parse(optarg, &error_fatal); > break; > case QEMU_OPTION_no_acpi: > - acpi_enabled = 0; > + olist = qemu_find_opts("machine"); > + qemu_opts_parse_noisily(olist, "acpi=off", false); > break; > case QEMU_OPTION_no_hpet: > no_hpet = 1; >
On 20/03/20 11:01, Gerd Hoffmann wrote: > Remove the global acpi_enabled bool and replace it with an > acpi OnOffAuto machine property. > > qemu throws an error now if you use -no-acpi while the machine > type you are using doesn't support acpi in the first place. > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> > --- > include/hw/acpi/acpi.h | 1 - > include/hw/arm/virt.h | 2 ++ > include/hw/i386/x86.h | 3 +++ > hw/arm/virt-acpi-build.c | 2 +- > hw/arm/virt.c | 36 ++++++++++++++++++++++++++++++++++-- > hw/i386/acpi-build.c | 2 +- > hw/i386/pc.c | 4 ++-- > hw/i386/pc_piix.c | 2 +- > hw/i386/x86.c | 32 ++++++++++++++++++++++++++++++++ > softmmu/vl.c | 4 ++-- > 10 files changed, 78 insertions(+), 10 deletions(-) > > diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h > index 1f2dafbd7db6..4bef57531229 100644 > --- a/include/hw/acpi/acpi.h > +++ b/include/hw/acpi/acpi.h > @@ -181,7 +181,6 @@ void acpi_send_gpe_event(ACPIREGS *ar, qemu_irq irq, > void acpi_update_sci(ACPIREGS *acpi_regs, qemu_irq irq); > > /* acpi.c */ > -extern int acpi_enabled; > extern char unsigned *acpi_tables; > extern size_t acpi_tables_len; > > diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h > index 893796d3b06b..60b2f521eb47 100644 > --- a/include/hw/arm/virt.h > +++ b/include/hw/arm/virt.h > @@ -131,6 +131,7 @@ typedef struct { > bool highmem_ecam; > bool its; > bool virt; > + OnOffAuto acpi; > VirtGICType gic_version; > VirtIOMMUType iommu; > uint16_t virtio_iommu_bdf; > @@ -163,6 +164,7 @@ typedef struct { > OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_VIRT_MACHINE) > > void virt_acpi_setup(VirtMachineState *vms); > +bool virt_is_acpi_enabled(VirtMachineState *vms); > > /* Return the number of used redistributor regions */ > static inline int virt_gicv3_redist_region_count(VirtMachineState *vms) > diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h > index 22babcb3bb8d..54af8ab5cfae 100644 > --- a/include/hw/i386/x86.h > +++ b/include/hw/i386/x86.h > @@ -64,6 +64,7 @@ typedef struct { > unsigned smp_dies; > > OnOffAuto smm; > + OnOffAuto acpi; > > /* > * Address space used by IOAPIC device. All IOAPIC interrupts > @@ -74,6 +75,7 @@ typedef struct { > > #define X86_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g" > #define X86_MACHINE_SMM "smm" > +#define X86_MACHINE_ACPI "acpi" > > #define TYPE_X86_MACHINE MACHINE_TYPE_NAME("x86") > #define X86_MACHINE(obj) \ > @@ -104,6 +106,7 @@ void x86_load_linux(X86MachineState *x86ms, > bool linuxboot_dma_enabled); > > bool x86_machine_is_smm_enabled(X86MachineState *x86ms); > +bool x86_machine_is_acpi_enabled(X86MachineState *x86ms); > > /* Global System Interrupts */ > > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c > index fb4b166f82c7..7ef0733d7147 100644 > --- a/hw/arm/virt-acpi-build.c > +++ b/hw/arm/virt-acpi-build.c > @@ -910,7 +910,7 @@ void virt_acpi_setup(VirtMachineState *vms) > return; > } > > - if (!acpi_enabled) { > + if (!virt_is_acpi_enabled(vms)) { > trace_virt_acpi_setup(); > return; > } > diff --git a/hw/arm/virt.c b/hw/arm/virt.c > index 94f93dda54f2..7dc96abf72cf 100644 > --- a/hw/arm/virt.c > +++ b/hw/arm/virt.c > @@ -67,6 +67,7 @@ > #include "kvm_arm.h" > #include "hw/firmware/smbios.h" > #include "qapi/visitor.h" > +#include "qapi/qapi-visit-common.h" > #include "standard-headers/linux/input.h" > #include "hw/arm/smmuv3.h" > #include "hw/acpi/acpi.h" > @@ -1844,7 +1845,7 @@ static void machvirt_init(MachineState *machine) > > create_pcie(vms); > > - if (has_ged && aarch64 && firmware_loaded && acpi_enabled) { > + if (has_ged && aarch64 && firmware_loaded && virt_is_acpi_enabled(vms)) { > vms->acpi_dev = create_acpi_ged(vms); > } else { > create_gpio(vms); > @@ -1934,6 +1935,31 @@ static void virt_set_its(Object *obj, bool value, Error **errp) > vms->its = value; > } > > +bool virt_is_acpi_enabled(VirtMachineState *vms) > +{ > + if (vms->acpi == ON_OFF_AUTO_OFF) { > + return false; > + } > + return true; > +} > + > +static void virt_get_acpi(Object *obj, Visitor *v, const char *name, > + void *opaque, Error **errp) > +{ > + VirtMachineState *vms = VIRT_MACHINE(obj); > + OnOffAuto acpi = vms->acpi; > + > + visit_type_OnOffAuto(v, name, &acpi, errp); > +} > + > +static void virt_set_acpi(Object *obj, Visitor *v, const char *name, > + void *opaque, Error **errp) > +{ > + VirtMachineState *vms = VIRT_MACHINE(obj); > + > + visit_type_OnOffAuto(v, name, &vms->acpi, errp); > +} > + > static char *virt_get_gic_version(Object *obj, Error **errp) > { > VirtMachineState *vms = VIRT_MACHINE(obj); > @@ -2113,7 +2139,7 @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, > if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { > VirtMachineState *vms = VIRT_MACHINE(machine); > > - if (!vms->bootinfo.firmware_loaded || !acpi_enabled) { > + if (!vms->bootinfo.firmware_loaded || !virt_is_acpi_enabled(vms)) { > return HOTPLUG_HANDLER(machine); > } > } > @@ -2184,6 +2210,12 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) > mc->numa_mem_supported = true; > mc->auto_enable_numa_with_memhp = true; > mc->default_ram_id = "mach-virt.ram"; > + > + object_class_property_add(oc, "acpi", "OnOffAuto", > + virt_get_acpi, virt_set_acpi, > + NULL, NULL, &error_abort); > + object_class_property_set_description(oc, "acpi", > + "Enable ACPI", &error_abort); > } > > static void virt_instance_init(Object *obj) > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c > index 9a19c14e661b..2a7e55bae765 100644 > --- a/hw/i386/acpi-build.c > +++ b/hw/i386/acpi-build.c > @@ -3024,7 +3024,7 @@ void acpi_setup(void) > return; > } > > - if (!acpi_enabled) { > + if (!x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) { > ACPI_BUILD_DPRINTF("ACPI disabled. Bailing out.\n"); > return; > } > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > index 98ee763f68f8..0bf0aaca5201 100644 > --- a/hw/i386/pc.c > +++ b/hw/i386/pc.c > @@ -1297,7 +1297,7 @@ static void pc_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, > * but pcms->acpi_dev is still created. Check !acpi_enabled in > * addition to cover this case. > */ > - if (!pcms->acpi_dev || !acpi_enabled) { > + if (!pcms->acpi_dev || !x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) { > error_setg(errp, > "memory hotplug is not enabled: missing acpi device or acpi disabled"); > return; > @@ -1351,7 +1351,7 @@ static void pc_memory_unplug_request(HotplugHandler *hotplug_dev, > * but pcms->acpi_dev is still created. Check !acpi_enabled in > * addition to cover this case. > */ > - if (!pcms->acpi_dev || !acpi_enabled) { > + if (!pcms->acpi_dev || !x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) { > error_setg(&local_err, > "memory hotplug is not enabled: missing acpi device or acpi disabled"); > goto out; > diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c > index e6756216f9f4..9cceae3e2c35 100644 > --- a/hw/i386/pc_piix.c > +++ b/hw/i386/pc_piix.c > @@ -275,7 +275,7 @@ static void pc_init1(MachineState *machine, > pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci"); > } > > - if (pcmc->pci_enabled && acpi_enabled) { > + if (pcmc->pci_enabled && x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) { > DeviceState *piix4_pm; > > smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0); > diff --git a/hw/i386/x86.c b/hw/i386/x86.c > index 87b73fe33cd2..6ca3cf936f38 100644 > --- a/hw/i386/x86.c > +++ b/hw/i386/x86.c > @@ -904,11 +904,37 @@ static void x86_machine_set_smm(Object *obj, Visitor *v, const char *name, > visit_type_OnOffAuto(v, name, &x86ms->smm, errp); > } > > +bool x86_machine_is_acpi_enabled(X86MachineState *x86ms) > +{ > + if (x86ms->acpi == ON_OFF_AUTO_OFF) { > + return false; > + } > + return true; > +} > + > +static void x86_machine_get_acpi(Object *obj, Visitor *v, const char *name, > + void *opaque, Error **errp) > +{ > + X86MachineState *x86ms = X86_MACHINE(obj); > + OnOffAuto acpi = x86ms->acpi; > + > + visit_type_OnOffAuto(v, name, &acpi, errp); > +} > + > +static void x86_machine_set_acpi(Object *obj, Visitor *v, const char *name, > + void *opaque, Error **errp) > +{ > + X86MachineState *x86ms = X86_MACHINE(obj); > + > + visit_type_OnOffAuto(v, name, &x86ms->acpi, errp); > +} > + > static void x86_machine_initfn(Object *obj) > { > X86MachineState *x86ms = X86_MACHINE(obj); > > x86ms->smm = ON_OFF_AUTO_AUTO; > + x86ms->acpi = ON_OFF_AUTO_AUTO; > x86ms->max_ram_below_4g = 0; /* use default */ > x86ms->smp_dies = 1; > } > @@ -937,6 +963,12 @@ static void x86_machine_class_init(ObjectClass *oc, void *data) > NULL, NULL, &error_abort); > object_class_property_set_description(oc, X86_MACHINE_SMM, > "Enable SMM", &error_abort); > + > + object_class_property_add(oc, X86_MACHINE_ACPI, "OnOffAuto", > + x86_machine_get_acpi, x86_machine_set_acpi, > + NULL, NULL, &error_abort); > + object_class_property_set_description(oc, X86_MACHINE_ACPI, > + "Enable ACPI", &error_abort); > } > > static const TypeInfo x86_machine_info = { > diff --git a/softmmu/vl.c b/softmmu/vl.c > index 1d33a2834037..9f06bd4bf0a7 100644 > --- a/softmmu/vl.c > +++ b/softmmu/vl.c > @@ -144,7 +144,6 @@ static Chardev **serial_hds; > Chardev *parallel_hds[MAX_PARALLEL_PORTS]; > int win2k_install_hack = 0; > int singlestep = 0; > -int acpi_enabled = 1; > int no_hpet = 0; > int fd_bootchk = 1; > static int no_reboot; > @@ -3513,7 +3512,8 @@ void qemu_init(int argc, char **argv, char **envp) > vnc_parse(optarg, &error_fatal); > break; > case QEMU_OPTION_no_acpi: > - acpi_enabled = 0; > + olist = qemu_find_opts("machine"); > + qemu_opts_parse_noisily(olist, "acpi=off", false); > break; > case QEMU_OPTION_no_hpet: > no_hpet = 1; > Acked-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h index 1f2dafbd7db6..4bef57531229 100644 --- a/include/hw/acpi/acpi.h +++ b/include/hw/acpi/acpi.h @@ -181,7 +181,6 @@ void acpi_send_gpe_event(ACPIREGS *ar, qemu_irq irq, void acpi_update_sci(ACPIREGS *acpi_regs, qemu_irq irq); /* acpi.c */ -extern int acpi_enabled; extern char unsigned *acpi_tables; extern size_t acpi_tables_len; diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 893796d3b06b..60b2f521eb47 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -131,6 +131,7 @@ typedef struct { bool highmem_ecam; bool its; bool virt; + OnOffAuto acpi; VirtGICType gic_version; VirtIOMMUType iommu; uint16_t virtio_iommu_bdf; @@ -163,6 +164,7 @@ typedef struct { OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_VIRT_MACHINE) void virt_acpi_setup(VirtMachineState *vms); +bool virt_is_acpi_enabled(VirtMachineState *vms); /* Return the number of used redistributor regions */ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms) diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h index 22babcb3bb8d..54af8ab5cfae 100644 --- a/include/hw/i386/x86.h +++ b/include/hw/i386/x86.h @@ -64,6 +64,7 @@ typedef struct { unsigned smp_dies; OnOffAuto smm; + OnOffAuto acpi; /* * Address space used by IOAPIC device. All IOAPIC interrupts @@ -74,6 +75,7 @@ typedef struct { #define X86_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g" #define X86_MACHINE_SMM "smm" +#define X86_MACHINE_ACPI "acpi" #define TYPE_X86_MACHINE MACHINE_TYPE_NAME("x86") #define X86_MACHINE(obj) \ @@ -104,6 +106,7 @@ void x86_load_linux(X86MachineState *x86ms, bool linuxboot_dma_enabled); bool x86_machine_is_smm_enabled(X86MachineState *x86ms); +bool x86_machine_is_acpi_enabled(X86MachineState *x86ms); /* Global System Interrupts */ diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index fb4b166f82c7..7ef0733d7147 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -910,7 +910,7 @@ void virt_acpi_setup(VirtMachineState *vms) return; } - if (!acpi_enabled) { + if (!virt_is_acpi_enabled(vms)) { trace_virt_acpi_setup(); return; } diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 94f93dda54f2..7dc96abf72cf 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -67,6 +67,7 @@ #include "kvm_arm.h" #include "hw/firmware/smbios.h" #include "qapi/visitor.h" +#include "qapi/qapi-visit-common.h" #include "standard-headers/linux/input.h" #include "hw/arm/smmuv3.h" #include "hw/acpi/acpi.h" @@ -1844,7 +1845,7 @@ static void machvirt_init(MachineState *machine) create_pcie(vms); - if (has_ged && aarch64 && firmware_loaded && acpi_enabled) { + if (has_ged && aarch64 && firmware_loaded && virt_is_acpi_enabled(vms)) { vms->acpi_dev = create_acpi_ged(vms); } else { create_gpio(vms); @@ -1934,6 +1935,31 @@ static void virt_set_its(Object *obj, bool value, Error **errp) vms->its = value; } +bool virt_is_acpi_enabled(VirtMachineState *vms) +{ + if (vms->acpi == ON_OFF_AUTO_OFF) { + return false; + } + return true; +} + +static void virt_get_acpi(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + VirtMachineState *vms = VIRT_MACHINE(obj); + OnOffAuto acpi = vms->acpi; + + visit_type_OnOffAuto(v, name, &acpi, errp); +} + +static void virt_set_acpi(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + VirtMachineState *vms = VIRT_MACHINE(obj); + + visit_type_OnOffAuto(v, name, &vms->acpi, errp); +} + static char *virt_get_gic_version(Object *obj, Error **errp) { VirtMachineState *vms = VIRT_MACHINE(obj); @@ -2113,7 +2139,7 @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { VirtMachineState *vms = VIRT_MACHINE(machine); - if (!vms->bootinfo.firmware_loaded || !acpi_enabled) { + if (!vms->bootinfo.firmware_loaded || !virt_is_acpi_enabled(vms)) { return HOTPLUG_HANDLER(machine); } } @@ -2184,6 +2210,12 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) mc->numa_mem_supported = true; mc->auto_enable_numa_with_memhp = true; mc->default_ram_id = "mach-virt.ram"; + + object_class_property_add(oc, "acpi", "OnOffAuto", + virt_get_acpi, virt_set_acpi, + NULL, NULL, &error_abort); + object_class_property_set_description(oc, "acpi", + "Enable ACPI", &error_abort); } static void virt_instance_init(Object *obj) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 9a19c14e661b..2a7e55bae765 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -3024,7 +3024,7 @@ void acpi_setup(void) return; } - if (!acpi_enabled) { + if (!x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) { ACPI_BUILD_DPRINTF("ACPI disabled. Bailing out.\n"); return; } diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 98ee763f68f8..0bf0aaca5201 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1297,7 +1297,7 @@ static void pc_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, * but pcms->acpi_dev is still created. Check !acpi_enabled in * addition to cover this case. */ - if (!pcms->acpi_dev || !acpi_enabled) { + if (!pcms->acpi_dev || !x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) { error_setg(errp, "memory hotplug is not enabled: missing acpi device or acpi disabled"); return; @@ -1351,7 +1351,7 @@ static void pc_memory_unplug_request(HotplugHandler *hotplug_dev, * but pcms->acpi_dev is still created. Check !acpi_enabled in * addition to cover this case. */ - if (!pcms->acpi_dev || !acpi_enabled) { + if (!pcms->acpi_dev || !x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) { error_setg(&local_err, "memory hotplug is not enabled: missing acpi device or acpi disabled"); goto out; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index e6756216f9f4..9cceae3e2c35 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -275,7 +275,7 @@ static void pc_init1(MachineState *machine, pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci"); } - if (pcmc->pci_enabled && acpi_enabled) { + if (pcmc->pci_enabled && x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) { DeviceState *piix4_pm; smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0); diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 87b73fe33cd2..6ca3cf936f38 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -904,11 +904,37 @@ static void x86_machine_set_smm(Object *obj, Visitor *v, const char *name, visit_type_OnOffAuto(v, name, &x86ms->smm, errp); } +bool x86_machine_is_acpi_enabled(X86MachineState *x86ms) +{ + if (x86ms->acpi == ON_OFF_AUTO_OFF) { + return false; + } + return true; +} + +static void x86_machine_get_acpi(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + X86MachineState *x86ms = X86_MACHINE(obj); + OnOffAuto acpi = x86ms->acpi; + + visit_type_OnOffAuto(v, name, &acpi, errp); +} + +static void x86_machine_set_acpi(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + X86MachineState *x86ms = X86_MACHINE(obj); + + visit_type_OnOffAuto(v, name, &x86ms->acpi, errp); +} + static void x86_machine_initfn(Object *obj) { X86MachineState *x86ms = X86_MACHINE(obj); x86ms->smm = ON_OFF_AUTO_AUTO; + x86ms->acpi = ON_OFF_AUTO_AUTO; x86ms->max_ram_below_4g = 0; /* use default */ x86ms->smp_dies = 1; } @@ -937,6 +963,12 @@ static void x86_machine_class_init(ObjectClass *oc, void *data) NULL, NULL, &error_abort); object_class_property_set_description(oc, X86_MACHINE_SMM, "Enable SMM", &error_abort); + + object_class_property_add(oc, X86_MACHINE_ACPI, "OnOffAuto", + x86_machine_get_acpi, x86_machine_set_acpi, + NULL, NULL, &error_abort); + object_class_property_set_description(oc, X86_MACHINE_ACPI, + "Enable ACPI", &error_abort); } static const TypeInfo x86_machine_info = { diff --git a/softmmu/vl.c b/softmmu/vl.c index 1d33a2834037..9f06bd4bf0a7 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -144,7 +144,6 @@ static Chardev **serial_hds; Chardev *parallel_hds[MAX_PARALLEL_PORTS]; int win2k_install_hack = 0; int singlestep = 0; -int acpi_enabled = 1; int no_hpet = 0; int fd_bootchk = 1; static int no_reboot; @@ -3513,7 +3512,8 @@ void qemu_init(int argc, char **argv, char **envp) vnc_parse(optarg, &error_fatal); break; case QEMU_OPTION_no_acpi: - acpi_enabled = 0; + olist = qemu_find_opts("machine"); + qemu_opts_parse_noisily(olist, "acpi=off", false); break; case QEMU_OPTION_no_hpet: no_hpet = 1;
Remove the global acpi_enabled bool and replace it with an acpi OnOffAuto machine property. qemu throws an error now if you use -no-acpi while the machine type you are using doesn't support acpi in the first place. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- include/hw/acpi/acpi.h | 1 - include/hw/arm/virt.h | 2 ++ include/hw/i386/x86.h | 3 +++ hw/arm/virt-acpi-build.c | 2 +- hw/arm/virt.c | 36 ++++++++++++++++++++++++++++++++++-- hw/i386/acpi-build.c | 2 +- hw/i386/pc.c | 4 ++-- hw/i386/pc_piix.c | 2 +- hw/i386/x86.c | 32 ++++++++++++++++++++++++++++++++ softmmu/vl.c | 4 ++-- 10 files changed, 78 insertions(+), 10 deletions(-)