Skip to content

Commit

Permalink
blkdebug: report errors on flush too
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
(cherry picked from commit 9e52c53)

*included to maintain parity with unit tests which inject errors
 via blkdebug. needed for:
 "qcow2: Flushing the caches in qcow2_close may fail"

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
  • Loading branch information
bonzini authored and mdroth committed Jan 14, 2015
1 parent 175117c commit 0073781
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions block/blkdebug.c
Expand Up @@ -526,6 +526,25 @@ static BlockDriverAIOCB *blkdebug_aio_writev(BlockDriverState *bs,
return bdrv_aio_writev(bs->file, sector_num, qiov, nb_sectors, cb, opaque);
}

static BlockDriverAIOCB *blkdebug_aio_flush(BlockDriverState *bs,
BlockDriverCompletionFunc *cb, void *opaque)
{
BDRVBlkdebugState *s = bs->opaque;
BlkdebugRule *rule = NULL;

QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) {
if (rule->options.inject.sector == -1) {
break;
}
}

if (rule && rule->options.inject.error) {
return inject_error(bs, cb, opaque, rule);
}

return bdrv_aio_flush(bs->file, cb, opaque);
}


static void blkdebug_close(BlockDriverState *bs)
{
Expand Down Expand Up @@ -703,6 +722,7 @@ static BlockDriver bdrv_blkdebug = {

.bdrv_aio_readv = blkdebug_aio_readv,
.bdrv_aio_writev = blkdebug_aio_writev,
.bdrv_aio_flush = blkdebug_aio_flush,

.bdrv_debug_event = blkdebug_debug_event,
.bdrv_debug_breakpoint = blkdebug_debug_breakpoint,
Expand Down

0 comments on commit 0073781

Please sign in to comment.