conf: checkpoint: Add a flag storing whether disk 'size' is valid

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@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Peter Krempa 2020-07-01 16:58:29 +02:00
parent 459a60823e
commit a94997c476
3 changed files with 3 additions and 1 deletions

View File

@ -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");

View File

@ -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 */

View File

@ -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;
}