diff mbox

[1/7] qom: Make link property API public

Message ID 20170628124850.12821-2-famz@redhat.com
State New
Headers show

Commit Message

Fam Zheng June 28, 2017, 12:48 p.m. UTC
The get/set pair and the struct will be reused by qdev link prop, make
them public.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 include/qom/object.h | 13 +++++++++++++
 qom/object.c         | 18 ++++++------------
 2 files changed, 19 insertions(+), 12 deletions(-)

Comments

Paolo Bonzini June 28, 2017, 1:32 p.m. UTC | #1
On 28/06/2017 14:48, Fam Zheng wrote:
> The get/set pair and the struct will be reused by qdev link prop, make
> them public.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>

Maybe it's better to make it a separate header file.  No other objections.

Paolo

> ---
>  include/qom/object.h | 13 +++++++++++++
>  qom/object.c         | 18 ++++++------------
>  2 files changed, 19 insertions(+), 12 deletions(-)
> 
> diff --git a/include/qom/object.h b/include/qom/object.h
> index abaeb8c..4659e6a 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -1613,4 +1613,17 @@ Object *container_get(Object *root, const char *path);
>   * Returns the instance_size of the given @typename.
>   */
>  size_t object_type_get_instance_size(const char *typename);
> +
> +typedef struct {
> +    Object **child;
> +    void (*check)(Object *, const char *, Object *, Error **);
> +    ObjectPropertyLinkFlags flags;
> +} LinkProperty;
> +
> +void object_get_link_property(Object *obj, Visitor *v,
> +                              const char *name, void *opaque,
> +                              Error **errp);
> +void object_set_link_property(Object *obj, Visitor *v,
> +                              const char *name, void *opaque,
> +                              Error **errp);
>  #endif
> diff --git a/qom/object.c b/qom/object.c
> index 5f6fdfa..3868370 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -1434,15 +1434,9 @@ void object_property_allow_set_link(Object *obj, const char *name,
>      /* Allow the link to be set, always */
>  }
>  
> -typedef struct {
> -    Object **child;
> -    void (*check)(Object *, const char *, Object *, Error **);
> -    ObjectPropertyLinkFlags flags;
> -} LinkProperty;
> -
> -static void object_get_link_property(Object *obj, Visitor *v,
> -                                     const char *name, void *opaque,
> -                                     Error **errp)
> +void object_get_link_property(Object *obj, Visitor *v,
> +                              const char *name, void *opaque,
> +                              Error **errp)
>  {
>      LinkProperty *lprop = opaque;
>      Object **child = lprop->child;
> @@ -1498,9 +1492,9 @@ static Object *object_resolve_link(Object *obj, const char *name,
>      return target;
>  }
>  
> -static void object_set_link_property(Object *obj, Visitor *v,
> -                                     const char *name, void *opaque,
> -                                     Error **errp)
> +void object_set_link_property(Object *obj, Visitor *v,
> +                              const char *name, void *opaque,
> +                              Error **errp)
>  {
>      Error *local_err = NULL;
>      LinkProperty *prop = opaque;
>
Andreas Färber June 28, 2017, 1:36 p.m. UTC | #2
Am 28.06.2017 um 15:32 schrieb Paolo Bonzini:
> On 28/06/2017 14:48, Fam Zheng wrote:
>> The get/set pair and the struct will be reused by qdev link prop, make
>> them public.
>>
>> Signed-off-by: Fam Zheng <famz@redhat.com>
> 
> Maybe it's better to make it a separate header file.  No other objections.

So you think it should be added?

The alternative would be moving info qom-tree forward and finally
deprecating info qtree. There was a patch of mine to make it list
properties with -v or so, but there were StringOutputVisitor
dependencies where it got stuck in review.

Regards,
Andreas
Fam Zheng June 28, 2017, 2:09 p.m. UTC | #3
On Wed, 06/28 15:36, Andreas Färber wrote:
> The alternative would be moving info qom-tree forward and finally
> deprecating info qtree. There was a patch of mine to make it list
> properties with -v or so, but there were StringOutputVisitor
> dependencies where it got stuck in review.

No objection to enhancing info qom-tree, but also no idea how to help. :)

BTW, will it print much more information than "info qtree"? If so deprecating it
sounds like a bad idea for me. "info qtree" output is already lengthy. As HMP is
for human, it would be nice if the output is easy to extract interesting
information with eyeball, rather than dumping everything.

Fam
diff mbox

Patch

diff --git a/include/qom/object.h b/include/qom/object.h
index abaeb8c..4659e6a 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1613,4 +1613,17 @@  Object *container_get(Object *root, const char *path);
  * Returns the instance_size of the given @typename.
  */
 size_t object_type_get_instance_size(const char *typename);
+
+typedef struct {
+    Object **child;
+    void (*check)(Object *, const char *, Object *, Error **);
+    ObjectPropertyLinkFlags flags;
+} LinkProperty;
+
+void object_get_link_property(Object *obj, Visitor *v,
+                              const char *name, void *opaque,
+                              Error **errp);
+void object_set_link_property(Object *obj, Visitor *v,
+                              const char *name, void *opaque,
+                              Error **errp);
 #endif
diff --git a/qom/object.c b/qom/object.c
index 5f6fdfa..3868370 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1434,15 +1434,9 @@  void object_property_allow_set_link(Object *obj, const char *name,
     /* Allow the link to be set, always */
 }
 
-typedef struct {
-    Object **child;
-    void (*check)(Object *, const char *, Object *, Error **);
-    ObjectPropertyLinkFlags flags;
-} LinkProperty;
-
-static void object_get_link_property(Object *obj, Visitor *v,
-                                     const char *name, void *opaque,
-                                     Error **errp)
+void object_get_link_property(Object *obj, Visitor *v,
+                              const char *name, void *opaque,
+                              Error **errp)
 {
     LinkProperty *lprop = opaque;
     Object **child = lprop->child;
@@ -1498,9 +1492,9 @@  static Object *object_resolve_link(Object *obj, const char *name,
     return target;
 }
 
-static void object_set_link_property(Object *obj, Visitor *v,
-                                     const char *name, void *opaque,
-                                     Error **errp)
+void object_set_link_property(Object *obj, Visitor *v,
+                              const char *name, void *opaque,
+                              Error **errp)
 {
     Error *local_err = NULL;
     LinkProperty *prop = opaque;