From 0741c3880a26b5ca672592fd69a12a70b2506a80 Mon Sep 17 00:00:00 2001 From: Peter Xu Date: Mon, 5 Mar 2018 01:16:25 -0500 Subject: [PATCH] qom: provide root container for internal objs We have object_get_objects_root() to keep user created objects, however no place for objects that will be used internally. Create such a container for internal objects. Backports commit 7c47c4ead75d0b733ee8f2f51fd1de0644cc1308 from qemu --- qemu/aarch64.h | 1 + qemu/aarch64eb.h | 1 + qemu/arm.h | 1 + qemu/armeb.h | 1 + qemu/header_gen.py | 1 + qemu/include/qom/object.h | 11 +++++++++++ qemu/m68k.h | 1 + qemu/mips.h | 2 +- qemu/mips64.h | 2 +- qemu/mips64el.h | 2 +- qemu/mipsel.h | 2 +- qemu/powerpc.h | 1 + qemu/qom/object.c | 11 +++++++++++ qemu/sparc.h | 1 + qemu/sparc64.h | 1 + qemu/x86_64.h | 1 + 16 files changed, 36 insertions(+), 4 deletions(-) diff --git a/qemu/aarch64.h b/qemu/aarch64.h index 0006cfa5..f87f62d3 100644 --- a/qemu/aarch64.h +++ b/qemu/aarch64.h @@ -2391,6 +2391,7 @@ #define object_finalize object_finalize_aarch64 #define object_finalize_child_property object_finalize_child_property_aarch64 #define object_get_child_property object_get_child_property_aarch64 +#define object_get_internal_root object_get_internal_root_aarch64 #define object_get_link_property object_get_link_property_aarch64 #define object_get_root object_get_root_aarch64 #define object_init_with_type object_init_with_type_aarch64 diff --git a/qemu/aarch64eb.h b/qemu/aarch64eb.h index e8bcd184..0a974604 100644 --- a/qemu/aarch64eb.h +++ b/qemu/aarch64eb.h @@ -2391,6 +2391,7 @@ #define object_finalize object_finalize_aarch64eb #define object_finalize_child_property object_finalize_child_property_aarch64eb #define object_get_child_property object_get_child_property_aarch64eb +#define object_get_internal_root object_get_internal_root_aarch64eb #define object_get_link_property object_get_link_property_aarch64eb #define object_get_root object_get_root_aarch64eb #define object_init_with_type object_init_with_type_aarch64eb diff --git a/qemu/arm.h b/qemu/arm.h index 903e0f5f..7087f7f5 100644 --- a/qemu/arm.h +++ b/qemu/arm.h @@ -2391,6 +2391,7 @@ #define object_finalize object_finalize_arm #define object_finalize_child_property object_finalize_child_property_arm #define object_get_child_property object_get_child_property_arm +#define object_get_internal_root object_get_internal_root_arm #define object_get_link_property object_get_link_property_arm #define object_get_root object_get_root_arm #define object_init_with_type object_init_with_type_arm diff --git a/qemu/armeb.h b/qemu/armeb.h index 0d10fdaf..651d646f 100644 --- a/qemu/armeb.h +++ b/qemu/armeb.h @@ -2391,6 +2391,7 @@ #define object_finalize object_finalize_armeb #define object_finalize_child_property object_finalize_child_property_armeb #define object_get_child_property object_get_child_property_armeb +#define object_get_internal_root object_get_internal_root_armeb #define object_get_link_property object_get_link_property_armeb #define object_get_root object_get_root_armeb #define object_init_with_type object_init_with_type_armeb diff --git a/qemu/header_gen.py b/qemu/header_gen.py index 81a1836a..69783968 100644 --- a/qemu/header_gen.py +++ b/qemu/header_gen.py @@ -2397,6 +2397,7 @@ symbols = ( 'object_finalize', 'object_finalize_child_property', 'object_get_child_property', + 'object_get_internal_root', 'object_get_link_property', 'object_get_root', 'object_init_with_type', diff --git a/qemu/include/qom/object.h b/qemu/include/qom/object.h index b7d452e8..ec8181a1 100644 --- a/qemu/include/qom/object.h +++ b/qemu/include/qom/object.h @@ -1053,6 +1053,17 @@ const char *object_property_get_type(struct uc_struct *uc, Object *obj, */ Object *object_get_root(struct uc_struct *uc); +/** + * object_get_internal_root: + * + * Get the container object that holds internally used object + * instances. Any object which is put into this container must not be + * user visible, and it will not be exposed in the QOM tree. + * + * Returns: the internal object container + */ +Object *object_get_internal_root(struct uc_struct *uc); + /** * object_get_canonical_path_component: * diff --git a/qemu/m68k.h b/qemu/m68k.h index 7b802bbd..47e64b4f 100644 --- a/qemu/m68k.h +++ b/qemu/m68k.h @@ -2391,6 +2391,7 @@ #define object_finalize object_finalize_m68k #define object_finalize_child_property object_finalize_child_property_m68k #define object_get_child_property object_get_child_property_m68k +#define object_get_internal_root object_get_internal_root_m68k #define object_get_link_property object_get_link_property_m68k #define object_get_root object_get_root_m68k #define object_init_with_type object_init_with_type_m68k diff --git a/qemu/mips.h b/qemu/mips.h index cccc840e..778c1e71 100644 --- a/qemu/mips.h +++ b/qemu/mips.h @@ -2391,6 +2391,7 @@ #define object_finalize object_finalize_mips #define object_finalize_child_property object_finalize_child_property_mips #define object_get_child_property object_get_child_property_mips +#define object_get_internal_root object_get_internal_root_mips #define object_get_link_property object_get_link_property_mips #define object_get_root object_get_root_mips #define object_init_with_type object_init_with_type_mips @@ -3440,7 +3441,6 @@ #define cpu_mips_exec cpu_mips_exec_mips #define cpu_mips_get_count cpu_mips_get_count_mips #define cpu_mips_get_random cpu_mips_get_random_mips -#define cpu_mips_init cpu_mips_init_mips #define cpu_mips_kseg0_to_phys cpu_mips_kseg0_to_phys_mips #define cpu_mips_kvm_um_phys_to_kseg0 cpu_mips_kvm_um_phys_to_kseg0_mips #define cpu_mips_phys_to_kseg0 cpu_mips_phys_to_kseg0_mips diff --git a/qemu/mips64.h b/qemu/mips64.h index ba1c5352..08b31594 100644 --- a/qemu/mips64.h +++ b/qemu/mips64.h @@ -2391,6 +2391,7 @@ #define object_finalize object_finalize_mips64 #define object_finalize_child_property object_finalize_child_property_mips64 #define object_get_child_property object_get_child_property_mips64 +#define object_get_internal_root object_get_internal_root_mips64 #define object_get_link_property object_get_link_property_mips64 #define object_get_root object_get_root_mips64 #define object_init_with_type object_init_with_type_mips64 @@ -3440,7 +3441,6 @@ #define cpu_mips_exec cpu_mips_exec_mips64 #define cpu_mips_get_count cpu_mips_get_count_mips64 #define cpu_mips_get_random cpu_mips_get_random_mips64 -#define cpu_mips_init cpu_mips_init_mips64 #define cpu_mips_kseg0_to_phys cpu_mips_kseg0_to_phys_mips64 #define cpu_mips_kvm_um_phys_to_kseg0 cpu_mips_kvm_um_phys_to_kseg0_mips64 #define cpu_mips_phys_to_kseg0 cpu_mips_phys_to_kseg0_mips64 diff --git a/qemu/mips64el.h b/qemu/mips64el.h index 30a1b5fb..e75a7be2 100644 --- a/qemu/mips64el.h +++ b/qemu/mips64el.h @@ -2391,6 +2391,7 @@ #define object_finalize object_finalize_mips64el #define object_finalize_child_property object_finalize_child_property_mips64el #define object_get_child_property object_get_child_property_mips64el +#define object_get_internal_root object_get_internal_root_mips64el #define object_get_link_property object_get_link_property_mips64el #define object_get_root object_get_root_mips64el #define object_init_with_type object_init_with_type_mips64el @@ -3440,7 +3441,6 @@ #define cpu_mips_exec cpu_mips_exec_mips64el #define cpu_mips_get_count cpu_mips_get_count_mips64el #define cpu_mips_get_random cpu_mips_get_random_mips64el -#define cpu_mips_init cpu_mips_init_mips64el #define cpu_mips_kseg0_to_phys cpu_mips_kseg0_to_phys_mips64el #define cpu_mips_kvm_um_phys_to_kseg0 cpu_mips_kvm_um_phys_to_kseg0_mips64el #define cpu_mips_phys_to_kseg0 cpu_mips_phys_to_kseg0_mips64el diff --git a/qemu/mipsel.h b/qemu/mipsel.h index a8e34774..f5f8d672 100644 --- a/qemu/mipsel.h +++ b/qemu/mipsel.h @@ -2391,6 +2391,7 @@ #define object_finalize object_finalize_mipsel #define object_finalize_child_property object_finalize_child_property_mipsel #define object_get_child_property object_get_child_property_mipsel +#define object_get_internal_root object_get_internal_root_mipsel #define object_get_link_property object_get_link_property_mipsel #define object_get_root object_get_root_mipsel #define object_init_with_type object_init_with_type_mipsel @@ -3440,7 +3441,6 @@ #define cpu_mips_exec cpu_mips_exec_mipsel #define cpu_mips_get_count cpu_mips_get_count_mipsel #define cpu_mips_get_random cpu_mips_get_random_mipsel -#define cpu_mips_init cpu_mips_init_mipsel #define cpu_mips_kseg0_to_phys cpu_mips_kseg0_to_phys_mipsel #define cpu_mips_kvm_um_phys_to_kseg0 cpu_mips_kvm_um_phys_to_kseg0_mipsel #define cpu_mips_phys_to_kseg0 cpu_mips_phys_to_kseg0_mipsel diff --git a/qemu/powerpc.h b/qemu/powerpc.h index c5671cd5..7388cf91 100644 --- a/qemu/powerpc.h +++ b/qemu/powerpc.h @@ -2391,6 +2391,7 @@ #define object_finalize object_finalize_powerpc #define object_finalize_child_property object_finalize_child_property_powerpc #define object_get_child_property object_get_child_property_powerpc +#define object_get_internal_root object_get_internal_root_powerpc #define object_get_link_property object_get_link_property_powerpc #define object_get_root object_get_root_powerpc #define object_init_with_type object_init_with_type_powerpc diff --git a/qemu/qom/object.c b/qemu/qom/object.c index 43dcd14d..0cc4d0c6 100644 --- a/qemu/qom/object.c +++ b/qemu/qom/object.c @@ -1153,6 +1153,17 @@ Object *object_get_root(struct uc_struct *uc) return uc->root; } +Object *object_get_internal_root(struct uc_struct *uc) +{ + static Object *internal_root; + + if (!internal_root) { + internal_root = object_new(uc, "container"); + } + + return internal_root; +} + static void object_get_child_property(struct uc_struct *uc, Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { diff --git a/qemu/sparc.h b/qemu/sparc.h index 74357b73..b7d7f092 100644 --- a/qemu/sparc.h +++ b/qemu/sparc.h @@ -2391,6 +2391,7 @@ #define object_finalize object_finalize_sparc #define object_finalize_child_property object_finalize_child_property_sparc #define object_get_child_property object_get_child_property_sparc +#define object_get_internal_root object_get_internal_root_sparc #define object_get_link_property object_get_link_property_sparc #define object_get_root object_get_root_sparc #define object_init_with_type object_init_with_type_sparc diff --git a/qemu/sparc64.h b/qemu/sparc64.h index 5ece5199..2798b263 100644 --- a/qemu/sparc64.h +++ b/qemu/sparc64.h @@ -2391,6 +2391,7 @@ #define object_finalize object_finalize_sparc64 #define object_finalize_child_property object_finalize_child_property_sparc64 #define object_get_child_property object_get_child_property_sparc64 +#define object_get_internal_root object_get_internal_root_sparc64 #define object_get_link_property object_get_link_property_sparc64 #define object_get_root object_get_root_sparc64 #define object_init_with_type object_init_with_type_sparc64 diff --git a/qemu/x86_64.h b/qemu/x86_64.h index 974a0173..3fb3a989 100644 --- a/qemu/x86_64.h +++ b/qemu/x86_64.h @@ -2391,6 +2391,7 @@ #define object_finalize object_finalize_x86_64 #define object_finalize_child_property object_finalize_child_property_x86_64 #define object_get_child_property object_get_child_property_x86_64 +#define object_get_internal_root object_get_internal_root_x86_64 #define object_get_link_property object_get_link_property_x86_64 #define object_get_root object_get_root_x86_64 #define object_init_with_type object_init_with_type_x86_64