summaryrefslogtreecommitdiffstats
path: root/qemu/qapi/opts-visitor.c
diff options
context:
space:
mode:
authorJosé Pekkarinen <jose.pekkarinen@nokia.com>2016-05-18 13:18:31 +0300
committerJosé Pekkarinen <jose.pekkarinen@nokia.com>2016-05-18 13:42:15 +0300
commit437fd90c0250dee670290f9b714253671a990160 (patch)
treeb871786c360704244a07411c69fb58da9ead4a06 /qemu/qapi/opts-visitor.c
parent5bbd6fe9b8bab2a93e548c5a53b032d1939eec05 (diff)
These changes are the raw update to qemu-2.6.
Collission happened in the following patches: migration: do cleanup operation after completion(738df5b9) Bug fix.(1750c932f86) kvmclock: add a new function to update env->tsc.(b52baab2) The code provided by the patches was already in the upstreamed version. Change-Id: I3cc11841a6a76ae20887b2e245710199e1ea7f9a Signed-off-by: José Pekkarinen <jose.pekkarinen@nokia.com>
Diffstat (limited to 'qemu/qapi/opts-visitor.c')
-rw-r--r--qemu/qapi/opts-visitor.c74
1 files changed, 38 insertions, 36 deletions
diff --git a/qemu/qapi/opts-visitor.c b/qemu/qapi/opts-visitor.c
index 7ae33b311..602f2609c 100644
--- a/qemu/qapi/opts-visitor.c
+++ b/qemu/qapi/opts-visitor.c
@@ -1,7 +1,7 @@
/*
* Options Visitor
*
- * Copyright Red Hat, Inc. 2012, 2013
+ * Copyright Red Hat, Inc. 2012-2016
*
* Author: Laszlo Ersek <lersek@redhat.com>
*
@@ -10,7 +10,9 @@
*
*/
-#include "qemu-common.h"
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "qemu/cutils.h"
#include "qapi/qmp/qerror.h"
#include "qapi/opts-visitor.h"
#include "qemu/queue.h"
@@ -89,6 +91,12 @@ struct OptsVisitor
};
+static OptsVisitor *to_ov(Visitor *v)
+{
+ return container_of(v, OptsVisitor, visitor);
+}
+
+
static void
destroy_list(gpointer list)
{
@@ -118,10 +126,10 @@ opts_visitor_insert(GHashTable *unprocessed_opts, const QemuOpt *opt)
static void
-opts_start_struct(Visitor *v, void **obj, const char *kind,
- const char *name, size_t size, Error **errp)
+opts_start_struct(Visitor *v, const char *name, void **obj,
+ size_t size, Error **errp)
{
- OptsVisitor *ov = DO_UPCAST(OptsVisitor, visitor, v);
+ OptsVisitor *ov = to_ov(v);
const QemuOpt *opt;
if (obj) {
@@ -150,17 +158,11 @@ opts_start_struct(Visitor *v, void **obj, const char *kind,
}
-static gboolean
-ghr_true(gpointer ign_key, gpointer ign_value, gpointer ign_user_data)
-{
- return TRUE;
-}
-
-
static void
opts_end_struct(Visitor *v, Error **errp)
{
- OptsVisitor *ov = DO_UPCAST(OptsVisitor, visitor, v);
+ OptsVisitor *ov = to_ov(v);
+ GHashTableIter iter;
GQueue *any;
if (--ov->depth > 0) {
@@ -168,8 +170,8 @@ opts_end_struct(Visitor *v, Error **errp)
}
/* we should have processed all (distinct) QemuOpt instances */
- any = g_hash_table_find(ov->unprocessed_opts, &ghr_true, NULL);
- if (any) {
+ g_hash_table_iter_init(&iter, ov->unprocessed_opts);
+ if (g_hash_table_iter_next(&iter, NULL, (void **)&any)) {
const QemuOpt *first;
first = g_queue_peek_head(any);
@@ -202,7 +204,7 @@ lookup_distinct(const OptsVisitor *ov, const char *name, Error **errp)
static void
opts_start_list(Visitor *v, const char *name, Error **errp)
{
- OptsVisitor *ov = DO_UPCAST(OptsVisitor, visitor, v);
+ OptsVisitor *ov = to_ov(v);
/* we can't traverse a list in a list */
assert(ov->list_mode == LM_NONE);
@@ -214,9 +216,9 @@ opts_start_list(Visitor *v, const char *name, Error **errp)
static GenericList *
-opts_next_list(Visitor *v, GenericList **list, Error **errp)
+opts_next_list(Visitor *v, GenericList **list, size_t size)
{
- OptsVisitor *ov = DO_UPCAST(OptsVisitor, visitor, v);
+ OptsVisitor *ov = to_ov(v);
GenericList **link;
switch (ov->list_mode) {
@@ -257,15 +259,15 @@ opts_next_list(Visitor *v, GenericList **list, Error **errp)
abort();
}
- *link = g_malloc0(sizeof **link);
+ *link = g_malloc0(size);
return *link;
}
static void
-opts_end_list(Visitor *v, Error **errp)
+opts_end_list(Visitor *v)
{
- OptsVisitor *ov = DO_UPCAST(OptsVisitor, visitor, v);
+ OptsVisitor *ov = to_ov(v);
assert(ov->list_mode == LM_STARTED ||
ov->list_mode == LM_IN_PROGRESS ||
@@ -305,9 +307,9 @@ processed(OptsVisitor *ov, const char *name)
static void
-opts_type_str(Visitor *v, char **obj, const char *name, Error **errp)
+opts_type_str(Visitor *v, const char *name, char **obj, Error **errp)
{
- OptsVisitor *ov = DO_UPCAST(OptsVisitor, visitor, v);
+ OptsVisitor *ov = to_ov(v);
const QemuOpt *opt;
opt = lookup_scalar(ov, name, errp);
@@ -321,9 +323,9 @@ opts_type_str(Visitor *v, char **obj, const char *name, Error **errp)
/* mimics qemu-option.c::parse_option_bool() */
static void
-opts_type_bool(Visitor *v, bool *obj, const char *name, Error **errp)
+opts_type_bool(Visitor *v, const char *name, bool *obj, Error **errp)
{
- OptsVisitor *ov = DO_UPCAST(OptsVisitor, visitor, v);
+ OptsVisitor *ov = to_ov(v);
const QemuOpt *opt;
opt = lookup_scalar(ov, name, errp);
@@ -354,9 +356,9 @@ opts_type_bool(Visitor *v, bool *obj, const char *name, Error **errp)
static void
-opts_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp)
+opts_type_int64(Visitor *v, const char *name, int64_t *obj, Error **errp)
{
- OptsVisitor *ov = DO_UPCAST(OptsVisitor, visitor, v);
+ OptsVisitor *ov = to_ov(v);
const QemuOpt *opt;
const char *str;
long long val;
@@ -410,9 +412,9 @@ opts_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp)
static void
-opts_type_uint64(Visitor *v, uint64_t *obj, const char *name, Error **errp)
+opts_type_uint64(Visitor *v, const char *name, uint64_t *obj, Error **errp)
{
- OptsVisitor *ov = DO_UPCAST(OptsVisitor, visitor, v);
+ OptsVisitor *ov = to_ov(v);
const QemuOpt *opt;
const char *str;
unsigned long long val;
@@ -462,9 +464,9 @@ opts_type_uint64(Visitor *v, uint64_t *obj, const char *name, Error **errp)
static void
-opts_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp)
+opts_type_size(Visitor *v, const char *name, uint64_t *obj, Error **errp)
{
- OptsVisitor *ov = DO_UPCAST(OptsVisitor, visitor, v);
+ OptsVisitor *ov = to_ov(v);
const QemuOpt *opt;
int64_t val;
char *endptr;
@@ -474,8 +476,8 @@ opts_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp)
return;
}
- val = strtosz_suffix(opt->str ? opt->str : "", &endptr,
- STRTOSZ_DEFSUFFIX_B);
+ val = qemu_strtosz_suffix(opt->str ? opt->str : "", &endptr,
+ QEMU_STRTOSZ_DEFSUFFIX_B);
if (val < 0 || *endptr) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
"a size value representible as a non-negative int64");
@@ -488,9 +490,9 @@ opts_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp)
static void
-opts_optional(Visitor *v, bool *present, const char *name, Error **errp)
+opts_optional(Visitor *v, const char *name, bool *present)
{
- OptsVisitor *ov = DO_UPCAST(OptsVisitor, visitor, v);
+ OptsVisitor *ov = to_ov(v);
/* we only support a single mandatory scalar field in a list node */
assert(ov->list_mode == LM_NONE);
@@ -522,7 +524,7 @@ opts_visitor_new(const QemuOpts *opts)
*/
ov->visitor.type_enum = &input_type_enum;
- ov->visitor.type_int = &opts_type_int;
+ ov->visitor.type_int64 = &opts_type_int64;
ov->visitor.type_uint64 = &opts_type_uint64;
ov->visitor.type_size = &opts_type_size;
ov->visitor.type_bool = &opts_type_bool;