[libvirt] [libvirt-glib] storage-pool: API to get/set autostart flag

Add binding for virStoragePoolGetAutostart & virStoragePoolSetAutostart. --- libvirt-gobject/libvirt-gobject-storage-pool.c | 52 ++++++++++++++++++++++++++ libvirt-gobject/libvirt-gobject-storage-pool.h | 5 +++ libvirt-gobject/libvirt-gobject.sym | 6 +++ 3 files changed, 63 insertions(+) diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c index f3eac0d..e520c6a 100644 --- a/libvirt-gobject/libvirt-gobject-storage-pool.c +++ b/libvirt-gobject/libvirt-gobject-storage-pool.c @@ -1048,6 +1048,58 @@ gboolean gvir_storage_pool_delete (GVirStoragePool *pool, return TRUE; } +/** + * gvir_storage_pool_get_autostart: + * @pool: the storage pool + * @err: return location for any #GError + * + * Return value: #True if autostart is enabled, #False otherwise. + */ +gboolean gvir_storage_pool_get_autostart(GVirStoragePool *pool, + GError **err) +{ + gboolean ret = FALSE; + + g_return_val_if_fail(GVIR_IS_STORAGE_POOL(pool), ret); + g_return_val_if_fail(err == NULL || *err == NULL, ret); + + if (virStoragePoolGetAutostart(pool->priv->handle, &ret)) { + gvir_set_error_literal(err, GVIR_STORAGE_POOL_ERROR, + 0, + "Failed to get autostart flag from storage pool"); + return FALSE; + } + + return ret; +} + +/** + * gvir_storage_pool_set_autostart: + * @pool: the storage pool + * @autostart: New value for autostart flag + * @err: return location for any #GError + * + * Sets whether or not storage pool @pool is started automatically on boot. + * + * Return value: #TRUE on success, #FALSE otherwise. + */ +gboolean gvir_storage_pool_set_autostart(GVirStoragePool *pool, + gboolean autostart, + GError **err) +{ + g_return_val_if_fail(GVIR_IS_STORAGE_POOL(pool), FALSE); + g_return_val_if_fail(err == NULL || *err == NULL, FALSE); + + if (virStoragePoolSetAutostart(pool->priv->handle, autostart)) { + gvir_set_error_literal(err, GVIR_STORAGE_POOL_ERROR, + 0, + "Failed to set autostart flag on storage pool"); + return FALSE; + } + + return TRUE; +} + static void gvir_storage_pool_delete_helper(GSimpleAsyncResult *res, GObject *object, diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.h b/libvirt-gobject/libvirt-gobject-storage-pool.h index f8529f0..f7f879c 100644 --- a/libvirt-gobject/libvirt-gobject-storage-pool.h +++ b/libvirt-gobject/libvirt-gobject-storage-pool.h @@ -166,6 +166,11 @@ void gvir_storage_pool_delete_async (GVirStoragePool *pool, gboolean gvir_storage_pool_delete_finish(GVirStoragePool *pool, GAsyncResult *result, GError **err); +gboolean gvir_storage_pool_get_autostart(GVirStoragePool *pool, + GError **err); +gboolean gvir_storage_pool_set_autostart(GVirStoragePool *pool, + gboolean autostart, + GError **err); G_END_DECLS diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym index 927cad9..dcda675 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -265,4 +265,10 @@ LIBVIRT_GOBJECT_0.2.0 { gvir_domain_open_graphics_fd; } LIBVIRT_GOBJECT_0.1.9; +LIBVIRT_GOBJECT_0.2.1 { + global: + gvir_storage_pool_get_autostart; + gvir_storage_pool_set_autostart; +} LIBVIRT_GOBJECT_0.2.0; + # .... define new API here using predicted next version number .... -- 2.1.0

Ping! I forgot to mention, this is likely needed to fix: https://bugzilla.gnome.org/show_bug.cgi?id=748160 On Mon, May 18, 2015 at 3:11 PM, Zeeshan Ali (Khattak) <zeeshanak@gnome.org> wrote:
Add binding for virStoragePoolGetAutostart & virStoragePoolSetAutostart. --- libvirt-gobject/libvirt-gobject-storage-pool.c | 52 ++++++++++++++++++++++++++ libvirt-gobject/libvirt-gobject-storage-pool.h | 5 +++ libvirt-gobject/libvirt-gobject.sym | 6 +++ 3 files changed, 63 insertions(+)
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c index f3eac0d..e520c6a 100644 --- a/libvirt-gobject/libvirt-gobject-storage-pool.c +++ b/libvirt-gobject/libvirt-gobject-storage-pool.c @@ -1048,6 +1048,58 @@ gboolean gvir_storage_pool_delete (GVirStoragePool *pool, return TRUE; }
+/** + * gvir_storage_pool_get_autostart: + * @pool: the storage pool + * @err: return location for any #GError + * + * Return value: #True if autostart is enabled, #False otherwise. + */ +gboolean gvir_storage_pool_get_autostart(GVirStoragePool *pool, + GError **err) +{ + gboolean ret = FALSE; + + g_return_val_if_fail(GVIR_IS_STORAGE_POOL(pool), ret); + g_return_val_if_fail(err == NULL || *err == NULL, ret); + + if (virStoragePoolGetAutostart(pool->priv->handle, &ret)) { + gvir_set_error_literal(err, GVIR_STORAGE_POOL_ERROR, + 0, + "Failed to get autostart flag from storage pool"); + return FALSE; + } + + return ret; +} + +/** + * gvir_storage_pool_set_autostart: + * @pool: the storage pool + * @autostart: New value for autostart flag + * @err: return location for any #GError + * + * Sets whether or not storage pool @pool is started automatically on boot. + * + * Return value: #TRUE on success, #FALSE otherwise. + */ +gboolean gvir_storage_pool_set_autostart(GVirStoragePool *pool, + gboolean autostart, + GError **err) +{ + g_return_val_if_fail(GVIR_IS_STORAGE_POOL(pool), FALSE); + g_return_val_if_fail(err == NULL || *err == NULL, FALSE); + + if (virStoragePoolSetAutostart(pool->priv->handle, autostart)) { + gvir_set_error_literal(err, GVIR_STORAGE_POOL_ERROR, + 0, + "Failed to set autostart flag on storage pool"); + return FALSE; + } + + return TRUE; +} + static void gvir_storage_pool_delete_helper(GSimpleAsyncResult *res, GObject *object, diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.h b/libvirt-gobject/libvirt-gobject-storage-pool.h index f8529f0..f7f879c 100644 --- a/libvirt-gobject/libvirt-gobject-storage-pool.h +++ b/libvirt-gobject/libvirt-gobject-storage-pool.h @@ -166,6 +166,11 @@ void gvir_storage_pool_delete_async (GVirStoragePool *pool, gboolean gvir_storage_pool_delete_finish(GVirStoragePool *pool, GAsyncResult *result, GError **err); +gboolean gvir_storage_pool_get_autostart(GVirStoragePool *pool, + GError **err); +gboolean gvir_storage_pool_set_autostart(GVirStoragePool *pool, + gboolean autostart, + GError **err);
G_END_DECLS
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym index 927cad9..dcda675 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -265,4 +265,10 @@ LIBVIRT_GOBJECT_0.2.0 { gvir_domain_open_graphics_fd; } LIBVIRT_GOBJECT_0.1.9;
+LIBVIRT_GOBJECT_0.2.1 { + global: + gvir_storage_pool_get_autostart; + gvir_storage_pool_set_autostart; +} LIBVIRT_GOBJECT_0.2.0; + # .... define new API here using predicted next version number .... -- 2.1.0
-- Regards, Zeeshan Ali (Khattak) ________________________________________ Befriend GNOME: http://www.gnome.org/friends/

On Mon, May 18, 2015 at 03:11:07PM +0100, Zeeshan Ali (Khattak) wrote:
Add binding for virStoragePoolGetAutostart & virStoragePoolSetAutostart. --- libvirt-gobject/libvirt-gobject-storage-pool.c | 52 ++++++++++++++++++++++++++ libvirt-gobject/libvirt-gobject-storage-pool.h | 5 +++ libvirt-gobject/libvirt-gobject.sym | 6 +++ 3 files changed, 63 insertions(+)
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c index f3eac0d..e520c6a 100644 --- a/libvirt-gobject/libvirt-gobject-storage-pool.c +++ b/libvirt-gobject/libvirt-gobject-storage-pool.c @@ -1048,6 +1048,58 @@ gboolean gvir_storage_pool_delete (GVirStoragePool *pool, return TRUE; }
+/** + * gvir_storage_pool_get_autostart: + * @pool: the storage pool + * @err: return location for any #GError + * + * Return value: #True if autostart is enabled, #False otherwise. + */ +gboolean gvir_storage_pool_get_autostart(GVirStoragePool *pool, + GError **err) +{ + gboolean ret = FALSE;
I'd use 'int' instead of gboolean here as virStoragePoolGetAutostart expects a int * as its last arg
+ + g_return_val_if_fail(GVIR_IS_STORAGE_POOL(pool), ret); + g_return_val_if_fail(err == NULL || *err == NULL, ret); + + if (virStoragePoolGetAutostart(pool->priv->handle, &ret)) { + gvir_set_error_literal(err, GVIR_STORAGE_POOL_ERROR, + 0, + "Failed to get autostart flag from storage pool"); + return FALSE; + } + + return ret;
You can return !!ret here if you want to be absolutely sure that you return TRUE.
+} + +/** + * gvir_storage_pool_set_autostart: + * @pool: the storage pool + * @autostart: New value for autostart flag
for the autostart flag ? Looks good otherwise, ACK. Christophe

On Thu, May 21, 2015 at 3:12 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
On Mon, May 18, 2015 at 03:11:07PM +0100, Zeeshan Ali (Khattak) wrote:
Add binding for virStoragePoolGetAutostart & virStoragePoolSetAutostart. --- libvirt-gobject/libvirt-gobject-storage-pool.c | 52 ++++++++++++++++++++++++++ libvirt-gobject/libvirt-gobject-storage-pool.h | 5 +++ libvirt-gobject/libvirt-gobject.sym | 6 +++ 3 files changed, 63 insertions(+)
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c index f3eac0d..e520c6a 100644 --- a/libvirt-gobject/libvirt-gobject-storage-pool.c +++ b/libvirt-gobject/libvirt-gobject-storage-pool.c @@ -1048,6 +1048,58 @@ gboolean gvir_storage_pool_delete (GVirStoragePool *pool, return TRUE; }
+/** + * gvir_storage_pool_get_autostart: + * @pool: the storage pool + * @err: return location for any #GError + * + * Return value: #True if autostart is enabled, #False otherwise. + */ +gboolean gvir_storage_pool_get_autostart(GVirStoragePool *pool, + GError **err) +{ + gboolean ret = FALSE;
I'd use 'int' instead of gboolean here as virStoragePoolGetAutostart expects a int * as its last arg
+ + g_return_val_if_fail(GVIR_IS_STORAGE_POOL(pool), ret); + g_return_val_if_fail(err == NULL || *err == NULL, ret); + + if (virStoragePoolGetAutostart(pool->priv->handle, &ret)) { + gvir_set_error_literal(err, GVIR_STORAGE_POOL_ERROR, + 0, + "Failed to get autostart flag from storage pool"); + return FALSE; + } + + return ret;
You can return !!ret here if you want to be absolutely sure that you return TRUE.
+} + +/** + * gvir_storage_pool_set_autostart: + * @pool: the storage pool + * @autostart: New value for autostart flag
for the autostart flag ?
Yeah, I couldn't think of better way to put it than libvirt docs: http://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetAutost... How about "Whether or not to autostart"? -- Regards, Zeeshan Ali (Khattak) ________________________________________ Befriend GNOME: http://www.gnome.org/friends/

On Fri, May 29, 2015 at 06:49:43PM +0100, Zeeshan Ali (Khattak) wrote:
+} + +/** + * gvir_storage_pool_set_autostart: + * @pool: the storage pool + * @autostart: New value for autostart flag
for the autostart flag ?
Yeah, I couldn't think of better way to put it than libvirt docs:
http://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetAutost...
How about "Whether or not to autostart"?
Sorry, I was only suggesting to replace "for autostart flag" with "for the autostart flag". "Whether or not to autostart" is good too. Christophe
participants (2)
-
Christophe Fergeau
-
Zeeshan Ali (Khattak)