Skip to contentSkip to conversation

blockdev: unset inappropriate flags when changing medium

PATCH Applied Alyssa Milburn 2 participants 2 messages Feb 6, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 blockdev: unset inappropriate flags when changing medium

Most importantly, this removes BDRV_O_TEMPORARY, to avoid unlink()ing an image which replaces a snapshotted one.

---
 blockdev.c | 2 ++
 1 file changed, 2 insertions(+)
blockdev.c +2 -0
index be4ca44..a916b06 100644
@@ -2514,6 +2514,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;
Signature · 1 line
2.1.0
Applied
#1 lore raw
Quoted 14 lines · Alyssa Milburn

Most importantly, this removes BDRV_O_TEMPORARY, to avoid unlink()ing an image which replaces a snapshotted one.

---
 blockdev.c | 2 ++
 1 file changed, 2 insertions(+)
blockdev.c +0 -0
index be4ca44..a916b06 100644

blockdev.c void qmp_blockdev_change_medium(const char *device, const char *filename, · line 2521

Quoted 8 lines
blockdev.c +2 -0
@@ -2514,6 +2514,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;

Thanks, applied to my block tree:

https://github.com/XanClic/qemu/commits/block

Max