[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 075/103] qom: introduce object_property_get_enum and
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 075/103] qom: introduce object_property_get_enum and object_property_get_uint16List |
Date: |
Tue, 17 Jun 2014 20:40:51 +0300 |
From: Hu Tao <address@hidden>
Signed-off-by: Hu Tao <address@hidden>
Acked-by: Michael S. Tsirkin <address@hidden>
---
include/qom/object.h | 28 ++++++++++++++++++++++++++++
qom/object.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+)
diff --git a/include/qom/object.h b/include/qom/object.h
index a641dcd..b882ccc 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -917,6 +917,34 @@ 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);
+
+/**
+ * object_property_get_uint16List:
+ * @obj: the object
+ * @name: the name of the property
+ * @list: the returned int list
+ * @errp: returns an error if this function fails
+ *
+ * Returns: the value of the property, converted to integers, or
+ * undefined if an error occurs (including when the property value is not
+ * an list of integers).
+ */
+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 e42b254..3876618 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)
{
--
MST
- [Qemu-devel] [PULL 061/103] Add qtest for vhost-user, (continued)
- [Qemu-devel] [PULL 061/103] Add qtest for vhost-user, Michael S. Tsirkin, 2014/06/17
- [Qemu-devel] [PULL 065/103] NUMA: convert -numa option to use OptsVisitor, Michael S. Tsirkin, 2014/06/17
- [Qemu-devel] [PULL 066/103] NUMA: expand MAX_NODES from 64 to 128, Michael S. Tsirkin, 2014/06/17
- [Qemu-devel] [PULL 067/103] man: improve -numa doc, Michael S. Tsirkin, 2014/06/17
- [Qemu-devel] [PULL 069/103] numa: introduce memory_region_allocate_system_memory, Michael S. Tsirkin, 2014/06/17
- [Qemu-devel] [PULL 070/103] memory: reorganize file-based allocation, Michael S. Tsirkin, 2014/06/17
- [Qemu-devel] [PULL 071/103] memory: move preallocation code out of exec.c, Michael S. Tsirkin, 2014/06/17
- [Qemu-devel] [PULL 072/103] memory: move RAM_PREALLOC_MASK to exec.c, rename, Michael S. Tsirkin, 2014/06/17
- [Qemu-devel] [PULL 073/103] configure: add Linux libnuma detection, Michael S. Tsirkin, 2014/06/17
- [Qemu-devel] [PULL 074/103] Introduce signed range., Michael S. Tsirkin, 2014/06/17
- [Qemu-devel] [PULL 075/103] qom: introduce object_property_get_enum and object_property_get_uint16List,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 076/103] numa: add -numa node,memdev= option, Michael S. Tsirkin, 2014/06/17
- [Qemu-devel] [PULL 078/103] memory: add error propagation to file-based RAM allocation, Michael S. Tsirkin, 2014/06/17
- [Qemu-devel] [PULL 079/103] vl: redo -object parsing, Michael S. Tsirkin, 2014/06/17
- [Qemu-devel] [PULL 080/103] pc: pass MachineState to pc_memory_init, Michael S. Tsirkin, 2014/06/17
- [Qemu-devel] [PULL 081/103] backend:hostmem: replace hostmemory with host_memory, Michael S. Tsirkin, 2014/06/17
- [Qemu-devel] [PULL 082/103] hostmem: separate allocation from UserCreatable complete method, Michael S. Tsirkin, 2014/06/17
- [Qemu-devel] [PULL 083/103] hostmem: add file-based HostMemoryBackend, Michael S. Tsirkin, 2014/06/17
- [Qemu-devel] [PULL 077/103] memory: move mem_path handling to memory_region_allocate_system_memory, Michael S. Tsirkin, 2014/06/17
- [Qemu-devel] [PULL 084/103] hostmem: add merge and dump properties, Michael S. Tsirkin, 2014/06/17