diff options
author | Hu Tao <hutao@cn.fujitsu.com> | 2014-05-14 17:43:33 +0800 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2014-06-19 18:44:19 +0300 |
commit | 1f21772db0b14049b1b4bfef1f039b40827c676f (patch) | |
tree | cb541c9259741222117f2830ef300922e720b511 /qom | |
parent | 7f8f9ef1dac25e76706ee0454bb6cfa097489170 (diff) |
qom: introduce object_property_get_enum and object_property_get_uint16List
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'qom')
-rw-r--r-- | qom/object.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/qom/object.c b/qom/object.c index e42b254303..3876618c2e 100644 --- a/qom/object.c +++ b/qom/object.c @@ -13,6 +13,7 @@ #include "qom/object.h" #include "qemu-common.h" #include "qapi/visitor.h" +#include "qapi-visit.h" #include "qapi/string-input-visitor.h" #include "qapi/string-output-visitor.h" #include "qapi/qmp/qerror.h" @@ -938,6 +939,40 @@ int64_t object_property_get_int(Object *obj, const char *name, return retval; } +int object_property_get_enum(Object *obj, const char *name, + const char *strings[], Error **errp) +{ + StringOutputVisitor *sov; + StringInputVisitor *siv; + int ret; + + sov = string_output_visitor_new(false); + object_property_get(obj, string_output_get_visitor(sov), name, errp); + siv = string_input_visitor_new(string_output_get_string(sov)); + string_output_visitor_cleanup(sov); + visit_type_enum(string_input_get_visitor(siv), + &ret, strings, NULL, name, errp); + string_input_visitor_cleanup(siv); + + return ret; +} + +void object_property_get_uint16List(Object *obj, const char *name, + uint16List **list, Error **errp) +{ + StringOutputVisitor *ov; + StringInputVisitor *iv; + + ov = string_output_visitor_new(false); + object_property_get(obj, string_output_get_visitor(ov), + name, errp); + iv = string_input_visitor_new(string_output_get_string(ov)); + visit_type_uint16List(string_input_get_visitor(iv), + list, NULL, errp); + string_output_visitor_cleanup(ov); + string_input_visitor_cleanup(iv); +} + void object_property_parse(Object *obj, const char *string, const char *name, Error **errp) { |