diff options
Diffstat (limited to 'qom/object.c')
-rw-r--r-- | qom/object.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/qom/object.c b/qom/object.c index 8f0d8a7b13..ee384311f9 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1076,12 +1076,27 @@ typedef struct EnumProperty { } EnumProperty; int object_property_get_enum(Object *obj, const char *name, - const char * const strings[], Error **errp) + const char *typename, Error **errp) { StringOutputVisitor *sov; StringInputVisitor *siv; char *str; int ret; + ObjectProperty *prop = object_property_find(obj, name, errp); + EnumProperty *enumprop; + + if (prop == NULL) { + return 0; + } + + if (!g_str_equal(prop->type, typename)) { + error_setg(errp, "Property %s on %s is not '%s' enum type", + name, object_class_get_name( + object_get_class(obj)), typename); + return 0; + } + + enumprop = prop->opaque; sov = string_output_visitor_new(false); object_property_get(obj, string_output_get_visitor(sov), name, errp); @@ -1089,7 +1104,7 @@ int object_property_get_enum(Object *obj, const char *name, siv = string_input_visitor_new(str); string_output_visitor_cleanup(sov); visit_type_enum(string_input_get_visitor(siv), - &ret, strings, NULL, name, errp); + &ret, enumprop->strings, NULL, name, errp); g_free(str); string_input_visitor_cleanup(siv); |