[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 32/34] qom: introduce object_property_get_enum an
From: |
address@hidden |
Subject: |
[Qemu-devel] [PATCH v3 32/34] qom: introduce object_property_get_enum and object_property_get_uint16List |
Date: |
Wed, 26 Mar 2014 10:37:02 +0000 |
Signed-off-by: Hu Tao <address@hidden>
---
include/qom/object.h | 18 ++++++++++++++++++
qom/object.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/include/qom/object.h b/include/qom/object.h
index a641dcd..2e488f1 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -917,6 +917,24 @@ int64_t object_property_get_int(Object *obj, const char
*name,
Error **errp);
/**
+ * object_property_get_enum:
+ * @obj: the object
+ * @name: the name of the property
+ * @strings: strings corresponding to enums
+ * @errp: returns an error if this function fails
+ *
+ * Returns: the value of the property, converted to an integer, or
+ * undefined if an error occurs (including when the property value is not
+ * an enum).
+ */
+int object_property_get_enum(Object *obj, const char *name,
+ const char *strings[], Error **errp);
+
+
+void object_property_get_uint16List(Object *obj, const char *name,
+ uint16List **list, Error **errp);
+
+/**
* object_property_set:
* @obj: the object
* @v: the visitor that will be used to write the property value. This should
diff --git a/qom/object.c b/qom/object.c
index f4de619..f6e3c4f 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)
{
--
1.8.5.2.229.g4448466
- [Qemu-devel] [PATCH v3 05/34] NUMA: expand MAX_NODES from 64 to 128, (continued)
- [Qemu-devel] [PATCH v3 05/34] NUMA: expand MAX_NODES from 64 to 128, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 18/34] memory: add error propagation to file-based RAM allocation, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 08/34] vl: convert -m to QemuOpts, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 14/34] add memdev backend infrastructure, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 21/34] hostmem: add file-based HostMemoryBackend, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 22/34] hostmem: separate allocation from UserCreatable complete method, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 26/34] configure: add Linux libnuma detection, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 24/34] hostmem: allow preallocation of any memory region, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 27/34] hostmem: add properties for NUMA memory policy, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 11/34] qmp: improve error reporting for -object and object-add, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 32/34] qom: introduce object_property_get_enum and object_property_get_uint16List,
address@hidden <=
- [Qemu-devel] [PATCH v3 20/34] memory: move RAM_PREALLOC_MASK to exec.c, rename, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 25/34] hostmem: add property to map memory with MAP_SHARED, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 23/34] hostmem: add merge and dump properties, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 34/34] hmp: add info memdev, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 28/34] hw: switch all boards to use memory_region_allocate_system_memory, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 31/34] qapi: make string output visitor parse int list, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 33/34] qmp: add query-memdev, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 06/34] man: improve -numa doc, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 19/34] memory: move preallocation code out of exec.c, address@hidden, 2014/03/26