Patchwork [07/16] qom: release previous object when setting

login
register
mail settings
Submitter Corey Minyard
Date Sept. 18, 2012, 8 p.m.
Message ID <1347998443-20599-8-git-send-email-minyard@acm.org>
Download mbox | patch
Permalink /patch/184832/
State New
Headers show

Comments

Corey Minyard - Sept. 18, 2012, 8 p.m.
From: Corey Minyard <cminyard@mvista.com>

When setting an object, if you don't release the previous object
that was there, it may become unusable.  This change allows a
chardev to be removed from one object's properties and added to
another's.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qom/object.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

Patch

diff --git a/qom/object.c b/qom/object.c
index e3e9242..6bbb6a8 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -692,6 +692,9 @@  void object_property_set(Object *obj, Visitor *v, const char *name,
     if (!prop->set) {
         error_set(errp, QERR_PERMISSION_DENIED);
     } else {
+        if (prop->release) {
+            prop->release(obj, name, prop->opaque);
+        }
         prop->set(obj, v, prop->opaque, name, errp);
     }
 }