Skip to contentSkip to conversation

qemu-img: allow rebase to a NULL backing file when unsafe

PATCH Applied Stefan Hajnoczi 2 participants 2 messages Apr 13, 2011 – Apr 14, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-img: allow rebase to a NULL backing file when unsafe

From: Anthony Liguori <[email protected]>

QEMU can drop a backing file so that an image file no longer depends on the backing file, but this feature has not been exposed in qemu-img. This is useful in an image streaming usecase or when an image file has been fully allocated and no reads can hit the backing file anymore.

Since the dropping the backing file can make the image unusable, only allow this when the unsafe flag has been set.

---
 qemu-img.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
qemu-img.c +1 -1
index d9c2c12..ed5ba91 100644
@@ -1240,7 +1240,7 @@ static int img_rebase(int argc, char **argv)
         }
     }
 
-    if ((optind >= argc) || !out_baseimg) {
+    if ((optind >= argc) || (!unsafe && !out_baseimg)) {
         help();
     }
     filename = argv[optind++];
Signature · 1 line
1.7.4.1
Applied
#1 lore raw

Am 13.04.2011 16:51, schrieb Stefan Hajnoczi:

Quoted 9 lines

From: Anthony Liguori <[email protected]>

QEMU can drop a backing file so that an image file no longer depends on the backing file, but this feature has not been exposed in qemu-img. This is useful in an image streaming usecase or when an image file has been fully allocated and no reads can hit the backing file anymore.

Since the dropping the backing file can make the image unusable, only allow this when the unsafe flag has been set.

I think it would also make sense to allow it in safe mode, it would have the same effect as rebasing onto an empty new backing file. Might take more than a one-liner, though.

In case you need a workaround for older qemu-img versions, -b "" works, too (at least for qcow2).

Quoted 11 lines
---
 qemu-img.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
qemu-img.c +0 -0
index d9c2c12..ed5ba91 100644

qemu-img.c static int img_rebase(int argc, char **argv) · line 1246

Quoted 8 lines
qemu-img.c +1 -1
@@ -1240,7 +1240,7 @@ static int img_rebase(int argc, char **argv)
         }
     }
 
-    if ((optind >= argc) || !out_baseimg) {
+    if ((optind >= argc) || (!unsafe && !out_baseimg)) {
         help();
     }
     filename = argv[optind++];

Thanks, applied to the block branch.

Kevin