[libvirt] [libvirt-dbus] [PATCH 1/2] Introduce Domain Snapshot Interface
Ján Tomko
jtomko at redhat.com
Tue Oct 8 13:18:52 UTC 2019
On Mon, Oct 07, 2019 at 05:22:33PM +0200, Simon Kobyda wrote:
>Signed-off-by: Simon Kobyda <skobyda at redhat.com>
>---
> data/Makefile.am | 1 +
> data/org.libvirt.DomainSnapshot.xml | 7 +++
> src/Makefile.am | 2 +
> src/connect.c | 6 +++
> src/connect.h | 1 +
> src/domainsnapshot.c | 79 +++++++++++++++++++++++++++++
> src/domainsnapshot.h | 9 ++++
> src/util.c | 47 +++++++++++++++++
> src/util.h | 16 ++++++
> 9 files changed, 168 insertions(+)
> create mode 100644 data/org.libvirt.DomainSnapshot.xml
> create mode 100644 src/domainsnapshot.c
> create mode 100644 src/domainsnapshot.h
>
>diff --git a/src/util.c b/src/util.c
>index 103bb29..2be616c 100644
>--- a/src/util.c
>+++ b/src/util.c
>@@ -279,6 +279,53 @@ virtDBusUtilVirDomainListFree(virDomainPtr *domains)
> g_free(domains);
> }
>
>+virDomainSnapshotPtr
>+virtDBusUtilVirDomainSnapshotFromBusPath(virConnectPtr connection,
>+ const gchar *path,
>+ const gchar *domainSnapshotPath)
>+{
>+ g_autofree gchar *domainName = NULL;
>+ g_autofree gchar *snapshotName = NULL;
>+ g_autoptr(virDomain) domain = NULL;
>+ gsize prefixLen = strlen(domainSnapshotPath) + 1;
>+ gchar** strings = g_strsplit(path + prefixLen, "_", 2);
>+
This won't work correctly with domain names containing "_" - you will
split in the domain name instead.
Using UUIDs instead of names should give you a fixed point where to
split.
>+ domainName = virtDBusUtilDecodeStr(strings[0]);
>+ snapshotName = virtDBusUtilDecodeStr(strings[1]);
>+
>+ domain = virDomainLookupByName(connection, domainName);
>+
>+ return virDomainSnapshotLookupByName(domain, snapshotName, 0); // TODO flags for external?
>+}
>+
Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20191008/c74d628a/attachment-0001.sig>
More information about the libvir-list
mailing list