Skip to contentSkip to conversation

Allow custom file sizes for backed files

PATCH New [email protected] 1 participant 1 message May 11, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow custom file sizes for backed files

From: Alexander Graf <[email protected]>

Currently when creating an image with a backing file enabled, the size of the file is the same as the size of the backing file.

I don't see any reason why it has to be that way. Qcow2 even contains code to handle the case where the backing file doesn't contain the data we want to read from it, so we're fine here.

This patch allows to specify a size option even when using a backing file. I tested that it works with a raw backed qcow2 file.

---
 qemu-img.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
qemu-img.c +4 -3
index 29149a2..01fa059 100644
@@ -271,9 +271,10 @@ static int img_create(int argc, char **argv)
         bdrv_get_geometry(bs, &size);
         size *= 512;
         bdrv_delete(bs);
-    } else {
-        if (optind >= argc)
-            help();
+    } else if (optind >= argc) {
+        help();
+    }
+    if (optind < argc) {
         p = argv[optind];
         sizef = strtod(p, (char **)&p);
         if (*p == 'M') {
Signature · 1 line
1.6.0.2