From: Timm Bäder <mail@xxxxxxxxxxx> Add a way to determine if the given GVirDomainSnapshot is the current snapshot of its GVirDomain. --- libvirt-gobject/libvirt-gobject-domain-snapshot.c | 29 +++++++++++++++++++++++ libvirt-gobject/libvirt-gobject-domain-snapshot.h | 3 +++ libvirt-gobject/libvirt-gobject.sym | 1 + 3 files changed, 33 insertions(+) diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c b/libvirt-gobject/libvirt-gobject-domain-snapshot.c index 7bb89f1..69b6e5a 100644 --- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c +++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c @@ -235,3 +235,32 @@ gboolean gvir_domain_snapshot_delete (GVirDomainSnapshot *snapshot, } return TRUE; } + + +/** + * gvir_domain_snapshot_is_current: + * @snapshot: The domain snapshot + * @flags: Currently unused, pass 0 + * @error: (allow-none): Place-holder for error or NULL + * + * Returns: TRUE if the given snapshot is the current snapshot + * of its domain or FALSE if it is not or an error occurs. + */ +gboolean gvir_domain_snapshot_is_current(GVirDomainSnapshot *snapshot, + guint flags, + GError **error) { + gint status; + + g_return_val_if_fail(GVIR_IS_DOMAIN_SNAPSHOT(snapshot), FALSE); + g_return_val_if_fail(error == NULL || *error == NULL, FALSE); + + status = virDomainSnapshotIsCurrent(snapshot->priv->handle, flags); + if (status == -1) { + gvir_set_error(error, GVIR_DOMAIN_SNAPSHOT_ERROR, 0, + "Could not determine if `%s' is the current snapshot", + gvir_domain_snapshot_get_name(snapshot)); + return FALSE; + } + + return status; +} diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.h b/libvirt-gobject/libvirt-gobject-domain-snapshot.h index b3ebe7f..bf697b3 100644 --- a/libvirt-gobject/libvirt-gobject-domain-snapshot.h +++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.h @@ -85,6 +85,9 @@ gboolean gvir_domain_snapshot_delete (GVirDomainSnapshot *snapshot, guint flags, GError **error); +gboolean gvir_domain_snapshot_is_current(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 6aa8b86..641c4da 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -242,6 +242,7 @@ LIBVIRT_GOBJECT_0.1.9 { gvir_domain_get_snapshots; gvir_domain_snapshot_delete; gvir_domain_snapshot_list_flags_get_type; + gvir_domain_snapshot_is_current; } LIBVIRT_GOBJECT_0.1.5; # .... define new API here using predicted next version number .... -- 2.0.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list