From: Timm Bäder <mail(a)baedert.org>
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 | 18 +++++++++++++
libvirt-gobject/libvirt-gobject.sym | 1 +
3 files changed, 52 insertions(+)
diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c
b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
index 69b6e5a..497288f 100644
--- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c
+++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
@@ -264,3 +264,36 @@ gboolean gvir_domain_snapshot_is_current(GVirDomainSnapshot
*snapshot,
return status;
}
+
+
+
+/**
+ * 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 bf697b3..2db0a38 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);
@@ -88,6 +101,11 @@ gboolean gvir_domain_snapshot_delete (GVirDomainSnapshot *snapshot,
gboolean gvir_domain_snapshot_is_current(GVirDomainSnapshot *snapshot,
guint flags,
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 641c4da..0ffbb3f 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -243,6 +243,7 @@ LIBVIRT_GOBJECT_0.1.9 {
gvir_domain_snapshot_delete;
gvir_domain_snapshot_list_flags_get_type;
gvir_domain_snapshot_is_current;
+ gvir_domain_snapshot_revert_to;
} LIBVIRT_GOBJECT_0.1.5;
# .... define new API here using predicted next version number ....
--
2.0.3
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list