qom: fix registration of QOM interfaces
cover qom: fix registration of QOM interfaces
object_class_foreach can initialize new types, and also register new types corresponding to the implementations of interfaces. Those will change the type internal hashtable which is currently enumerated, and GHashTable does not permit this.
Fix this by not registering those internal types in the hash table, and assert that we do not reenter GHashTable incorrectly during iteration.
Hervé Poussineau (1):
qom: detect bad reentrance during object_class_foreach
Paolo Bonzini (1):
qom: do not register interface "types" in the type table
qom/object.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
Signature · 1 line
1.8.4.2
PATCH 1/2 qom: do not register interface "types" in the type table
There should be no need to look them up nor enumerate the interface "types", whose "classes" are really just vtables. Just create the types and add them to the interface list of the parent type.
--- qom/object.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
qom/object.c +10 -3
@@ -88,7 +88,7 @@ static TypeImpl *type_table_lookup(const char *name)return g_hash_table_lookup (type_table_get (), name); } -static TypeImpl *type_register_internal (const TypeInfo *info) +static TypeImpl *type_new (const TypeInfo *info) {TypeImpl *ti =g_malloc0 (sizeof (*ti));int i;
@@ -122,8 +122,15 @@ static TypeImpl *type_register_internal(const TypeInfo *info) } ti->num_interfaces = i; -type_table_add (ti); +return ti; +} +static TypeImpl *type_register_internal (const TypeInfo *info) +{ +TypeImpl *ti; + ti =type_new (info); + +type_table_add (ti);return ti; }
@@ -216,7 +223,7 @@ static void type_initialize_interface(TypeImpl *ti, const char *parent) info.name =g_strdup_printf ("%s::%s" , ti->name, info.parent); info.abstract = true; - iface_impl =type_register (&info); + iface_impl =type_new (&info);type_initialize (iface_impl);g_free ((char *)info.name);
Signature · 1 line
1.8.4.2
PATCH 2/2 qom: detect bad reentrance during object_class_foreach
In reply to Paolo BonziniFrom: Hervé Poussineau <[email protected]>
We should not modify the type hash table while it is being iterated on. Assert that it does not happen.
--- qom/object.c | 4 ++++ 1 file changed, 4 insertions(+)
qom/object.c +4 -0
@@ -78,8 +78,10 @@ static GHashTable *type_table_get(void)return type_table; } +static bool enumerating = false;static void type_table_add (TypeImpl *ti) { +assert (!enumerating);g_hash_table_insert (type_table_get (), (void *)ti->name, ti); }
@@ -666,7 +668,9 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), {OCFData data = { fn, implements_type, include_abstract, opaque }; + enumerating = true;g_hash_table_foreach (type_table_get (), object_class_foreach_tramp, &data); + enumerating = false; } int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),
Signature · 1 line
1.8.4.2
Re: [Qemu-devel] [PATCH 2/2] qom: detect bad reentrance during object_class_foreach
Quoted 16 lines · Paolo Bonzini
From: Hervé Poussineau <[email protected]>
We should not modify the type hash table while it is being iterated on. Assert that it does not happen.
Signed-off-by Hervé Poussineau <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- qom/object.c | 4 ++++ 1 file changed, 4 insertions(+)qom/object.c +0
-0
qom/object.c static GHashTable *type_table_get(void) · line 81
Quoted 4 lines
qom/object.c +1
-0@@ -78,8 +78,10 @@ static GHashTable *type_table_get(void)return type_table; } +static bool enumerating = false;
Global variable could probably use a more descriptive name.
Regards,
Peter
Quoted 20 lines
qom/object.c +3
-1static void type_table_add (TypeImpl *ti) { +assert (!enumerating);g_hash_table_insert (type_table_get (), (void *)ti->name, ti); }@@ -666,7 +668,9 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), {OCFData data = { fn, implements_type, include_abstract, opaque }; + enumerating = true;g_hash_table_foreach (type_table_get (), object_class_foreach_tramp, &data); + enumerating = false; } int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque), --1.8.4.2
Re: [Qemu-devel] [PATCH 2/2] qom: detect bad reentrance during object_class_foreach
Am 04.12.2013 06:51, schrieb Peter Crosthwaite:
Quoted 20 lines · Paolo Bonzini
Quoted 19 lines
From: Hervé Poussineau <[email protected]>
We should not modify the type hash table while it is being iterated on. Assert that it does not happen.
Signed-off-by Hervé Poussineau <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- qom/object.c | 4 ++++ 1 file changed, 4 insertions(+)qom/object.c +0
-0@@ -78,8 +78,10 @@ static GHashTable *type_table_get(void)return type_table; }
Quoted 3 lines
qom/object.c static GHashTable *type_table_get(void) · line 81
Quoted 1 line
qom/object.c +1
-0+static bool enumerating = false;Global variable could probably use a more descriptive name.
I renamed it to enumerating_types and dropped the assignment as suggested elsewhere by Alexey (a reply here would've been nice!).
I also took the liberty of inserted a white line to make the function better readable.
Regards,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH 2/2] qom: detect bad reentrance during object_class_foreach
Quoted 21 lines · Andreas Färber
Am 04.12.2013 06:51, schrieb Peter Crosthwaite:
Quoted 20 lines · Paolo Bonzini
Quoted 19 lines
From: Hervé Poussineau <[email protected]>
We should not modify the type hash table while it is being iterated on. Assert that it does not happen.
Signed-off-by Hervé Poussineau <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- qom/object.c | 4 ++++ 1 file changed, 4 insertions(+)qom/object.c +0
-0@@ -78,8 +78,10 @@ static GHashTable *type_table_get(void)return type_table; }
Quoted 6 lines
Quoted 3 lines
qom/object.c static GHashTable *type_table_get(void) · line 81
Quoted 1 line
qom/object.c +1
-0+static bool enumerating = false;Global variable could probably use a more descriptive name.
I renamed it to
enumerating_typesand dropped the assignment as suggested elsewhere by Alexey (a reply here would've been nice!).
Whose reply? To what? :)
Quoted 3 lines
I also took the liberty of inserted a white line to make the function better readable.
I do not mind, this was not my stuff :)
What I wonder about is what is going to happen to the rest of what I posted? Should I wait till this qom-next gets merged to upstream and repost my patches for Alex Graf again? Thanks.
Signature · 1 line
Alexey
Re: [Qemu-devel] [PATCH 2/2] qom: detect bad reentrance during object_class_foreach
Am 19.12.2013 12:38, schrieb Alexey Kardashevskiy:
Quoted 22 lines · Andreas Färber
Quoted 21 lines
Am 04.12.2013 06:51, schrieb Peter Crosthwaite:
Quoted 20 lines · Paolo Bonzini
Quoted 19 lines
From: Hervé Poussineau <[email protected]>
We should not modify the type hash table while it is being iterated on. Assert that it does not happen.
Signed-off-by Hervé Poussineau <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- qom/object.c | 4 ++++ 1 file changed, 4 insertions(+)qom/object.c +0
-0@@ -78,8 +78,10 @@ static GHashTable *type_table_get(void)return type_table; }
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
qom/object.c static GHashTable *type_table_get(void) · line 81
Quoted 1 line
qom/object.c +1
-0+static bool enumerating = false;Global variable could probably use a more descriptive name.
I renamed it to
enumerating_typesand dropped the assignment as suggested elsewhere by Alexey (a reply here would've been nice!).Whose reply? To what? :)
A reply of yours to Peter C.'s change request, stating that you have addressed it - and in this case in which series. :)
Quoted 8 lines
Quoted 2 lines
I also took the liberty of inserted a white line to make the function better readable.
I do not mind, this was not my stuff :)
What I wonder about is what is going to happen to the rest of what I posted? Should I wait till this qom-next gets merged to upstream and repost my patches for Alex Graf again? Thanks.
I do intend to post a pull before Chistmas, reviewing+applying the last no_user patch from Markus was one key ingredient for that.
Not sure which rest exactly you're referring to? I need to review your latest QemuOpts proposal among others. Actually I have a whole A4 page written down with series I'm wading through. ;)
Cheers,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH 2/2] qom: detect bad reentrance during object_class_foreach
Quoted 27 lines · Andreas Färber
Am 19.12.2013 12:38, schrieb Alexey Kardashevskiy:
Quoted 26 lines · Andreas Färber
Quoted 25 lines
Am 04.12.2013 06:51, schrieb Peter Crosthwaite:
Quoted 23 lines · Paolo Bonzini
Quoted 16 lines
From: Hervé Poussineau <[email protected]>
We should not modify the type hash table while it is being iterated on. Assert that it does not happen.
Signed-off-by Hervé Poussineau <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- qom/object.c | 4 ++++ 1 file changed, 4 insertions(+)qom/object.c +0
-0qom/object.c static GHashTable *type_table_get(void) · line 81
Quoted 4 lines
qom/object.c +1
-0@@ -78,8 +78,10 @@ static GHashTable *type_table_get(void)return type_table; } +static bool enumerating = false;Global variable could probably use a more descriptive name.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
I renamed it to
enumerating_typesand dropped the assignment as suggested elsewhere by Alexey (a reply here would've been nice!).Whose reply? To what? :)
A reply of yours to Peter C.'s change request, stating that you have addressed it - and in this case in which series. :)
You lost me here. I got these patches from Paolo Bonzini and I was told to repost them together with my other patches, that's it :)
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
I also took the liberty of inserted a white line to make the function better readable.
I do not mind, this was not my stuff :)
What I wonder about is what is going to happen to the rest of what I posted? Should I wait till this qom-next gets merged to upstream and repost my patches for Alex Graf again? Thanks.
Quoted 6 lines
I do intend to post a pull before Chistmas, reviewing+applying the last
no_userpatch from Markus was one key ingredient for that.Not sure which rest exactly you're referring to? I need to review your latest QemuOpts proposal among others. Actually I have a whole A4 page written down with series I'm wading through. ;)
I posted the "[PATCH v4 0/8] spapr: bootindex support" series which included the 2 patches you mentioned in this series, from the rest - 3 are for spapr and 3 are platform independent.
Signature · 1 line
Alexey
Re: [Qemu-devel] [PATCH 2/2] qom: detect bad reentrance during object_class_foreach
Quoted 52 lines · Alexey Kardashevskiy
Quoted 27 lines · Andreas Färber
Am 19.12.2013 12:38, schrieb Alexey Kardashevskiy:
Quoted 26 lines · Andreas Färber
Quoted 25 lines
Am 04.12.2013 06:51, schrieb Peter Crosthwaite:
Quoted 23 lines · Paolo Bonzini
Quoted 16 lines
From: Hervé Poussineau <[email protected]>
We should not modify the type hash table while it is being iterated on. Assert that it does not happen.
Signed-off-by Hervé Poussineau <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- qom/object.c | 4 ++++ 1 file changed, 4 insertions(+)qom/object.c +0
-0qom/object.c static GHashTable *type_table_get(void) · line 81
Quoted 4 lines
qom/object.c +1
-0@@ -78,8 +78,10 @@ static GHashTable *type_table_get(void)return type_table; } +static bool enumerating = false;Global variable could probably use a more descriptive name.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
I renamed it to
enumerating_typesand dropped the assignment as suggested elsewhere by Alexey (a reply here would've been nice!).Whose reply? To what? :)
A reply of yours to Peter C.'s change request, stating that you have addressed it - and in this case in which series. :)
You lost me here. I got these patches from Paolo Bonzini and I was told to repost them together with my other patches, that's it :)
Quoted 12 lines
Quoted 8 lines
Quoted 2 lines
I also took the liberty of inserted a white line to make the function better readable.
I do not mind, this was not my stuff :)
What I wonder about is what is going to happen to the rest of what I posted? Should I wait till this qom-next gets merged to upstream and repost my patches for Alex Graf again? Thanks.
I do intend to post a pull before Chistmas, reviewing+applying the last
no_userpatch from Markus was one key ingredient for that.
Quoted 8 lines
Quoted 3 lines
Not sure which rest exactly you're referring to? I need to review your latest QemuOpts proposal among others. Actually I have a whole A4 page written down with series I'm wading through. ;)
I posted the "[PATCH v4 0/8] spapr: bootindex support" series which included the 2 patches you mentioned in this series, from the rest - 3 are for spapr and 3 are platform independent.
So? What do I do with my 6 patches from the "[PATCH v4 0/8] spapr:
bootindex support" series? Thanks!
Signature · 1 line
Alexey
Re: [Qemu-devel] [PATCH 2/2] qom: detect bad reentrance during object_class_foreach
Am 24.12.2013 07:49, schrieb Alexey Kardashevskiy:
Quoted 15 lines · Alexey Kardashevskiy
Quoted 14 lines · Andreas Färber
Quoted 11 lines
Am 19.12.2013 12:38, schrieb Alexey Kardashevskiy:
Quoted 3 lines
What I wonder about is what is going to happen to the rest of what I posted? Should I wait till this qom-next gets merged to upstream and repost my patches for Alex Graf again? Thanks.
I do intend to post a pull before Chistmas, reviewing+applying the last
no_userpatch from Markus was one key ingredient for that.Not sure which rest exactly you're referring to? I need to review your latest QemuOpts proposal among others. Actually I have a whole A4 page written down with series I'm wading through. ;)
Quoted 8 lines
Quoted 3 lines
I posted the "[PATCH v4 0/8] spapr: bootindex support" series which included the 2 patches you mentioned in this series, from the rest - 3 are for spapr and 3 are platform independent.
So? What do I do with my 6 patches from the "[PATCH v4 0/8] spapr:
bootindex support" series? Thanks!
Be patient. ;)
1) I am on holidays and thus not available full-time.
2) Alex has already sent out his ppc PULL, so no urgency.
3) As mentioned, I plan to post QOM and CPU PULLs later today.
And no, you don't need to repost after parts of your series get applied pretty much unmodified.
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Andreas Färber
AppliedAm 03.12.2013 16:41, schrieb Paolo Bonzini:
Quoted 5 lines
Hervé Poussineau (1):
qom: detect bad reentrance duringobject_class_foreachPaolo Bonzini (1):
qom: do not register interface "types" in the type table
Thanks, applied to qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-next
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg