[PATCH v2 04/11] snapshot: Add virDomainSnapshotObjListFormat

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

 



Add a new function to output all of the domain's snapshots in one
buffer.

Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>
---
 src/conf/snapshot_conf.h |  8 +++++++-
 src/conf/snapshot_conf.c | 39 +++++++++++++++++++++++++++++++++++++++
 src/libvirt_private.syms |  1 +
 3 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h
index 4d6e6134a3..19ab75f895 100644
--- a/src/conf/snapshot_conf.h
+++ b/src/conf/snapshot_conf.h
@@ -1,7 +1,7 @@
 /*
  * snapshot_conf.h: domain snapshot XML processing
  *
- * Copyright (C) 2006-2014 Red Hat, Inc.
+ * Copyright (C) 2006-2019 Red Hat, Inc.
  * Copyright (C) 2006-2008 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -123,6 +123,12 @@ char *virDomainSnapshotDefFormat(const char *uuidstr,
                                  virCapsPtr caps,
                                  virDomainXMLOptionPtr xmlopt,
                                  unsigned int flags);
+int virDomainSnapshotObjListFormat(virBufferPtr buf,
+                                   const char *uuidstr,
+                                   virDomainSnapshotObjListPtr snapshots,
+                                   virCapsPtr caps,
+                                   virDomainXMLOptionPtr xmlopt,
+                                   unsigned int flags);
 int virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr snapshot,
                                 int default_snapshot,
                                 bool require_match);
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 5cb977336a..a572da5b58 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -803,6 +803,45 @@ virDomainSnapshotDefFormat(const char *uuidstr,
     return virBufferContentAndReset(&buf);
 }

+struct virDomainSnapshotFormatData {
+    virBufferPtr buf;
+    const char *uuidstr;
+    virCapsPtr caps;
+    virDomainXMLOptionPtr xmlopt;
+    unsigned int flags;
+};
+
+static int
+virDomainSnapshotFormatOne(void *payload, const void *name ATTRIBUTE_UNUSED,
+                           void *opaque)
+{
+    virDomainSnapshotObjPtr snap = payload;
+    struct virDomainSnapshotFormatData *data = opaque;
+    return virDomainSnapshotDefFormatInternal(data->buf, data->uuidstr,
+                                              snap->def, data->caps,
+                                              data->xmlopt, data->flags);
+}
+
+
+int
+virDomainSnapshotObjListFormat(virBufferPtr buf,
+                               const char *uuidstr,
+                               virDomainSnapshotObjListPtr snapshots,
+                               virCapsPtr caps,
+                               virDomainXMLOptionPtr xmlopt,
+                               unsigned int flags)
+{
+    struct virDomainSnapshotFormatData data = {
+        .buf = buf,
+        .uuidstr = uuidstr,
+        .caps = caps,
+        .xmlopt = xmlopt,
+        .flags = flags,
+    };
+    return virDomainSnapshotForEach(snapshots, virDomainSnapshotFormatOne,
+                                    &data);
+}
+
 /* Snapshot Obj functions */
 static virDomainSnapshotObjPtr virDomainSnapshotObjNew(void)
 {
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 6bfb497648..c623737c30 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -891,6 +891,7 @@ virDomainSnapshotFormatConvertXMLFlags;
 virDomainSnapshotIsExternal;
 virDomainSnapshotLocationTypeFromString;
 virDomainSnapshotLocationTypeToString;
+virDomainSnapshotObjListFormat;
 virDomainSnapshotObjListFree;
 virDomainSnapshotObjListGetNames;
 virDomainSnapshotObjListNew;
-- 
2.20.1

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

  Powered by Linux