From 76a4a8cfb6a294d68ab25eb371023b0193630aff Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Mon, 15 Nov 2010 18:10:35 -0200 Subject: [RHEL6 qemu-kvm PATCH] Fix -snapshot deleting images on disk change RH-Author: Kevin Wolf Message-id: <1289844635-3481-1-git-send-email-kwolf@redhat.com> Patchwork-id: 13570 O-Subject: [RHEL-6.1 qemu-kvm PATCH] Fix -snapshot deleting images on disk change Bugzilla: 653582 RH-Acked-by: Jes Sorensen RH-Acked-by: Paolo Bonzini RH-Acked-by: Christoph Hellwig Bugzilla: 653582 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 Signed-off-by: Kevin Wolf (cherry picked from commit 199630b62ec7cc5efd6f860ff545b449c7b5cdb8) Conflicts: block.c block.h blockdev.c Signed-off-by: Kevin Wolf --- block.c | 5 +++++ block.h | 1 + monitor.c | 1 + 3 files changed, 7 insertions(+), 0 deletions(-) Signed-off-by: Eduardo Habkost --- block.c | 5 +++++ block.h | 1 + monitor.c | 1 + 3 files changed, 7 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index d09addd..a575111 100644 --- a/block.c +++ b/block.c @@ -1742,6 +1742,11 @@ int bdrv_can_snapshot(BlockDriverState *bs) return 1; } +int bdrv_is_snapshot(BlockDriverState *bs) +{ + return !!(bs->open_flags & BDRV_O_SNAPSHOT); +} + int bdrv_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) { diff --git a/block.h b/block.h index 7122e76..9b08d07 100644 --- a/block.h +++ b/block.h @@ -188,6 +188,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); int bdrv_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info); int bdrv_snapshot_goto(BlockDriverState *bs, diff --git a/monitor.c b/monitor.c index f52dd63..2c5eb59 100644 --- a/monitor.c +++ b/monitor.c @@ -1066,6 +1066,7 @@ static int do_change_block(Monitor *mon, const char *device, return -1; } bdrv_flags = bdrv_get_type_hint(bs) == BDRV_TYPE_CDROM ? 0 : BDRV_O_RDWR; + bdrv_flags |= bdrv_is_snapshot(bs) ? BDRV_O_SNAPSHOT : 0; if (bdrv_open(bs, filename, bdrv_flags, drv)) { return -1; } -- 1.7.3.2