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

[libvirt] [libvirt-glib 3/4] gobject: Wrap virStoragePoolUndefine



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

diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
index c5a98f2..ac9b20f 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.c
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
@@ -734,6 +734,96 @@ gboolean gvir_storage_pool_build_finish(GVirStoragePool *pool,
 }
 
 /**
+ * gvir_storage_pool_undefine:
+ * @pool: the storage pool to undefine
+ * @err: return location for any #GError
+ *
+ * Return value: #True on success, #False otherwise.
+ */
+gboolean gvir_storage_pool_undefine (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 (virStoragePoolUndefine(pool->priv->handle)) {
+        gvir_set_error_literal(err, GVIR_STORAGE_POOL_ERROR,
+                               0,
+                               "Failed to undefine storage pool");
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
+static void
+gvir_storage_pool_undefine_helper(GSimpleAsyncResult *res,
+                                  GObject *object,
+                                  GCancellable *cancellable G_GNUC_UNUSED)
+{
+    GVirStoragePool *pool = GVIR_STORAGE_POOL(object);
+    GError *err = NULL;
+
+    if (!gvir_storage_pool_undefine(pool, &err)) {
+        g_simple_async_result_set_from_error(res, err);
+        g_error_free(err);
+    }
+}
+
+/**
+ * gvir_storage_pool_undefine_async:
+ * @pool: the storage pool to undefine
+ * @cancellable: (allow-none)(transfer none): cancellation object
+ * @callback: (scope async): completion callback
+ * @user_data: (closure): opaque data for callback
+ */
+void gvir_storage_pool_undefine_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_undefine_async);
+    g_simple_async_result_run_in_thread(res,
+                                        gvir_storage_pool_undefine_helper,
+                                        G_PRIORITY_DEFAULT,
+                                        cancellable);
+    g_object_unref(res);
+}
+
+/**
+ * gvir_storage_pool_undefine_finish:
+ * @pool: the storage pool to undefine
+ * @result: (transfer none): async method result
+ * @err: return location for any #GError
+ *
+ * Return value: #True on success, #False otherwise.
+ */
+gboolean gvir_storage_pool_undefine_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_undefine_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;
+}
+
+/**
  * gvir_storage_pool_start:
  * @pool: the storage pool to start
  * @flags:  the flags
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.h b/libvirt-gobject/libvirt-gobject-storage-pool.h
index 12c2d96..5fc9eeb 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.h
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.h
@@ -121,6 +121,16 @@ gboolean gvir_storage_pool_build_finish(GVirStoragePool *pool,
                                         GAsyncResult *result,
                                         GError **err);
 
+gboolean gvir_storage_pool_undefine (GVirStoragePool *pool,
+                                     GError **err);
+void gvir_storage_pool_undefine_async (GVirStoragePool *pool,
+                                       GCancellable *cancellable,
+                                       GAsyncReadyCallback callback,
+                                       gpointer user_data);
+gboolean gvir_storage_pool_undefine_finish(GVirStoragePool *pool,
+                                           GAsyncResult *result,
+                                           GError **err);
+
 gboolean gvir_storage_pool_start (GVirStoragePool *pool,
                                   guint flags,
                                   GError **err);
@@ -143,6 +153,7 @@ 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 9a4baee..3d394dc 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -208,6 +208,9 @@ LIBVIRT_GOBJECT_0.1.4 {
 	gvir_storage_pool_stop;
 	gvir_storage_pool_stop_async;
 	gvir_storage_pool_stop_finish;
+	gvir_storage_pool_undefine;
+	gvir_storage_pool_undefine_async;
+	gvir_storage_pool_undefine_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]