On Sun, May 10, 2026 at 11:49 PM Marc-André Lureau <[email protected]> wrote: > > Convert the acpi and iommu-sys OnOffAuto properties from manual > visitor-based callbacks to property_add_qapi_enum(). > > Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Alistair Francis <[email protected]> Alistair > --- > hw/riscv/virt.c | 54 ++++++++++++++++++++++++------------------------------ > 1 file changed, 24 insertions(+), 30 deletions(-) > > diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c > index a1c323e66df..5148044df95 100644 > --- a/hw/riscv/virt.c > +++ b/hw/riscv/virt.c > @@ -55,7 +55,7 @@ > #include "hw/pci-host/gpex.h" > #include "hw/display/ramfb.h" > #include "hw/acpi/aml-build.h" > -#include "qapi/qapi-visit-common.h" > +#include "qapi/qapi-type-infos-common.h" > #include "hw/virtio/virtio-iommu.h" > #include "hw/uefi/var-service-api.h" > > @@ -1832,21 +1832,16 @@ bool virt_is_iommu_sys_enabled(RISCVVirtState *s) > return s->iommu_sys == ON_OFF_AUTO_ON; > } > > -static void virt_get_iommu_sys(Object *obj, Visitor *v, const char *name, > - void *opaque, Error **errp) > +static int virt_get_iommu_sys(Object *obj, Error **errp) > { > RISCVVirtState *s = RISCV_VIRT_MACHINE(obj); > - OnOffAuto iommu_sys = s->iommu_sys; > - > - visit_type_OnOffAuto(v, name, &iommu_sys, errp); > + return s->iommu_sys; > } > > -static void virt_set_iommu_sys(Object *obj, Visitor *v, const char *name, > - void *opaque, Error **errp) > +static void virt_set_iommu_sys(Object *obj, int value, Error **errp) > { > RISCVVirtState *s = RISCV_VIRT_MACHINE(obj); > - > - visit_type_OnOffAuto(v, name, &s->iommu_sys, errp); > + s->iommu_sys = value; > } > > bool virt_is_acpi_enabled(RISCVVirtState *s) > @@ -1854,21 +1849,16 @@ bool virt_is_acpi_enabled(RISCVVirtState *s) > return s->acpi != ON_OFF_AUTO_OFF; > } > > -static void virt_get_acpi(Object *obj, Visitor *v, const char *name, > - void *opaque, Error **errp) > +static int virt_get_acpi(Object *obj, Error **errp) > { > RISCVVirtState *s = RISCV_VIRT_MACHINE(obj); > - OnOffAuto acpi = s->acpi; > - > - visit_type_OnOffAuto(v, name, &acpi, errp); > + return s->acpi; > } > > -static void virt_set_acpi(Object *obj, Visitor *v, const char *name, > - void *opaque, Error **errp) > +static void virt_set_acpi(Object *obj, int value, Error **errp) > { > RISCVVirtState *s = RISCV_VIRT_MACHINE(obj); > - > - visit_type_OnOffAuto(v, name, &s->acpi, errp); > + s->acpi = value; > } > > static HotplugHandler *virt_machine_get_hotplug_handler(MachineState > *machine, > @@ -1966,17 +1956,21 @@ static void virt_machine_class_init(ObjectClass *oc, > const void *data) > object_class_property_set_description(oc, "aia-guests", str); > } > > - object_class_property_add(oc, "acpi", "OnOffAuto", > - virt_get_acpi, virt_set_acpi, > - NULL, NULL); > - object_class_property_set_description(oc, "acpi", > - "Enable ACPI"); > - > - object_class_property_add(oc, "iommu-sys", "OnOffAuto", > - virt_get_iommu_sys, virt_set_iommu_sys, > - NULL, NULL); > - object_class_property_set_description(oc, "iommu-sys", > - "Enable IOMMU platform device"); > + object_class_property_add_qapi_enum(oc, QAPI_ENUM_PROP( > + .name = "acpi", > + .description = "Enable ACPI", > + .qapi_type = &OnOffAuto_type_info, > + .get = virt_get_acpi, > + .set = virt_set_acpi, > + )); > + > + object_class_property_add_qapi_enum(oc, QAPI_ENUM_PROP( > + .name = "iommu-sys", > + .description = "Enable IOMMU platform device", > + .qapi_type = &OnOffAuto_type_info, > + .get = virt_get_iommu_sys, > + .set = virt_set_iommu_sys, > + )); > } > > static const TypeInfo virt_machine_typeinfo = { > > -- > 2.54.0 > >
