blkdebug: Add @iotype error option

This new error option allows users of blkdebug to inject errors only on
certain kinds of I/O operations.  Users usually want to make a very
specific operation fail, not just any; but right now they simply hope
that the event that triggers the error injection is followed up with
that very operation.  That may not be true, however, because the block
layer is changing (including blkdebug, which may increase the number of
types of I/O operations on which to inject errors).

The new option's default has been chosen to keep backwards
compatibility.

Note that similar to the internal representation, we could choose to
expose this option as a list of I/O types.  But there is no practical
use for this, because as described above, users usually know exactly
which kind of operation they want to make fail, so there is no need to
specify multiple I/O types at once.  In addition, exposing this option
as a list would require non-trivial changes to qemu_opts_absorb_qdict().

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-id: 20190507203508.18026-4-mreitz@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
Max Reitz 2019-05-07 22:35:04 +02:00
parent 8eaac025fb
commit 16789db3de
2 changed files with 67 additions and 9 deletions

View file

@ -3264,6 +3264,26 @@
'l1_shrink_write_table', 'l1_shrink_free_l2_clusters',
'cor_write', 'cluster_alloc_space'] }
##
# @BlkdebugIOType:
#
# Kinds of I/O that blkdebug can inject errors in.
#
# @read: .bdrv_co_preadv()
#
# @write: .bdrv_co_pwritev()
#
# @write-zeroes: .bdrv_co_pwrite_zeroes()
#
# @discard: .bdrv_co_pdiscard()
#
# @flush: .bdrv_co_flush_to_disk()
#
# Since: 4.1
##
{ 'enum': 'BlkdebugIOType', 'prefix': 'BLKDEBUG_IO_TYPE',
'data': [ 'read', 'write', 'write-zeroes', 'discard', 'flush' ] }
##
# @BlkdebugInjectErrorOptions:
#
@ -3274,6 +3294,11 @@
# @state: the state identifier blkdebug needs to be in to
# actually trigger the event; defaults to "any"
#
# @iotype: the type of I/O operations on which this error should
# be injected; defaults to "all read, write,
# write-zeroes, discard, and flush operations"
# (since: 4.1)
#
# @errno: error identifier (errno) to be returned; defaults to
# EIO
#
@ -3291,6 +3316,7 @@
{ 'struct': 'BlkdebugInjectErrorOptions',
'data': { 'event': 'BlkdebugEvent',
'*state': 'int',
'*iotype': 'BlkdebugIOType',
'*errno': 'int',
'*sector': 'int',
'*once': 'bool',