mirror of https://gitee.com/openkylin/libvirt.git
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:
parent
459a60823e
commit
a94997c476
|
@ -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");
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue