From: Timm Bäder <mail@xxxxxxxxxxx> ... which is basically analogous to gvir_domain_set_config --- libvirt-gobject/libvirt-gobject-domain-snapshot.c | 58 +++++++++++++++++++++++ libvirt-gobject/libvirt-gobject-domain-snapshot.h | 5 ++ libvirt-gobject/libvirt-gobject.sym | 1 + 3 files changed, 64 insertions(+) diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c b/libvirt-gobject/libvirt-gobject-domain-snapshot.c index 497288f..2c81882 100644 --- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c +++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c @@ -297,3 +297,61 @@ gboolean gvir_domain_snapshot_revert_to(GVirDomainSnapshot *snapshot, return TRUE; } + + + +/** + * gvir_domain_snapshot_set_config: + * @snapshot: The domain snapshot + * @conf: The new config object + * @error: (allow-none): Place-holder for error or NULL + * + * Updates the given snapshot's configuration according to the + * given GVirConfigDomainSnapshot. + * + * Returns: TRUE if no error was reported, FALSE otherwise. + */ +gboolean gvir_domain_snapshot_set_config(GVirDomainSnapshot *snapshot, + GVirConfigDomainSnapshot *conf, + GError **error) +{ + gchar *xml; + virConnectPtr conn; + virDomainSnapshotPtr handle; + virDomainPtr domain; + GVirDomainSnapshotPrivate *priv; + + g_return_val_if_fail(GVIR_IS_DOMAIN_SNAPSHOT(snapshot), FALSE); + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_SNAPSHOT(conf), FALSE); + g_return_val_if_fail(error == NULL || *error == NULL, FALSE); + + priv = snapshot->priv; + handle = priv->handle; + domain = virDomainSnapshotGetDomain(handle); + + + if ((conn = virDomainSnapshotGetConnect(priv->handle)) == NULL) { + gvir_set_error_literal(error, GVIR_DOMAIN_SNAPSHOT_ERROR, + 0, + "Failed to get domain connection"); + return FALSE; + } + + + xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(conf)); + + handle = virDomainSnapshotCreateXML(domain, + xml, + VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE); + free(xml); + + if (handle == NULL) { + gvir_set_error(error, GVIR_DOMAIN_SNAPSHOT_ERROR, + 0, + "Failed to create Snapshot `%s' from XML definition", + gvir_domain_snapshot_get_name(snapshot)); + return FALSE; + } + virDomainSnapshotFree(handle); + return TRUE; +} diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.h b/libvirt-gobject/libvirt-gobject-domain-snapshot.h index 2db0a38..1af65bb 100644 --- a/libvirt-gobject/libvirt-gobject-domain-snapshot.h +++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.h @@ -106,6 +106,11 @@ gboolean gvir_domain_snapshot_is_current(GVirDomainSnapshot *snapshot, gboolean gvir_domain_snapshot_revert_to(GVirDomainSnapshot *snapshot, guint flags, GError **error); + +gboolean gvir_domain_snapshot_set_config(GVirDomainSnapshot *snapshot, + GVirConfigDomainSnapshot *conf, + 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 0ffbb3f..4ca4175 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -244,6 +244,7 @@ LIBVIRT_GOBJECT_0.1.9 { gvir_domain_snapshot_list_flags_get_type; gvir_domain_snapshot_is_current; gvir_domain_snapshot_revert_to; + gvir_domain_snapshot_set_config; } 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