[libvirt-glib] [PATCH v2 2/4] GVirDomainSnapshot: Add _revert_to

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

 



Add a way to revert a domain to one of its snapshots.
---
 libvirt-gobject/libvirt-gobject-domain-snapshot.c | 33 +++++++++++++++++++++++
 libvirt-gobject/libvirt-gobject-domain-snapshot.h | 17 ++++++++++++
 libvirt-gobject/libvirt-gobject.sym               |  2 ++
 3 files changed, 52 insertions(+)

diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
index c53e877..dca1086 100644
--- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c
+++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
@@ -268,3 +268,36 @@ gboolean gvir_domain_snapshot_get_is_current(GVirDomainSnapshot *snapshot,
 
     return TRUE;
 }
+
+
+
+/**
+ * gvir_domain_snapshot_revert_to:
+ * @snapshot: The domain snapshot
+ * @flags: Bitwise OR of GVirDomainSnapshotRevertFlags
+ * @error: (allow-none): Place-holder for error or %NULL
+ *
+ * Returns: %TRUE if the snapshot's domain has successfully been
+ * reverted to the given snapshot, %FALSE otherwise, in which case
+ * @error will be set.
+ */
+gboolean gvir_domain_snapshot_revert_to(GVirDomainSnapshot *snapshot,
+                                        guint flags,
+                                        GError **error) {
+    int status;
+
+    g_return_val_if_fail(GVIR_IS_DOMAIN_SNAPSHOT(snapshot), FALSE);
+    g_return_val_if_fail((error == NULL) || (*error == NULL), FALSE);
+
+
+    status = virDomainRevertToSnapshot(snapshot->priv->handle,
+                                       flags);
+    if (status != 0) {
+        gvir_set_error(error, GVIR_DOMAIN_SNAPSHOT_ERROR,
+                       0, "Failed to revert to snapshot `%s'",
+                       gvir_domain_snapshot_get_name(snapshot));
+        return FALSE;
+    }
+
+    return TRUE;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.h b/libvirt-gobject/libvirt-gobject-domain-snapshot.h
index 0a0bb96..7abe8ca 100644
--- a/libvirt-gobject/libvirt-gobject-domain-snapshot.h
+++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.h
@@ -71,6 +71,19 @@ typedef enum {
 } GVirDomainSnapshotDeleteFlags;
 
 
+/**
+ * GVirDomainSnapshotRevertFlags:
+ * @GVIR_DOMAIN_SNAPSHOT_REVERT_RUNNING: Run after revert
+ * @GVIR_DOMAIN_SNAPSHOT_REVERT_PAUSED: Pause after revert
+ * @GVIR_DOMAIN_SNAPSHOT_REVERT_FORCE: Allow risky reverts
+ */
+typedef enum {
+  GVIR_DOMAIN_SNAPSHOT_REVERT_RUNNING = 1,
+  GVIR_DOMAIN_SNAPSHOT_REVERT_PAUSED = 2,
+  GVIR_DOMAIN_SNAPSHOT_REVERT_FORCE = 4
+} GVirDomainSnapshotRevertFlags;
+
+
 GType gvir_domain_snapshot_get_type(void);
 GType gvir_domain_snapshot_handle_get_type(void);
 
@@ -89,6 +102,10 @@ gboolean gvir_domain_snapshot_get_is_current(GVirDomainSnapshot *snapshot,
                                              guint flags,
                                              gboolean *is_current,
                                              GError **error);
+
+gboolean gvir_domain_snapshot_revert_to(GVirDomainSnapshot *snapshot,
+                                        guint flags,
+                                        GError **error);
 G_END_DECLS
 
 #endif /* __LIBVIRT_GOBJECT_DOMAIN_SNAPSHOT_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index c740f88..c1c9421 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -244,6 +244,8 @@ LIBVIRT_GOBJECT_0.1.9 {
 	gvir_domain_snapshot_delete_flags_get_type;
 	gvir_domain_snapshot_get_is_current;
 	gvir_domain_snapshot_list_flags_get_type;
+	gvir_domain_snapshot_revert_flags_get_type;
+	gvir_domain_snapshot_revert_to;
 	gvir_storage_pool_state_get_type;
 	gvir_storage_vol_resize_flags_get_type;
 	gvir_storage_vol_type_get_type;
-- 
2.0.4

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