From 8f6dfc8d04aa713a8a6f1856a5c2fa68100ecd77 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost@redhat.com>
Date: Thu, 19 Oct 2017 01:34:51 +0200
Subject: [PATCH 62/69] vl: Clean up user-creatable objects when exiting
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
RH-Author: Eduardo Habkost <ehabkost@redhat.com>
Message-id: <20171019013453.21449-3-ehabkost@redhat.com>
Patchwork-id: 77368
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH 2/4] vl: Clean up user-creatable objects when exiting
Bugzilla: 1460848
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Delete all user-creatable objects in /objects when exiting QEMU, so they
can perform cleanup actions.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20170824192315.5897-2-ehabkost@redhat.com>
Acked-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Zack Cornelius <zack.cornelius@kove.net>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
(cherry picked from commit 9d5139e543e8579aacd324193680c64fd1463d89)
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
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 18b837c..55949e6 100644
--- a/vl.c
+++ b/vl.c
@@ -4814,6 +4814,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;
--
1.8.3.1