]> git.proxmox.com Git - qemu.git/commitdiff
Fix -snapshot deleting images on disk change
authorBlue Swirl <blauwirbel@gmail.com>
Sun, 25 Jul 2010 20:49:34 +0000 (20:49 +0000)
committerKevin Wolf <kwolf@redhat.com>
Mon, 26 Jul 2010 11:39:40 +0000 (13:39 +0200)
Block device change command did not copy BDRV_O_SNAPSHOT flag. Thus
the new image did not have this flag and the file got deleted during
opening.

Fix by copying BDRV_O_SNAPSHOT flag.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c
block.h
blockdev.c

diff --git a/block.c b/block.c
index 49e6cbcd5246760cbb898b5da74241bd792b2d3d..452ae94eeab9d63b1900a9153d0c83d07270a672 100644 (file)
--- a/block.c
+++ b/block.c
@@ -1811,6 +1811,11 @@ int bdrv_can_snapshot(BlockDriverState *bs)
     return 1;
 }
 
+int bdrv_is_snapshot(BlockDriverState *bs)
+{
+    return !!(bs->open_flags & BDRV_O_SNAPSHOT);
+}
+
 BlockDriverState *bdrv_snapshots(void)
 {
     BlockDriverState *bs;
diff --git a/block.h b/block.h
index c2a7e4c762e94815e1ef2c10d0f7f586fa678bea..db131a3438da85e38c06a7b8f0f74cd25ea39ad3 100644 (file)
--- a/block.h
+++ b/block.h
@@ -202,6 +202,7 @@ const char *bdrv_get_encrypted_filename(BlockDriverState *bs);
 void bdrv_get_backing_filename(BlockDriverState *bs,
                                char *filename, int filename_size);
 int bdrv_can_snapshot(BlockDriverState *bs);
+int bdrv_is_snapshot(BlockDriverState *bs);
 BlockDriverState *bdrv_snapshots(void);
 int bdrv_snapshot_create(BlockDriverState *bs,
                          QEMUSnapshotInfo *sn_info);
index 0a9dec364e40eef673e1f87b0e5ee2c2b5a1194a..01e402bf3d079672efb40160b4df6314756fcc51 100644 (file)
@@ -590,6 +590,7 @@ int do_change_block(Monitor *mon, const char *device,
         return -1;
     }
     bdrv_flags = bdrv_is_read_only(bs) ? 0 : BDRV_O_RDWR;
+    bdrv_flags |= bdrv_is_snapshot(bs) ? BDRV_O_SNAPSHOT : 0;
     if (bdrv_open(bs, filename, bdrv_flags, drv) < 0) {
         qerror_report(QERR_OPEN_FILE_FAILED, filename);
         return -1;