aboutsummaryrefslogtreecommitdiff
path: root/qom/object.c
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2015-05-27 16:07:56 +0100
committerAndreas Färber <afaerber@suse.de>2015-06-19 18:42:48 +0200
commita3590dacce94519c1747d8bf423744c6bb7d9941 (patch)
treeb598151b5822753634082f7a634065009281e877 /qom/object.c
parenta8e3fbedc827f992657f5670212e854f62ec12ad (diff)
downloadqemu-a3590dacce94519c1747d8bf423744c6bb7d9941.zip
qemu-a3590dacce94519c1747d8bf423744c6bb7d9941.tar.gz
qemu-a3590dacce94519c1747d8bf423744c6bb7d9941.tar.bz2
qom: Don't pass string table to object_get_enum() function
Now that properties can be explicitly registered as an enum type, there is no need to pass the string table to the object_get_enum() function. The object property registration already has a pointer to the string table. In changing this method signature, the hostmem backend object has to be converted to use the new enum property registration code, which simplifies it somewhat. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'qom/object.c')
-rw-r--r--qom/object.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/qom/object.c b/qom/object.c
index 8f0d8a7..ee38431 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);