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

[libvirt] [libvirt-glib 2/4] gobject: Wrap virStoragePoolDestroy



---
 libvirt-gobject/libvirt-gobject-storage-pool.c | 90 ++++++++++++++++++++++++++
 libvirt-gobject/libvirt-gobject-storage-pool.h | 10 +++
 libvirt-gobject/libvirt-gobject.sym            |  6 ++
 3 files changed, 106 insertions(+)

diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
index a4316e9..c5a98f2 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.c
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
@@ -837,3 +837,93 @@ gboolean gvir_storage_pool_start_finish(GVirStoragePool *pool,
 
     return TRUE;
 }
+
+/**
+ * gvir_storage_pool_stop:
+ * @pool: the storage pool to stop
+ * @err: return location for any #GError
+ *
+ * Return value: #True on success, #False otherwise.
+ */
+gboolean gvir_storage_pool_stop (GVirStoragePool *pool,
+                                 GError **err)
+{
+    g_return_val_if_fail(GVIR_IS_STORAGE_POOL(pool), FALSE);
+    g_return_val_if_fail(err == NULL || *err == NULL, FALSE);
+
+    if (virStoragePoolDestroy(pool->priv->handle)) {
+        gvir_set_error_literal(err, GVIR_STORAGE_POOL_ERROR,
+                               0,
+                               "Failed to stop storage pool");
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
+static void
+gvir_storage_pool_stop_helper(GSimpleAsyncResult *res,
+                              GObject *object,
+                              GCancellable *cancellable G_GNUC_UNUSED)
+{
+    GVirStoragePool *pool = GVIR_STORAGE_POOL(object);
+    GError *err = NULL;
+
+    if (!gvir_storage_pool_stop(pool, &err)) {
+        g_simple_async_result_set_from_error(res, err);
+        g_error_free(err);
+    }
+}
+
+/**
+ * gvir_storage_pool_stop_async:
+ * @pool: the storage pool to stop
+ * @cancellable: (allow-none)(transfer none): cancellation object
+ * @callback: (scope async): completion callback
+ * @user_data: (closure): opaque data for callback
+ */
+void gvir_storage_pool_stop_async (GVirStoragePool *pool,
+                                   GCancellable *cancellable,
+                                   GAsyncReadyCallback callback,
+                                   gpointer user_data)
+{
+    GSimpleAsyncResult *res;
+
+    g_return_if_fail(GVIR_IS_STORAGE_POOL(pool));
+    g_return_if_fail((cancellable == NULL) || G_IS_CANCELLABLE(cancellable));
+
+    res = g_simple_async_result_new(G_OBJECT(pool),
+                                    callback,
+                                    user_data,
+                                    gvir_storage_pool_stop_async);
+    g_simple_async_result_run_in_thread(res,
+                                        gvir_storage_pool_stop_helper,
+                                        G_PRIORITY_DEFAULT,
+                                        cancellable);
+    g_object_unref(res);
+}
+
+/**
+ * gvir_storage_pool_stop_finish:
+ * @pool: the storage pool to stop
+ * @result: (transfer none): async method result
+ * @err: return location for any #GError
+ *
+ * Return value: #True on success, #False otherwise.
+ */
+gboolean gvir_storage_pool_stop_finish(GVirStoragePool *pool,
+                                       GAsyncResult *result,
+                                       GError **err)
+{
+    g_return_val_if_fail(GVIR_IS_STORAGE_POOL(pool), FALSE);
+    g_return_val_if_fail(g_simple_async_result_is_valid(result, G_OBJECT(pool),
+                                                        gvir_storage_pool_stop_async),
+                         FALSE);
+    g_return_val_if_fail(err == NULL || *err == NULL, FALSE);
+
+    if (g_simple_async_result_propagate_error(G_SIMPLE_ASYNC_RESULT(result),
+                                              err))
+        return FALSE;
+
+    return TRUE;
+}
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.h b/libvirt-gobject/libvirt-gobject-storage-pool.h
index 4589844..12c2d96 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.h
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.h
@@ -133,6 +133,16 @@ gboolean gvir_storage_pool_start_finish(GVirStoragePool *pool,
                                         GAsyncResult *result,
                                         GError **err);
 
+gboolean gvir_storage_pool_stop (GVirStoragePool *pool,
+                                 GError **err);
+void gvir_storage_pool_stop_async (GVirStoragePool *pool,
+                                   GCancellable *cancellable,
+                                   GAsyncReadyCallback callback,
+                                   gpointer user_data);
+gboolean gvir_storage_pool_stop_finish(GVirStoragePool *pool,
+                                       GAsyncResult *result,
+                                       GError **err);
+
 G_END_DECLS
 
 #endif /* __LIBVIRT_GOBJECT_STORAGE_POOL_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index 3a40a8a..9a4baee 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -204,4 +204,10 @@ LIBVIRT_GOBJECT_0.1.3 {
     gvir_domain_wakeup_finish;
 } LIBVIRT_GOBJECT_0.1.2;
 
+LIBVIRT_GOBJECT_0.1.4 {
+	gvir_storage_pool_stop;
+	gvir_storage_pool_stop_async;
+	gvir_storage_pool_stop_finish;
+} LIBVIRT_GOBJECT_0.1.3;
+
 # .... define new API here using predicted next version number ....
-- 
1.7.12.1


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