Avoid printing '0' size in case when we weren't able to determine the
backup size by adding a flag whether the size is valid and interlock
printing of the field according to the flag.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/conf/checkpoint_conf.c | 2 +-
src/conf/checkpoint_conf.h | 1 +
tests/qemudomaincheckpointxml2xmltest.c | 1 +
3 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c
index d557fada49..3405e8a3cc 100644
--- a/src/conf/checkpoint_conf.c
+++ b/src/conf/checkpoint_conf.c
@@ -430,7 +430,7 @@ virDomainCheckpointDiskDefFormat(virBufferPtr buf,
virDomainCheckpointTypeToString(disk->type));
if (disk->bitmap) {
virBufferEscapeString(buf, " bitmap='%s'", disk->bitmap);
- if (flags & VIR_DOMAIN_CHECKPOINT_FORMAT_SIZE)
+ if (flags & VIR_DOMAIN_CHECKPOINT_FORMAT_SIZE && disk->sizeValid)
virBufferAsprintf(buf, " size='%llu'", disk->size);
}
virBufferAddLit(buf, "/>\n");
diff --git a/src/conf/checkpoint_conf.h b/src/conf/checkpoint_conf.h
index ee5d210593..f115b98c2b 100644
--- a/src/conf/checkpoint_conf.h
+++ b/src/conf/checkpoint_conf.h
@@ -46,6 +46,7 @@ struct _virDomainCheckpointDiskDef {
int type; /* virDomainCheckpointType */
char *bitmap; /* bitmap name, if type is bitmap */
unsigned long long size; /* current checkpoint size in bytes */
+ bool sizeValid;
};
/* Stores the complete checkpoint metadata */
diff --git a/tests/qemudomaincheckpointxml2xmltest.c
b/tests/qemudomaincheckpointxml2xmltest.c
index b73ac74e81..a5a5b59205 100644
--- a/tests/qemudomaincheckpointxml2xmltest.c
+++ b/tests/qemudomaincheckpointxml2xmltest.c
@@ -83,6 +83,7 @@ testCompareXMLToXMLFiles(const char *inxml,
}
if (flags & TEST_SIZE) {
def->disks[0].size = 1048576;
+ def->disks[0].sizeValid = true;
formatflags |= VIR_DOMAIN_CHECKPOINT_FORMAT_SIZE;
}
--
2.26.2