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

[libvirt] [libvirt-glib] [PATCH v2 4/4] GVirDomain: Add _has_current_snapshot



... which uses virDomainHasCurrentSnapshot to determine if the given
domain has a current snapshot or not.
---
 libvirt-gobject/libvirt-gobject-domain.c | 34 ++++++++++++++++++++++++++++++++
 libvirt-gobject/libvirt-gobject-domain.h |  4 ++++
 libvirt-gobject/libvirt-gobject.sym      |  1 +
 3 files changed, 39 insertions(+)

diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index 5399892..f3794cc 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -1686,3 +1686,37 @@ gboolean gvir_domain_fetch_snapshots_finish(GVirDomain *dom,
 
     return g_task_propagate_boolean(G_TASK(res), error);
 }
+
+
+/**
+ * gvir_domain_has_current_snapshot:
+ * @dom: a #GVirDomain
+ * @flags: Unused, pass 0
+ * @has_current_snapshot: (out): Will be set to %TRUE if the given domain
+ * has a current snapshot and to %FALSE otherwise.
+ * @error: (allow-none): Place-holder for error or %NULL
+ *
+ * Returns: %TRUE on success, %FALSE otherwise.
+ */
+gboolean gvir_domain_has_current_snapshot(GVirDomain *dom,
+                                          guint flags,
+                                          gboolean *has_current_snapshot,
+                                          GError **error) {
+    int status;
+    g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE);
+    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
+
+    status = virDomainHasCurrentSnapshot(dom->priv->handle,
+                                         flags);
+
+    if (status == -1) {
+        gvir_set_error(error, GVIR_DOMAIN_ERROR, 0,
+                       "Unable to check if domain `%s' has a current snapshot",
+                       gvir_domain_get_name(dom));
+        return FALSE;
+    }
+
+    *has_current_snapshot = status;
+
+    return TRUE;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h
index 9846375..52b805f 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -380,6 +380,10 @@ gboolean gvir_domain_fetch_snapshots_finish(GVirDomain *dom,
                                             GAsyncResult *res,
                                             GError **error);
 
+gboolean gvir_domain_has_current_snapshot(GVirDomain *dom,
+                                          guint flags,
+                                          gboolean *has_current_snapshot,
+                                          GError **error);
 
 G_END_DECLS
 
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index bd12239..c34bf02 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -240,6 +240,7 @@ LIBVIRT_GOBJECT_0.1.9 {
 	gvir_domain_fetch_snapshots_async;
 	gvir_domain_fetch_snapshots_finish;
 	gvir_domain_get_snapshots;
+	gvir_domain_has_current_snapshot;
 	gvir_domain_snapshot_delete;
 	gvir_domain_snapshot_delete_flags_get_type;
 	gvir_domain_snapshot_get_is_current;
-- 
2.0.4


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