diff options
author | Ryan Harper <ryanh@us.ibm.com> | 2011-03-07 10:01:04 -0600 |
---|---|---|
committer | Justin M. Forbes <jforbes@redhat.com> | 2011-04-04 14:24:29 -0500 |
commit | a0af597d00c27741a0bf99720209def055f45499 (patch) | |
tree | 3cb13d3becec8c50e55d24ae85400d382ef4f4b9 | |
parent | d4b4ba03e86eeb697f04bf1173c29530e77e0ce5 (diff) | |
download | qemu-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.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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; } |