[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [libvirt-glib 1/2] Wrap storage pool info API



On Thu, Dec 01, 2011 at 12:02:48PM +0100, Christophe Fergeau wrote:
> On Wed, Nov 30, 2011 at 08:11:30PM +0200, Zeeshan Ali (Khattak) wrote:
> > From: "Zeeshan Ali (Khattak)" <zeeshanak gnome org>
> > 
> > ---
> >  libvirt-gobject/libvirt-gobject-storage-pool.c |   44 ++++++++++++++++++++++++
> >  libvirt-gobject/libvirt-gobject-storage-pool.h |   21 +++++++++++
> >  libvirt-gobject/libvirt-gobject.sym            |    2 +
> >  3 files changed, 67 insertions(+), 0 deletions(-)
> > 
> > diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
> > index da8ada5..3c30a3d 100644
> > --- a/libvirt-gobject/libvirt-gobject-storage-pool.c
> > +++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
> > @@ -189,6 +189,21 @@ gvir_storage_pool_handle_free(GVirStoragePoolHandle *src)
> >  G_DEFINE_BOXED_TYPE(GVirStoragePoolHandle, gvir_storage_pool_handle,
> >                      gvir_storage_pool_handle_copy, gvir_storage_pool_handle_free)
> >  
> > +static GVirStoragePoolInfo *
> > +gvir_storage_pool_info_copy(GVirStoragePoolInfo *info)
> > +{
> > +    return g_slice_dup(GVirStoragePoolInfo, info);
> > +}
> > +
> > +static void
> > +gvir_storage_pool_info_free(GVirStoragePoolInfo *info)
> > +{
> > +    g_slice_free(GVirStoragePoolInfo, info);
> > +}
> > +
> > +G_DEFINE_BOXED_TYPE(GVirStoragePoolInfo, gvir_storage_pool_info,
> > +                    gvir_storage_pool_info_copy, gvir_storage_pool_info_free)
> > +
> >  const gchar *gvir_storage_pool_get_name(GVirStoragePool *pool)
> >  {
> >      GVirStoragePoolPrivate *priv = pool->priv;
> > @@ -237,6 +252,35 @@ GVirConfigStoragePool *gvir_storage_pool_get_config(GVirStoragePool *pool,
> >      return conf;
> >  }
> >  
> > +/**
> > + * gvir_storage_pool_get_info:
> > + * @pool: the storage_pool
> > + * Returns: (transfer full): the info
> > + */
> > +GVirStoragePoolInfo *gvir_storage_pool_get_info(GVirStoragePool *pool,
> > +                                                GError **err)
> > +{
> > +    GVirStoragePoolPrivate *priv = pool->priv;
> > +    virStoragePoolInfo info;
> > +    GVirStoragePoolInfo *ret;
> > +
> > +    if (virStoragePoolGetInfo(priv->handle, &info) < 0) {
> > +        if (err)
> > +            *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR,
> > +                                          0,
> > +                                          "Unable to get storage pool info");
> > +        return NULL;
> > +    }
> > +
> > +    ret = g_slice_new(GVirStoragePoolInfo);
> > +    ret->state = info.state;
> > +    ret->capacity = info.capacity;
> > +    ret->allocation = info.allocation;
> > +    ret->available = info.available;
> > +
> > +    return ret;
> > +}
> > +
> 
> Any idea if this is always non blocking, or if it can take time if the
> storage is remote ?

This is always fast - it isn't updated unless you do a virStoragePoolRefresh


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]