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

Re: [libvirt] [libosinfo 2/2] Add gvir_connection_create_storage_pool()



On Tue, Oct 25, 2011 at 10:56:56PM +0300, Zeeshan Ali (Khattak) wrote:
> From: "Zeeshan Ali (Khattak)" <zeeshanak gnome org>
> 
> API to create new storage pools. This function also activates and builds
> the storage pool for you.
> ---
>  libvirt-gobject/libvirt-gobject-connection.c |   54 ++++++++++++++++++++++++++
>  libvirt-gobject/libvirt-gobject-connection.h |    6 +++
>  libvirt-gobject/libvirt-gobject.sym          |    1 +
>  3 files changed, 61 insertions(+), 0 deletions(-)
> 
> diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c
> index 30b7792..921c53c 100644
> --- a/libvirt-gobject/libvirt-gobject-connection.c
> +++ b/libvirt-gobject/libvirt-gobject-connection.c
> @@ -1201,3 +1201,57 @@ GVirDomain *gvir_connection_create_domain(GVirConnection *conn,
>  
>      return g_object_ref(domain);
>  }
> +
> +/**
> + * gvir_connection_create_storage_pool:
> + * @conn: the connection on which to create the pool
> + * @conf: the configuration for the new storage pool
> + * Returns: (transfer full): the newly created storage pool
> + */
> +GVirStoragePool *gvir_connection_create_storage_pool
> +                                (GVirConnection *conn,
> +                                 GVirConfigStoragePool *conf,
> +                                 GError **err) {
> +    const gchar *xml;
> +    virStoragePoolPtr handle;
> +    GVirConnectionPrivate *priv = conn->priv;
> +
> +    xml = gvir_config_object_get_doc(GVIR_CONFIG_OBJECT(conf));
> +
> +    g_return_val_if_fail(xml != NULL, NULL);
> +
> +    if (!(handle = virStoragePoolDefineXML(priv->conn, xml, 0))) {
> +        *err = gvir_error_new_literal(GVIR_CONNECTION_ERROR,
> +                                      0,
> +                                      "Failed to create storage pool");
> +        return NULL;
> +    }
> +
> +    if (virStoragePoolBuild(handle, 0)) {
> +        *err = gvir_error_new_literal(GVIR_CONNECTION_ERROR,
> +                                      0,
> +                                      "Failed to build storage pool");
> +        return NULL;
> +    }
> +
> +    if (virStoragePoolCreate(handle, 0)) {
> +        *err = gvir_error_new_literal(GVIR_CONNECTION_ERROR,
> +                                      0,
> +                                      "Failed to start storage pool");
> +        return NULL;
> +    }

IMHO you don't really want to tie invocation of these three
methods together, since it is quite typical to need to run
them indepedantly.

For example if you have an existing LVM volume group, you
don't want to run build. 

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]