[libvirt] [libvirt-glib] Add gvir_storage_vol_resize()

Christophe Fergeau cfergeau at redhat.com
Fri Feb 3 08:59:53 UTC 2012


ACK

Christophe

On Wed, Feb 01, 2012 at 10:32:02PM +0200, Zeeshan Ali (Khattak) wrote:
> From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>
> 
> Add wrapper for virStorageVolResize().
> ---
>  libvirt-gobject/libvirt-gobject-storage-vol.c |   27 +++++++++++++++++++++++++
>  libvirt-gobject/libvirt-gobject-storage-vol.h |   20 ++++++++++++++++++
>  libvirt-gobject/libvirt-gobject.sym           |    1 +
>  3 files changed, 48 insertions(+), 0 deletions(-)
> 
> diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.c b/libvirt-gobject/libvirt-gobject-storage-vol.c
> index 491e2e6..78ce76e 100644
> --- a/libvirt-gobject/libvirt-gobject-storage-vol.c
> +++ b/libvirt-gobject/libvirt-gobject-storage-vol.c
> @@ -299,3 +299,30 @@ gboolean gvir_storage_vol_delete(GVirStorageVol *vol,
>  
>      return TRUE;
>  }
> +
> +/**
> + * gvir_storage_vol_resize:
> + * @vol: the storage volume to resize
> + * @capacity: the new capacity of the volume
> + * @flags: (type GVirStorageVolResizeFlags): the flags
> + * @err: Return location for errors, or NULL
> + *
> + * Changes the capacity of the storage volume @vol to @capacity.
> + *
> + * Returns: #TRUE success, #FALSE otherwise
> + */
> +gboolean gvir_storage_vol_resize(GVirStorageVol *vol,
> +                                 guint64 capacity,
> +                                 guint flags,
> +                                 GError **err)
> +{
> +    if (virStorageVolResize(vol->priv->handle, capacity, flags) < 0) {
> +        gvir_set_error_literal(err,
> +                               GVIR_STORAGE_VOL_ERROR,
> +                               0,
> +                               "Unable to resize volume storage");
> +        return FALSE;
> +    }
> +
> +    return TRUE;
> +}
> diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.h b/libvirt-gobject/libvirt-gobject-storage-vol.h
> index 25f683a..b425f0a 100644
> --- a/libvirt-gobject/libvirt-gobject-storage-vol.h
> +++ b/libvirt-gobject/libvirt-gobject-storage-vol.h
> @@ -23,6 +23,7 @@
>  #if !defined(__LIBVIRT_GOBJECT_H__) && !defined(LIBVIRT_GOBJECT_BUILD)
>  #error "Only <libvirt-gobject/libvirt-gobject.h> can be included directly."
>  #endif
> +#include <libvirt/libvirt.h>
>  
>  #ifndef __LIBVIRT_GOBJECT_STORAGE_VOL_H__
>  #define __LIBVIRT_GOBJECT_STORAGE_VOL_H__
> @@ -65,6 +66,21 @@ typedef enum {
>      GVIR_STORAGE_VOL_STATE_DIR   = 2, /* Directory-passthrough based volume */
>  } GVirStorageVolType;
>  
> +/**
> + * GVirStorageVolResizeFlags:
> + * @GVIR_STORAGE_VOL_RESIZE_NONE: No flags
> + * @GVIR_STORAGE_VOL_RESIZE_ALLOCATE: force allocation of new size
> + * @GVIR_STORAGE_VOL_RESIZE_DELTA: size is relative to current
> + * @GVIR_STORAGE_VOL_RESIZE_SHRINK: allow decrease in capacity. This combined
> + * with #GVIR_STORAGE_VOL_RESIZE_DELTA, implies a negative delta.
> + */
> +typedef enum {
> +    GVIR_STORAGE_VOL_RESIZE_NONE     = 0,
> +    GVIR_STORAGE_VOL_RESIZE_ALLOCATE = VIR_STORAGE_VOL_RESIZE_ALLOCATE,
> +    GVIR_STORAGE_VOL_RESIZE_DELTA    = VIR_STORAGE_VOL_RESIZE_DELTA,
> +    GVIR_STORAGE_VOL_RESIZE_SHRINK   = VIR_STORAGE_VOL_RESIZE_SHRINK,
> +} GVirStorageVolResizeFlags;
> +
>  typedef struct _GVirStorageVolInfo GVirStorageVolInfo;
>  struct _GVirStorageVolInfo
>  {
> @@ -89,6 +105,10 @@ GVirConfigStorageVol *gvir_storage_vol_get_config(GVirStorageVol *vol,
>                                                    GError **err);
>  GVirStorageVolInfo *gvir_storage_vol_get_info(GVirStorageVol *vol,
>                                                GError **err);
> +gboolean gvir_storage_vol_resize(GVirStorageVol *vol,
> +                                 guint64 capacity,
> +                                 guint flags,
> +                                 GError **err);
>  
>  G_END_DECLS
>  
> diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
> index a4f03f7..468bf65 100644
> --- a/libvirt-gobject/libvirt-gobject.sym
> +++ b/libvirt-gobject/libvirt-gobject.sym
> @@ -126,6 +126,7 @@ LIBVIRT_GOBJECT_0.0.4 {
>  	gvir_storage_vol_get_config;
>  	gvir_storage_vol_get_info;
>  	gvir_storage_vol_delete;
> +	gvir_storage_vol_resize;
>  
>  	gvir_connection_handle_get_type;
>  
> -- 
> 1.7.7.6
> 
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120203/73d8381e/attachment-0001.sig>


More information about the libvir-list mailing list