[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 02/11] qom: detect bad reentrance during object_clas
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH 02/11] qom: detect bad reentrance during object_class_foreach |
Date: |
Wed, 11 Dec 2013 02:01:17 +0100 |
From: Hervé Poussineau <address@hidden>
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 <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Igor Mammedov <address@hidden>
---
v2:
* make ver more descriptinve s/enumerating/enumerating_classes/
[asked-by: Peter Crosthwaite]
---
qom/object.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/qom/object.c b/qom/object.c
index 3a43186..4a0fb86 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -78,8 +78,10 @@ static GHashTable *type_table_get(void)
return type_table;
}
+static bool enumerating_classes = false;
static void type_table_add(TypeImpl *ti)
{
+ assert(!enumerating_classes);
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_classes = true;
g_hash_table_foreach(type_table_get(), object_class_foreach_tramp, &data);
+ enumerating_classes = false;
}
int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),
--
1.7.1
- [Qemu-devel] [PATCH 00/11 v2] Refactor PCI/SHPC/PCIE hotplug to use a more generic hotplug API, Igor Mammedov, 2013/12/10
- [Qemu-devel] [PATCH 01/11] qom: do not register interface "types" in the type table, Igor Mammedov, 2013/12/10
- [Qemu-devel] [PATCH 02/11] qom: detect bad reentrance during object_class_foreach,
Igor Mammedov <=
- [Qemu-devel] [PATCH 03/11] define hotplug interface, Igor Mammedov, 2013/12/10
- [Qemu-devel] [PATCH 04/11] qdev: add to BusState "hotplug-handler" link, Igor Mammedov, 2013/12/10
- [Qemu-devel] [PATCH 05/11] qdev: add "hotplugable" property to Device, Igor Mammedov, 2013/12/10
- Re: [Qemu-devel] [PATCH 05/11] qdev: add "hotplugable" property to Device, Igor Mammedov, 2013/12/11
- Re: [Qemu-devel] [PATCH 05/11] qdev: add "hotplugable" property to Device, Paolo Bonzini, 2013/12/11
- Re: [Qemu-devel] [PATCH 05/11] qdev: add "hotplugable" property to Device, Igor Mammedov, 2013/12/11