]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: checkpoint: Add a flag storing whether disk 'size' is valid
authorPeter Krempa <pkrempa@redhat.com>
Wed, 1 Jul 2020 14:58:29 +0000 (16:58 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 7 Jul 2020 10:58:19 +0000 (12:58 +0200)
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>
src/conf/checkpoint_conf.c
src/conf/checkpoint_conf.h
tests/qemudomaincheckpointxml2xmltest.c

index d557fada490465eb1333531bb92ffed5c35776e2..3405e8a3ccff9735c5793133d24c9caa4ec3eb69 100644 (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");
index ee5d210593f809b3c0ca07f6c04e42d55a1c577e..f115b98c2bb7405977b7bb7b9a2264e505746060 100644 (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 */
index b73ac74e815ad38c9c7387d3e07f959418c5cb66..a5a5b5920537b3c2ec6c24ab68716f778b207850 100644 (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;
     }