aboutsummaryrefslogtreecommitdiffstats
path: root/block.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2012-01-18 14:40:41 +0000
committerKevin Wolf <kwolf@redhat.com>2012-01-26 11:45:26 +0100
commit2d3735d3bf61d5c8e154a197a11535cc65044334 (patch)
treec752ee53d1d7265777a3289e5cf63b00ae462244 /block.c
parent7e6246670add62116729bd93811e41eb60f66b77 (diff)
block: check bdrv_in_use() before blockdev operations
Long-running block operations like block migration and image streaming must have continual access to their block device. It is not safe to perform operations like hotplug, eject, change, resize, commit, or external snapshot while a long-running operation is in progress. This patch adds the missing bdrv_in_use() checks so that block migration and image streaming never have the rug pulled out from underneath them. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/block.c b/block.c
index 3f072f627..43f648437 100644
--- a/block.c
+++ b/block.c
@@ -1020,6 +1020,10 @@ int bdrv_commit(BlockDriverState *bs)
return -EACCES;
}
+ if (bdrv_in_use(bs) || bdrv_in_use(bs->backing_hd)) {
+ return -EBUSY;
+ }
+
backing_drv = bs->backing_hd->drv;
ro = bs->backing_hd->read_only;
strncpy(filename, bs->backing_hd->filename, sizeof(filename));