diff mbox series

[v6,02/11] qom: don't require user creatable objects to be registered

Message ID 20181019133835.16494-3-berrange@redhat.com
State New
Headers show
Series Add a standard authorization framework | expand

Commit Message

Daniel P. Berrangé Oct. 19, 2018, 1:38 p.m. UTC
When an object is in turn owned by another user object, it is not
desirable to expose this in the QOM object hierarchy, as it is
just an internal implementation detail, we should be free to change
without exposure.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 qom/object.c            | 12 ++++++++----
 qom/object_interfaces.c | 16 ++++++++++------
 2 files changed, 18 insertions(+), 10 deletions(-)

Comments

Marc-André Lureau Nov. 7, 2018, 6:09 p.m. UTC | #1
On Fri, Oct 19, 2018 at 5:39 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> When an object is in turn owned by another user object, it is not
> desirable to expose this in the QOM object hierarchy, as it is
> just an internal implementation detail, we should be free to change
> without exposure.
>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  qom/object.c            | 12 ++++++++----
>  qom/object_interfaces.c | 16 ++++++++++------
>  2 files changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/qom/object.c b/qom/object.c
> index 547dcf97c3..f20f0c45a7 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -607,15 +607,19 @@ Object *object_new_with_propv(const char *typename,
>          goto error;
>      }
>
> -    object_property_add_child(parent, id, obj, &local_err);
> -    if (local_err) {
> -        goto error;
> +    if (id != NULL) {
> +        object_property_add_child(parent, id, obj, &local_err);
> +        if (local_err) {
> +            goto error;
> +        }
>      }
>
>      if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
>          user_creatable_complete(obj, &local_err);
>          if (local_err) {
> -            object_unparent(obj);
> +            if (id != NULL) {
> +                object_unparent(obj);
> +            }
>              goto error;
>          }
>      }
> diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
> index 941fd63afd..94d5f91d69 100644
> --- a/qom/object_interfaces.c
> +++ b/qom/object_interfaces.c
> @@ -83,16 +83,20 @@ Object *user_creatable_add_type(const char *type, const char *id,
>          goto out;
>      }
>
> -    object_property_add_child(object_get_objects_root(),
> -                              id, obj, &local_err);
> -    if (local_err) {
> -        goto out;
> +    if (id != NULL) {
> +        object_property_add_child(object_get_objects_root(),
> +                                  id, obj, &local_err);
> +        if (local_err) {
> +            goto out;
> +        }
>      }
>
>      user_creatable_complete(obj, &local_err);
>      if (local_err) {
> -        object_property_del(object_get_objects_root(),
> -                            id, &error_abort);
> +        if (id != NULL) {
> +            object_property_del(object_get_objects_root(),
> +                                id, &error_abort);
> +        }
>          goto out;
>      }
>  out:
> --
> 2.17.2
>
>
diff mbox series

Patch

diff --git a/qom/object.c b/qom/object.c
index 547dcf97c3..f20f0c45a7 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -607,15 +607,19 @@  Object *object_new_with_propv(const char *typename,
         goto error;
     }
 
-    object_property_add_child(parent, id, obj, &local_err);
-    if (local_err) {
-        goto error;
+    if (id != NULL) {
+        object_property_add_child(parent, id, obj, &local_err);
+        if (local_err) {
+            goto error;
+        }
     }
 
     if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
         user_creatable_complete(obj, &local_err);
         if (local_err) {
-            object_unparent(obj);
+            if (id != NULL) {
+                object_unparent(obj);
+            }
             goto error;
         }
     }
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 941fd63afd..94d5f91d69 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -83,16 +83,20 @@  Object *user_creatable_add_type(const char *type, const char *id,
         goto out;
     }
 
-    object_property_add_child(object_get_objects_root(),
-                              id, obj, &local_err);
-    if (local_err) {
-        goto out;
+    if (id != NULL) {
+        object_property_add_child(object_get_objects_root(),
+                                  id, obj, &local_err);
+        if (local_err) {
+            goto out;
+        }
     }
 
     user_creatable_complete(obj, &local_err);
     if (local_err) {
-        object_property_del(object_get_objects_root(),
-                            id, &error_abort);
+        if (id != NULL) {
+            object_property_del(object_get_objects_root(),
+                                id, &error_abort);
+        }
         goto out;
     }
 out: