Make it possible to grab all snapshot XMLs via a single API
call, by adding a new internal flag, and expanding the struct
used to pass extra data for formatting.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/conf/domain_conf.h | 3 +++
src/conf/domain_conf.c | 23 ++++++++++++++++++++---
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 5086bc342a..34c0b8cea1 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3120,6 +3120,7 @@ typedef enum {
VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM = 1 << 6,
VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT = 1 << 7,
VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST = 1 << 8,
+ VIR_DOMAIN_DEF_FORMAT_SNAPSHOTS = 1 << 9,
} virDomainDefFormatFlags;
/* Use these flags to skip specific domain ABI consistency checks done
@@ -3198,6 +3199,8 @@ unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags);
* domains, according to the flags in use. */
typedef struct _virDomainDefFormatData {
virCapsPtr caps;
+ virDomainSnapshotObjListPtr snapshots;
+ virDomainSnapshotObjPtr current_snapshot;
} virDomainDefFormatData;
typedef struct _virDomainDefFormatData *virDomainDefFormatDataPtr;
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 941d582dc1..f383f00b8b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1,7 +1,7 @@
/*
* domain_conf.c: domain XML processing
*
- * Copyright (C) 2006-2016 Red Hat, Inc.
+ * Copyright (C) 2006-2019 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange
* Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
*
@@ -27848,7 +27848,8 @@ virDomainDefFormatInternal(virBufferPtr buf,
VIR_DOMAIN_DEF_FORMAT_STATUS |
VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET |
VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES |
- VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST,
+ VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST |
+ VIR_DOMAIN_DEF_FORMAT_SNAPSHOTS,
-1);
if (!(type = virDomainVirtTypeToString(def->virtType))) {
@@ -28643,6 +28644,21 @@ virDomainDefFormatInternal(virBufferPtr buf,
virDomainSEVDefFormat(buf, def->sev);
+ if (flags & VIR_DOMAIN_DEF_FORMAT_SNAPSHOTS) {
+ unsigned int snapflags = flags & VIR_DOMAIN_DEF_FORMAT_SECURE ?
+ VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE : 0;
+
+ if (!(data && data->snapshots)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("snapshots requested but not provided"));
+ goto error;
+ }
+ if (virDomainSnapshotObjListFormat(buf, uuidstr, data->snapshots,
+ data->current_snapshot, caps,
+ xmlopt, snapflags) < 0)
+ goto error;
+ }
+
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</domain>\n");
@@ -28698,7 +28714,8 @@ virDomainDefFormatFull(virDomainDefPtr def,
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
- virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS, NULL);
+ virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS |
+ VIR_DOMAIN_DEF_FORMAT_SNAPSHOTS, NULL);
if (virDomainDefFormatInternal(&buf, def, data, flags, NULL) < 0)
return NULL;
--
2.20.1