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

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

 



On Wed, Oct 26, 2011 at 01:17:36AM +0300, Zeeshan Ali (Khattak) wrote:
> From: "Zeeshan Ali (Khattak)" <zeeshanak@xxxxxxxxx>
> 
> API to create new storage pools.
> ---
>  libvirt-gobject/libvirt-gobject-connection.c |   40 ++++++++++++++++++++++++++
>  libvirt-gobject/libvirt-gobject-connection.h |    6 ++++
>  libvirt-gobject/libvirt-gobject.sym          |    1 +
>  3 files changed, 47 insertions(+), 0 deletions(-)
> 
> diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c
> index 30b7792..43a262a 100644
> --- a/libvirt-gobject/libvirt-gobject-connection.c
> +++ b/libvirt-gobject/libvirt-gobject-connection.c
> @@ -1201,3 +1201,43 @@ 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;
> +    }
> +
> +    GVirStoragePool *pool;
> +
> +    pool = GVIR_STORAGE_POOL(g_object_new(GVIR_TYPE_STORAGE_POOL,
> +                                          "handle", handle,
> +                                          NULL));
> +
> +    g_mutex_lock(priv->lock);
> +    g_hash_table_insert(priv->pools,
> +                        (gpointer)gvir_storage_pool_get_uuid(pool),
> +                        pool);
> +    g_mutex_unlock(priv->lock);
> +
> +    return g_object_ref(pool);
> +}
> diff --git a/libvirt-gobject/libvirt-gobject-connection.h b/libvirt-gobject/libvirt-gobject-connection.h
> index 8c1d1a4..3a8d888 100644
> --- a/libvirt-gobject/libvirt-gobject-connection.h
> +++ b/libvirt-gobject/libvirt-gobject-connection.h
> @@ -160,6 +160,12 @@ GVirStoragePool *gvir_connection_get_storage_pool(GVirConnection *conn,
>  GVirStoragePool *gvir_connection_find_storage_pool_by_name(GVirConnection *conn,
>                                                             const gchar *name);
>  
> +GVirStoragePool *gvir_connection_create_storage_pool
> +                                (GVirConnection *conn,
> +                                 GVirConfigStoragePool *conf,
> +                                 GError **err);
> +

ACK, but please add the 'unsigned int flags' parameter to this,
rather than hardcoding 0. Through bitter experiance, all libvirt
APIs now strive to have an 'unsigned int flags' parameter, because
we invariably need to invent flags at some time or another.



I wish GObject introspection supported default values, so we could
annotate all the flags parameters as taking a '0' default value
to avoid apps needing to set it all the time.... The annotations
are all defined, but the girscanner ignores them :-(

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 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]