diff --git a/qemu/aarch64.h b/qemu/aarch64.h index 38964499..1c6911e5 100644 --- a/qemu/aarch64.h +++ b/qemu/aarch64.h @@ -2203,6 +2203,7 @@ #define qlist_size_iter qlist_size_iter_aarch64 #define qlist_type qlist_type_aarch64 #define qlit_equal_qobject qlit_equal_qobject_aarch64 +#define qobject_from_qlit qobject_from_qlit_aarch64 #define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_aarch64 #define qobject_input_end_list qobject_input_end_list_aarch64 #define qobject_input_end_struct qobject_input_end_struct_aarch64 diff --git a/qemu/aarch64eb.h b/qemu/aarch64eb.h index 1b632d17..90faea57 100644 --- a/qemu/aarch64eb.h +++ b/qemu/aarch64eb.h @@ -2203,6 +2203,7 @@ #define qlist_size_iter qlist_size_iter_aarch64eb #define qlist_type qlist_type_aarch64eb #define qlit_equal_qobject qlit_equal_qobject_aarch64eb +#define qobject_from_qlit qobject_from_qlit_aarch64eb #define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_aarch64eb #define qobject_input_end_list qobject_input_end_list_aarch64eb #define qobject_input_end_struct qobject_input_end_struct_aarch64eb diff --git a/qemu/arm.h b/qemu/arm.h index e9e03acd..c03201b7 100644 --- a/qemu/arm.h +++ b/qemu/arm.h @@ -2203,6 +2203,7 @@ #define qlist_size_iter qlist_size_iter_arm #define qlist_type qlist_type_arm #define qlit_equal_qobject qlit_equal_qobject_arm +#define qobject_from_qlit qobject_from_qlit_arm #define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_arm #define qobject_input_end_list qobject_input_end_list_arm #define qobject_input_end_struct qobject_input_end_struct_arm diff --git a/qemu/armeb.h b/qemu/armeb.h index ff7b95be..85b4dae6 100644 --- a/qemu/armeb.h +++ b/qemu/armeb.h @@ -2203,6 +2203,7 @@ #define qlist_size_iter qlist_size_iter_armeb #define qlist_type qlist_type_armeb #define qlit_equal_qobject qlit_equal_qobject_armeb +#define qobject_from_qlit qobject_from_qlit_armeb #define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_armeb #define qobject_input_end_list qobject_input_end_list_armeb #define qobject_input_end_struct qobject_input_end_struct_armeb diff --git a/qemu/header_gen.py b/qemu/header_gen.py index 31892551..1fcefbf4 100644 --- a/qemu/header_gen.py +++ b/qemu/header_gen.py @@ -2209,6 +2209,7 @@ symbols = ( 'qlist_size_iter', 'qlist_type', 'qlit_equal_qobject', + 'qobject_from_qlit', 'qobject_input_end_implicit_struct', 'qobject_input_end_list', 'qobject_input_end_struct', diff --git a/qemu/include/qapi/qmp/qlit.h b/qemu/include/qapi/qmp/qlit.h index f1ed082d..c0676d5d 100644 --- a/qemu/include/qapi/qmp/qlit.h +++ b/qemu/include/qapi/qmp/qlit.h @@ -50,4 +50,6 @@ struct QLitDictEntry { bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs); +QObject *qobject_from_qlit(const QLitObject *qlit); + #endif /* QLIT_H */ diff --git a/qemu/m68k.h b/qemu/m68k.h index a96f3975..874d573e 100644 --- a/qemu/m68k.h +++ b/qemu/m68k.h @@ -2203,6 +2203,7 @@ #define qlist_size_iter qlist_size_iter_m68k #define qlist_type qlist_type_m68k #define qlit_equal_qobject qlit_equal_qobject_m68k +#define qobject_from_qlit qobject_from_qlit_m68k #define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_m68k #define qobject_input_end_list qobject_input_end_list_m68k #define qobject_input_end_struct qobject_input_end_struct_m68k diff --git a/qemu/mips.h b/qemu/mips.h index ea0cd272..f077f2ca 100644 --- a/qemu/mips.h +++ b/qemu/mips.h @@ -2203,6 +2203,7 @@ #define qlist_size_iter qlist_size_iter_mips #define qlist_type qlist_type_mips #define qlit_equal_qobject qlit_equal_qobject_mips +#define qobject_from_qlit qobject_from_qlit_mips #define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_mips #define qobject_input_end_list qobject_input_end_list_mips #define qobject_input_end_struct qobject_input_end_struct_mips diff --git a/qemu/mips64.h b/qemu/mips64.h index 43cb3df8..e34a926c 100644 --- a/qemu/mips64.h +++ b/qemu/mips64.h @@ -2203,6 +2203,7 @@ #define qlist_size_iter qlist_size_iter_mips64 #define qlist_type qlist_type_mips64 #define qlit_equal_qobject qlit_equal_qobject_mips64 +#define qobject_from_qlit qobject_from_qlit_mips64 #define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_mips64 #define qobject_input_end_list qobject_input_end_list_mips64 #define qobject_input_end_struct qobject_input_end_struct_mips64 diff --git a/qemu/mips64el.h b/qemu/mips64el.h index 90633409..d7e51a3d 100644 --- a/qemu/mips64el.h +++ b/qemu/mips64el.h @@ -2203,6 +2203,7 @@ #define qlist_size_iter qlist_size_iter_mips64el #define qlist_type qlist_type_mips64el #define qlit_equal_qobject qlit_equal_qobject_mips64el +#define qobject_from_qlit qobject_from_qlit_mips64el #define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_mips64el #define qobject_input_end_list qobject_input_end_list_mips64el #define qobject_input_end_struct qobject_input_end_struct_mips64el diff --git a/qemu/mipsel.h b/qemu/mipsel.h index 2ac2bc99..72b3da86 100644 --- a/qemu/mipsel.h +++ b/qemu/mipsel.h @@ -2203,6 +2203,7 @@ #define qlist_size_iter qlist_size_iter_mipsel #define qlist_type qlist_type_mipsel #define qlit_equal_qobject qlit_equal_qobject_mipsel +#define qobject_from_qlit qobject_from_qlit_mipsel #define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_mipsel #define qobject_input_end_list qobject_input_end_list_mipsel #define qobject_input_end_struct qobject_input_end_struct_mipsel diff --git a/qemu/powerpc.h b/qemu/powerpc.h index d4a16e55..a23441bc 100644 --- a/qemu/powerpc.h +++ b/qemu/powerpc.h @@ -2203,6 +2203,7 @@ #define qlist_size_iter qlist_size_iter_powerpc #define qlist_type qlist_type_powerpc #define qlit_equal_qobject qlit_equal_qobject_powerpc +#define qobject_from_qlit qobject_from_qlit_powerpc #define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_powerpc #define qobject_input_end_list qobject_input_end_list_powerpc #define qobject_input_end_struct qobject_input_end_struct_powerpc diff --git a/qemu/qobject/qlit.c b/qemu/qobject/qlit.c index c11e9c4f..4dcf0fcd 100644 --- a/qemu/qobject/qlit.c +++ b/qemu/qobject/qlit.c @@ -22,6 +22,7 @@ #include "qapi/qmp/qnum.h" #include "qapi/qmp/qobject.h" #include "qapi/qmp/qstring.h" +#include "qapi/qmp/qnull.h" static bool qlit_equal_qdict(const QLitObject *lhs, const QDict *qdict) { @@ -87,3 +88,39 @@ bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs) return false; } + +QObject *qobject_from_qlit(const QLitObject *qlit) +{ + switch (qlit->type) { + case QTYPE_QNULL: + return QOBJECT(qnull()); + case QTYPE_QNUM: + return QOBJECT(qnum_from_int(qlit->value.qnum)); + case QTYPE_QSTRING: + return QOBJECT(qstring_from_str(qlit->value.qstr)); + case QTYPE_QDICT: { + QDict *qdict = qdict_new(); + QLitDictEntry *e; + + for (e = qlit->value.qdict; e->key; e++) { + qdict_put_obj(qdict, e->key, qobject_from_qlit(&e->value)); + } + return QOBJECT(qdict); + } + case QTYPE_QLIST: { + QList *qlist = qlist_new(); + QLitObject *e; + + for (e = qlit->value.qlist; e->type != QTYPE_NONE; e++) { + qlist_append_obj(qlist, qobject_from_qlit(e)); + } + return QOBJECT(qlist); + } + case QTYPE_QBOOL: + return QOBJECT(qbool_from_bool(qlit->value.qbool)); + default: + assert(0); + } + + return NULL; +} diff --git a/qemu/sparc.h b/qemu/sparc.h index 09573bd5..2b5f3155 100644 --- a/qemu/sparc.h +++ b/qemu/sparc.h @@ -2203,6 +2203,7 @@ #define qlist_size_iter qlist_size_iter_sparc #define qlist_type qlist_type_sparc #define qlit_equal_qobject qlit_equal_qobject_sparc +#define qobject_from_qlit qobject_from_qlit_sparc #define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_sparc #define qobject_input_end_list qobject_input_end_list_sparc #define qobject_input_end_struct qobject_input_end_struct_sparc diff --git a/qemu/sparc64.h b/qemu/sparc64.h index 5e11b8d6..291e95e3 100644 --- a/qemu/sparc64.h +++ b/qemu/sparc64.h @@ -2203,6 +2203,7 @@ #define qlist_size_iter qlist_size_iter_sparc64 #define qlist_type qlist_type_sparc64 #define qlit_equal_qobject qlit_equal_qobject_sparc64 +#define qobject_from_qlit qobject_from_qlit_sparc64 #define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_sparc64 #define qobject_input_end_list qobject_input_end_list_sparc64 #define qobject_input_end_struct qobject_input_end_struct_sparc64 diff --git a/qemu/x86_64.h b/qemu/x86_64.h index 3b12aef7..2d67fa4a 100644 --- a/qemu/x86_64.h +++ b/qemu/x86_64.h @@ -2203,6 +2203,7 @@ #define qlist_size_iter qlist_size_iter_x86_64 #define qlist_type qlist_type_x86_64 #define qlit_equal_qobject qlit_equal_qobject_x86_64 +#define qobject_from_qlit qobject_from_qlit_x86_64 #define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_x86_64 #define qobject_input_end_list qobject_input_end_list_x86_64 #define qobject_input_end_struct qobject_input_end_struct_x86_64