[libvirt-glib] [PATCH v2] GVirDomainSnapshot: Add gvir_domain_snapshot_delete

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

 



---

Whoops, totally forgot about the delete flags in the first version,
sorry.

As for the underline in domain_snapshot, I took that from
gvir_domain_snapshot_get_config so I don't really know what's the
correct version.

Since this is using gvir_domain_snapshot_get_name now, the patch
removing the #if 0's in libvirt-gobject-domain-snapshot.c is needed.

 libvirt-gobject/libvirt-gobject-domain-snapshot.c | 25 +++++++++++++++++++++++
 libvirt-gobject/libvirt-gobject-domain-snapshot.h | 16 +++++++++++++++
 libvirt-gobject/libvirt-gobject.sym               |  6 ++++++
 3 files changed, 47 insertions(+)

diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
index fcf70ed..aa0504d 100644
--- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c
+++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
@@ -205,3 +205,28 @@ GVirConfigDomainSnapshot *gvir_domain_snapshot_get_config
     free(xml);
     return conf;
 }
+
+/**
+ * gvir_domain_snapshot_delete:
+ * @snapshot: the domain snapshot
+ * @flags: Bitwise or of #GVirDomainSnapshotDeleteFlags
+ * @error: (allow-none): Place-holder for error or NULL
+ */
+void gvir_domain_snapshot_delete (GVirDomainSnapshot *snapshot,
+                                  GVirDomainSnapshotDeleteFlags flags,
+                                  GError **error)
+{
+    GVirDomainSnapshotPrivate *priv;
+    int status;
+
+    g_return_if_fail(GVIR_IS_DOMAIN_SNAPSHOT (snapshot));
+    g_return_if_fail(error == NULL || *error == NULL);
+
+    priv = snapshot->priv;
+    status = virDomainSnapshotDelete(priv->handle, flags);
+    if (status < 0) {
+        gvir_set_error(error, GVIR_DOMAIN_SNAPSHOT_ERROR, 0,
+                       "Unable to delete snapshot `%s'",
+                      gvir_domain_snapshot_get_name(snapshot));
+    }
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.h b/libvirt-gobject/libvirt-gobject-domain-snapshot.h
index 5bd827c..3985795 100644
--- a/libvirt-gobject/libvirt-gobject-domain-snapshot.h
+++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.h
@@ -58,6 +58,18 @@ struct _GVirDomainSnapshotClass
     gpointer padding[20];
 };
 
+/**
+ * GVirDomainSnapshotDeleteFlags:
+ * @GVIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN: Also delete children
+ * @GVIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY: Delete just metadata
+ * @GVIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY: Delete just children
+ */
+typedef enum {
+  GVIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN = 1,
+  GVIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY = 2,
+  GVIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY = 4
+} GVirDomainSnapshotDeleteFlags;
+
 
 GType gvir_domain_snapshot_get_type(void);
 GType gvir_domain_snapshot_handle_get_type(void);
@@ -69,6 +81,10 @@ GVirConfigDomainSnapshot *gvir_domain_snapshot_get_config
                                  guint flags,
                                  GError **err);
 
+void gvir_domain_snapshot_delete (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 f2419ac..232e63b 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -234,4 +234,10 @@ LIBVIRT_GOBJECT_0.1.5 {
 	gvir_connection_open_read_only_finish;
 } LIBVIRT_GOBJECT_0.1.4;
 
+LIBVIRT_GOBJECT_0.1.9 {
+  global:
+  gvir_domain_snapshot_delete_flags_get_type;
+  gvir_domain_snapshot_delete;
+} LIBVIRT_GOBJECT_0.1.5;
+
 # .... define new API here using predicted next version number ....
-- 
1.9.3

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