On Mon, Oct 07, 2019 at 05:22:33PM +0200, Simon Kobyda wrote:
Signed-off-by: Simon Kobyda <skobyda@xxxxxxxxxx> --- 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
Attachment:
signature.asc
Description: PGP signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list