aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Harper <ryanh@us.ibm.com>2011-03-07 10:01:04 -0600
committerJustin M. Forbes <jforbes@redhat.com>2011-04-04 14:24:29 -0500
commita0af597d00c27741a0bf99720209def055f45499 (patch)
tree3cb13d3becec8c50e55d24ae85400d382ef4f4b9
parentd4b4ba03e86eeb697f04bf1173c29530e77e0ce5 (diff)
downloadqemu-a0af597d00c27741a0bf99720209def055f45499.zip
qemu-a0af597d00c27741a0bf99720209def055f45499.tar.gz
qemu-a0af597d00c27741a0bf99720209def055f45499.tar.bz2
Don't allow multiwrites against a block device without underlying medium
If the block device has been closed, we no longer have a medium to submit IO against, check for this before submitting io. This prevents a segfault further in the code where we dereference elements of the block driver. Signed-off-by: Ryan Harper <ryanh@us.ibm.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--block.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/block.c b/block.c
index b476479..17de165 100644
--- a/block.c
+++ b/block.c
@@ -2295,6 +2295,14 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs)
MultiwriteCB *mcb;
int i;
+ /* don't submit writes if we don't have a medium */
+ if (bs->drv == NULL) {
+ for (i = 0; i < num_reqs; i++) {
+ reqs[i].error = -ENOMEDIUM;
+ }
+ return -1;
+ }
+
if (num_reqs == 0) {
return 0;
}