diff mbox

[v4,1/9] qom: API to get instance_size of a type

Message ID 1465520348-13964-2-git-send-email-bharata@linux.vnet.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bharata B Rao June 10, 2016, 12:59 a.m. UTC
Add an API object_type_get_size(const char *typename) that returns the
instance_size of the give typename.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
---
 include/qom/object.h | 8 +++++++-
 qom/object.c         | 8 ++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

Comments

David Gibson June 10, 2016, 4:04 a.m. UTC | #1
On Fri, Jun 10, 2016 at 06:29:00AM +0530, Bharata B Rao wrote:
> Add an API object_type_get_size(const char *typename) that returns the
> instance_size of the give typename.
> 
> Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

This looks sensible to me, it would be nice to have an ack or two from
the qemu community at large.

> ---
>  include/qom/object.h | 8 +++++++-
>  qom/object.c         | 8 ++++++++
>  2 files changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/include/qom/object.h b/include/qom/object.h
> index 21bb5ff..460ddfc 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -1608,5 +1608,11 @@ int object_child_foreach_recursive(Object *obj,
>   */
>  Object *container_get(Object *root, const char *path);
>  
> -
> +/**
> + * object_type_get_size:
> + * @typename: Name of the Type whose instance_size is required
> + *
> + * Returns the instance_size of the given @typename.
> + */
> +size_t object_type_get_size(const char *typename);
>  #endif
> diff --git a/qom/object.c b/qom/object.c
> index 3bc8a00..0e75877 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -202,6 +202,14 @@ static size_t type_object_get_size(TypeImpl *ti)
>      return 0;
>  }
>  
> +size_t object_type_get_size(const char *typename)
> +{
> +    TypeImpl *type = type_get_by_name(typename);
> +
> +    g_assert(type != NULL);
> +    return type_object_get_size(type);
> +}
> +
>  static bool type_is_ancestor(TypeImpl *type, TypeImpl *target_type)
>  {
>      assert(target_type);
Igor Mammedov June 10, 2016, 7:38 a.m. UTC | #2
On Fri, 10 Jun 2016 14:04:41 +1000
David Gibson <david@gibson.dropbear.id.au> wrote:

> On Fri, Jun 10, 2016 at 06:29:00AM +0530, Bharata B Rao wrote:
> > Add an API object_type_get_size(const char *typename) that returns the
> > instance_size of the give typename.
I'd rename it to
  object_type_get_instance_size()
so it'd apparent what size is returned from name.

> > 
> > Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>  
> 
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> 
> This looks sensible to me, it would be nice to have an ack or two from
> the qemu community at large.
> 
> > ---
> >  include/qom/object.h | 8 +++++++-
> >  qom/object.c         | 8 ++++++++
> >  2 files changed, 15 insertions(+), 1 deletion(-)
> > 
> > diff --git a/include/qom/object.h b/include/qom/object.h
> > index 21bb5ff..460ddfc 100644
> > --- a/include/qom/object.h
> > +++ b/include/qom/object.h
> > @@ -1608,5 +1608,11 @@ int object_child_foreach_recursive(Object *obj,
> >   */
> >  Object *container_get(Object *root, const char *path);
> >  
> > -
> > +/**
> > + * object_type_get_size:
> > + * @typename: Name of the Type whose instance_size is required
> > + *
> > + * Returns the instance_size of the given @typename.
> > + */
> > +size_t object_type_get_size(const char *typename);
> >  #endif
> > diff --git a/qom/object.c b/qom/object.c
> > index 3bc8a00..0e75877 100644
> > --- a/qom/object.c
> > +++ b/qom/object.c
> > @@ -202,6 +202,14 @@ static size_t type_object_get_size(TypeImpl *ti)
> >      return 0;
> >  }
> >  
> > +size_t object_type_get_size(const char *typename)
> > +{
> > +    TypeImpl *type = type_get_by_name(typename);
> > +
> > +    g_assert(type != NULL);
> > +    return type_object_get_size(type);
> > +}
> > +
> >  static bool type_is_ancestor(TypeImpl *type, TypeImpl *target_type)
> >  {
> >      assert(target_type);  
>
David Gibson June 15, 2016, 5:48 a.m. UTC | #3
On Fri, Jun 10, 2016 at 09:38:24AM +0200, Igor Mammedov wrote:
> On Fri, 10 Jun 2016 14:04:41 +1000
> David Gibson <david@gibson.dropbear.id.au> wrote:
> 
> > On Fri, Jun 10, 2016 at 06:29:00AM +0530, Bharata B Rao wrote:
> > > Add an API object_type_get_size(const char *typename) that returns the
> > > instance_size of the give typename.
> I'd rename it to
>   object_type_get_instance_size()
> so it'd apparent what size is returned from name.

I'll make that change in my tree.

> 
> > > 
> > > Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>  
> > 
> > Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> > 
> > This looks sensible to me, it would be nice to have an ack or two from
> > the qemu community at large.
> > 
> > > ---
> > >  include/qom/object.h | 8 +++++++-
> > >  qom/object.c         | 8 ++++++++
> > >  2 files changed, 15 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/include/qom/object.h b/include/qom/object.h
> > > index 21bb5ff..460ddfc 100644
> > > --- a/include/qom/object.h
> > > +++ b/include/qom/object.h
> > > @@ -1608,5 +1608,11 @@ int object_child_foreach_recursive(Object *obj,
> > >   */
> > >  Object *container_get(Object *root, const char *path);
> > >  
> > > -
> > > +/**
> > > + * object_type_get_size:
> > > + * @typename: Name of the Type whose instance_size is required
> > > + *
> > > + * Returns the instance_size of the given @typename.
> > > + */
> > > +size_t object_type_get_size(const char *typename);
> > >  #endif
> > > diff --git a/qom/object.c b/qom/object.c
> > > index 3bc8a00..0e75877 100644
> > > --- a/qom/object.c
> > > +++ b/qom/object.c
> > > @@ -202,6 +202,14 @@ static size_t type_object_get_size(TypeImpl *ti)
> > >      return 0;
> > >  }
> > >  
> > > +size_t object_type_get_size(const char *typename)
> > > +{
> > > +    TypeImpl *type = type_get_by_name(typename);
> > > +
> > > +    g_assert(type != NULL);
> > > +    return type_object_get_size(type);
> > > +}
> > > +
> > >  static bool type_is_ancestor(TypeImpl *type, TypeImpl *target_type)
> > >  {
> > >      assert(target_type);  
> > 
>
diff mbox

Patch

diff --git a/include/qom/object.h b/include/qom/object.h
index 21bb5ff..460ddfc 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1608,5 +1608,11 @@  int object_child_foreach_recursive(Object *obj,
  */
 Object *container_get(Object *root, const char *path);
 
-
+/**
+ * object_type_get_size:
+ * @typename: Name of the Type whose instance_size is required
+ *
+ * Returns the instance_size of the given @typename.
+ */
+size_t object_type_get_size(const char *typename);
 #endif
diff --git a/qom/object.c b/qom/object.c
index 3bc8a00..0e75877 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -202,6 +202,14 @@  static size_t type_object_get_size(TypeImpl *ti)
     return 0;
 }
 
+size_t object_type_get_size(const char *typename)
+{
+    TypeImpl *type = type_get_by_name(typename);
+
+    g_assert(type != NULL);
+    return type_object_get_size(type);
+}
+
 static bool type_is_ancestor(TypeImpl *type, TypeImpl *target_type)
 {
     assert(target_type);