blockdev: unset inappropriate flags when changing medium
authorAlyssa Milburn <fuzzie@fuzzie.org>
Sat, 6 Feb 2016 13:36:18 +0000 (13:36 +0000)
committerMax Reitz <mreitz@redhat.com>
Mon, 22 Feb 2016 15:54:14 +0000 (16:54 +0100)
Most importantly, this removes BDRV_O_TEMPORARY, to avoid unlink()ing an
image which replaces a snapshotted one.

Signed-off-by: Alyssa Milburn <fuzzie@fuzzie.org>
Message-id: 20160206133618.GA16635@li141-249.members.linode.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
blockdev.c

index 5c02a4289c435d5eaf290108c435602d7a7ca902..d4bc43594020ace2c3887d1b10d949e52d34450b 100644 (file)
@@ -2513,6 +2513,8 @@ void qmp_blockdev_change_medium(const char *device, const char *filename,
     }
 
     bdrv_flags = blk_get_open_flags_from_root_state(blk);
+    bdrv_flags &= ~(BDRV_O_TEMPORARY | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING |
+        BDRV_O_PROTOCOL);
 
     if (!has_read_only) {
         read_only = BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN;