]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: block: Use correct type when creating image size JSON entries
authorPeter Krempa <pkrempa@redhat.com>
Fri, 30 Aug 2019 14:33:48 +0000 (16:33 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 4 Sep 2019 07:13:49 +0000 (09:13 +0200)
The 'u' modifier creates an unsigned int JSON attribute but the disk size
and capacity fields are unsigned long long. If the size of the created
image would be more than 4GiB we'd overflow and create sub-4G image.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_block.c

index 66b1d116d81a1dad13fd28ac8a3bc0b56d8f4575..e33aad4458ef43160475b29bf62e0d1c61f8c759 100644 (file)
@@ -2034,7 +2034,7 @@ qemuBlockStorageSourceCreateGetFormatPropsGeneric(virStorageSourcePtr src,
     if (virJSONValueObjectCreate(&props,
                                  "s:driver", driver,
                                  "s:file", src->nodestorage,
-                                 "u:size", src->capacity,
+                                 "U:size", src->capacity,
                                  NULL) < 0)
         return -1;
 
@@ -2100,7 +2100,7 @@ qemuBlockStorageSourceCreateGetFormatPropsLUKS(virStorageSourcePtr src,
     if (virJSONValueObjectAdd(luksprops,
                               "s:driver", "luks",
                               "s:file", src->nodestorage,
-                              "u:size", src->capacity,
+                              "U:size", src->capacity,
                               NULL) < 0)
         return -1;
 
@@ -2153,7 +2153,7 @@ qemuBlockStorageSourceCreateGetFormatPropsQcow2(virStorageSourcePtr src,
     if (virJSONValueObjectCreate(&qcow2props,
                                  "s:driver", "qcow2",
                                  "s:file", src->nodestorage,
-                                 "u:size", src->capacity,
+                                 "U:size", src->capacity,
                                  "S:version", qcow2version,
                                  NULL) < 0)
         return -1;
@@ -2177,7 +2177,7 @@ qemuBlockStorageSourceCreateGetFormatPropsQcow(virStorageSourcePtr src,
     if (virJSONValueObjectCreate(&qcowprops,
                                  "s:driver", "qcow",
                                  "s:file", src->nodestorage,
-                                 "u:size", src->capacity,
+                                 "U:size", src->capacity,
                                  NULL) < 0)
         return -1;
 
@@ -2200,7 +2200,7 @@ qemuBlockStorageSourceCreateGetFormatPropsQed(virStorageSourcePtr src,
     if (virJSONValueObjectCreate(&qedprops,
                                  "s:driver", "qed",
                                  "s:file", src->nodestorage,
-                                 "u:size", src->capacity,
+                                 "U:size", src->capacity,
                                  NULL) < 0)
         return -1;
 
@@ -2373,7 +2373,7 @@ qemuBlockStorageSourceCreateGetStorageProps(virStorageSourcePtr src,
                                  "s:driver", driver,
                                  "S:filename", filename,
                                  "A:location", &location,
-                                 "u:size", src->physical,
+                                 "U:size", src->physical,
                                  NULL) < 0)
         return -1;