Skip to content

Commit 0073781

Browse files
bonzinimdroth
authored andcommitted
blkdebug: report errors on flush too
Signed-off-by: Paolo Bonzini <[email protected]> Signed-off-by: John Snow <[email protected]> Signed-off-by: Stefan Hajnoczi <[email protected]> (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 <[email protected]>
1 parent 175117c commit 0073781

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

block/blkdebug.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,25 @@ static BlockDriverAIOCB *blkdebug_aio_writev(BlockDriverState *bs,
526526
return bdrv_aio_writev(bs->file, sector_num, qiov, nb_sectors, cb, opaque);
527527
}
528528

529+
static BlockDriverAIOCB *blkdebug_aio_flush(BlockDriverState *bs,
530+
BlockDriverCompletionFunc *cb, void *opaque)
531+
{
532+
BDRVBlkdebugState *s = bs->opaque;
533+
BlkdebugRule *rule = NULL;
534+
535+
QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) {
536+
if (rule->options.inject.sector == -1) {
537+
break;
538+
}
539+
}
540+
541+
if (rule && rule->options.inject.error) {
542+
return inject_error(bs, cb, opaque, rule);
543+
}
544+
545+
return bdrv_aio_flush(bs->file, cb, opaque);
546+
}
547+
529548

530549
static void blkdebug_close(BlockDriverState *bs)
531550
{
@@ -703,6 +722,7 @@ static BlockDriver bdrv_blkdebug = {
703722

704723
.bdrv_aio_readv = blkdebug_aio_readv,
705724
.bdrv_aio_writev = blkdebug_aio_writev,
725+
.bdrv_aio_flush = blkdebug_aio_flush,
706726

707727
.bdrv_debug_event = blkdebug_debug_event,
708728
.bdrv_debug_breakpoint = blkdebug_debug_breakpoint,

0 commit comments

Comments
 (0)