[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH v4 2/8] qom: detect bad reentrance during object_class
From: |
Alexey Kardashevskiy |
Subject: |
[Qemu-ppc] [PATCH v4 2/8] qom: detect bad reentrance during object_class_foreach |
Date: |
Wed, 11 Dec 2013 21:22:15 +1100 |
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: Alexey Kardashevskiy <address@hidden>
---
Changes:
v4:
* rename: @enumerating -> @enumerating_types
* @enumerating_types is static and does not require initialization to "false"
---
qom/object.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/qom/object.c b/qom/object.c
index 3a43186..937af00 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_types;
static void type_table_add(TypeImpl *ti)
{
+ assert(!enumerating_types);
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_types = true;
g_hash_table_foreach(type_table_get(), object_class_foreach_tramp, &data);
+ enumerating_types = false;
}
int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),
--
1.8.4.rc4
- [Qemu-ppc] [PATCH v4 0/8] spapr: bootindex support, Alexey Kardashevskiy, 2013/12/11
- [Qemu-ppc] [PATCH v4 1/8] qom: do not register interface "types" in the type table, Alexey Kardashevskiy, 2013/12/11
- [Qemu-ppc] [PATCH v4 2/8] qom: detect bad reentrance during object_class_foreach,
Alexey Kardashevskiy <=
- [Qemu-ppc] [PATCH v4 6/8] qdev: introduce FWPathProvider interface, Alexey Kardashevskiy, 2013/12/11
- [Qemu-ppc] [PATCH v4 8/8] spapr: define interface to fix device pathname, Alexey Kardashevskiy, 2013/12/11
- [Qemu-ppc] [PATCH v4 3/8] boot: extend get_boot_devices_list() to ignore suffixes, Alexey Kardashevskiy, 2013/12/11
- [Qemu-ppc] [PATCH v4 4/8] spapr-llan: add to boot device list, Alexey Kardashevskiy, 2013/12/11
- [Qemu-ppc] [PATCH v4 7/8] vl: allow customizing the class of /machine, Alexey Kardashevskiy, 2013/12/11
- [Qemu-ppc] [PATCH v4 5/8] spapr-vio: fix firmware names, Alexey Kardashevskiy, 2013/12/11
- Re: [Qemu-ppc] [PATCH v4 0/8] spapr: bootindex support, Paolo Bonzini, 2013/12/11
- Re: [Qemu-ppc] [PATCH v4 0/8] spapr: bootindex support, Michael S. Tsirkin, 2013/12/12