On 08/24/2017 04:23 PM, Eduardo Habkost wrote:
Delete all user-creatable objects in /objects when exiting QEMU, so they
can perform cleanup actions.
Signed-off-by: Eduardo Habkost <ehabk...@redhat.com>
Acked-by: Philippe Mathieu-Daudé <f4...@amsat.org>
---
Changes v1 -> v2:
* (none)
---
include/qom/object_interfaces.h | 8 ++++++++
qom/object_interfaces.c | 5 +++++
vl.c | 1 +
3 files changed, 14 insertions(+)
diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index fdd7603..3f5f206 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -148,4 +148,12 @@ int user_creatable_add_opts_foreach(void *opaque,
*/
void user_creatable_del(const char *id, Error **errp);
+/**
+ * user_creatable_cleanup:
+ *
+ * Delete all user-creatable objects and the user-creatable
+ * objects container.
+ */
+void user_creatable_cleanup(void);
+
#endif
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index ff27e06..dbf8878 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -193,6 +193,11 @@ void user_creatable_del(const char *id, Error **errp)
object_unparent(obj);
}
+void user_creatable_cleanup(void)
+{
+ object_unparent(object_get_objects_root());
+}
+
static void register_types(void)
{
static const TypeInfo uc_interface_info = {
diff --git a/vl.c b/vl.c
index 8e247cc..91d0ef0 100644
--- a/vl.c
+++ b/vl.c
@@ -4801,6 +4801,7 @@ int main(int argc, char **argv, char **envp)
audio_cleanup();
monitor_cleanup();
qemu_chr_cleanup();
+ user_creatable_cleanup();
/* TODO: unref root container, check all devices are ok */
return 0;