From: Marc-André Lureau <[email protected]> Convert the legacy-vm-type OnOffAuto property from manual visitor-based callbacks to object_class_property_add_enum().
Signed-off-by: Marc-André Lureau <[email protected]> Signed-off-by: Markus Armbruster <[email protected]> Message-ID: <[email protected]> --- target/i386/sev.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index 74a7b719b5..d19f98e1c7 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -20,6 +20,7 @@ #include <sys/ioctl.h> #include "qapi/error.h" +#include "qapi/qapi-type-infos-common.h" #include "qom/object_interfaces.h" #include "qemu/base64.h" #include "qemu/module.h" @@ -2982,23 +2983,16 @@ sev_guest_set_session_file(Object *obj, const char *value, Error **errp) SEV_GUEST(obj)->session_file = g_strdup(value); } -static void sev_guest_get_legacy_vm_type(Object *obj, Visitor *v, - const char *name, void *opaque, - Error **errp) +static int sev_guest_get_legacy_vm_type(Object *obj, Error **errp) { SevGuestState *sev_guest = SEV_GUEST(obj); - OnOffAuto legacy_vm_type = sev_guest->legacy_vm_type; - - visit_type_OnOffAuto(v, name, &legacy_vm_type, errp); + return sev_guest->legacy_vm_type; } -static void sev_guest_set_legacy_vm_type(Object *obj, Visitor *v, - const char *name, void *opaque, - Error **errp) +static void sev_guest_set_legacy_vm_type(Object *obj, int value, Error **errp) { SevGuestState *sev_guest = SEV_GUEST(obj); - - visit_type_OnOffAuto(v, name, &sev_guest->legacy_vm_type, errp); + sev_guest->legacy_vm_type = value; } static void @@ -3024,9 +3018,10 @@ sev_guest_class_init(ObjectClass *oc, const void *data) sev_guest_set_session_file); object_class_property_set_description(oc, "session-file", "guest owners session parameters (encoded with base64)"); - object_class_property_add(oc, "legacy-vm-type", "OnOffAuto", NULL, - sev_guest_get_legacy_vm_type, - sev_guest_set_legacy_vm_type, NULL, NULL); + object_class_property_add_enum(oc, "legacy-vm-type", "OnOffAuto", + &OnOffAuto_type_info, NULL, + sev_guest_get_legacy_vm_type, + sev_guest_set_legacy_vm_type); object_class_property_set_description(oc, "legacy-vm-type", "use legacy VM type to maintain measurement compatibility with older QEMU or kernel versions."); } -- 2.55.0
