From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com
Subject: [Qemu-devel] [PATCH 5/6] blkdebug: optionally tie errors to a specific sector
Date: Wed, 6 Jun 2012 08:10:43 +0200 [thread overview]
Message-ID: <1338963044-21445-6-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1338963044-21445-1-git-send-email-pbonzini@redhat.com>
This makes blkdebug scripts more powerful, and independent of the
exact sequence of operations performed by streaming.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/blkdebug.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/block/blkdebug.c b/block/blkdebug.c
index d12ebbf..59dcea0 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -59,6 +59,7 @@ typedef struct BlkdebugRule {
int error;
int immediately;
int once;
+ int64_t sector;
} inject;
struct {
int new_state;
@@ -85,6 +86,10 @@ static QemuOptsList inject_error_opts = {
.type = QEMU_OPT_NUMBER,
},
{
+ .name = "sector",
+ .type = QEMU_OPT_NUMBER,
+ },
+ {
.name = "once",
.type = QEMU_OPT_BOOL,
},
@@ -213,6 +218,7 @@ static int add_rule(QemuOpts *opts, void *opaque)
rule->options.inject.once = qemu_opt_get_bool(opts, "once", 0);
rule->options.inject.immediately =
qemu_opt_get_bool(opts, "immediately", 0);
+ rule->options.inject.sector = qemu_opt_get_number(opts, "sector", -1);
break;
case ACTION_SET_STATE:
@@ -343,7 +349,15 @@ static BlockDriverAIOCB *blkdebug_aio_readv(BlockDriverState *bs,
BlockDriverCompletionFunc *cb, void *opaque)
{
BDRVBlkdebugState *s = bs->opaque;
- BlkdebugRule *rule = QSIMPLEQ_FIRST(&s->active_rules);
+ BlkdebugRule *rule = NULL;
+
+ QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) {
+ if (rule->options.inject.sector == -1 ||
+ (rule->options.inject.sector >= sector_num &&
+ rule->options.inject.sector < sector_num + nb_sectors)) {
+ break;
+ }
+ }
if (rule && rule->options.inject.error) {
return inject_error(bs, cb, opaque, rule);
@@ -357,7 +371,15 @@ static BlockDriverAIOCB *blkdebug_aio_writev(BlockDriverState *bs,
BlockDriverCompletionFunc *cb, void *opaque)
{
BDRVBlkdebugState *s = bs->opaque;
- BlkdebugRule *rule = QSIMPLEQ_FIRST(&s->active_rules);
+ BlkdebugRule *rule = NULL;
+
+ QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) {
+ if (rule->options.inject.sector == -1 ||
+ (rule->options.inject.sector >= sector_num &&
+ rule->options.inject.sector < sector_num + nb_sectors)) {
+ break;
+ }
+ }
if (rule && rule->options.inject.error) {
return inject_error(bs, cb, opaque, rule);
--
1.7.10.1
next prev parent reply other threads:[~2012-06-06 6:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-06 6:10 [Qemu-devel] [PATCH 0/6] blkdebug changes extracted from 1.2 streaming patches Paolo Bonzini
2012-06-06 6:10 ` [Qemu-devel] [PATCH 1/6] blkdebug: remove sync i/o events Paolo Bonzini
2012-06-07 15:08 ` Stefan Hajnoczi
2012-06-06 6:10 ` [Qemu-devel] [PATCH 2/6] blkdebug: tiny cleanup Paolo Bonzini
2012-06-06 6:10 ` [Qemu-devel] [PATCH 3/6] blkdebug: pass getlength to underlying file Paolo Bonzini
2012-06-06 6:10 ` [Qemu-devel] [PATCH 4/6] blkdebug: store list of active rules Paolo Bonzini
2012-07-03 15:40 ` Kevin Wolf
2012-07-03 16:03 ` Paolo Bonzini
2012-07-04 6:39 ` Kevin Wolf
2012-06-06 6:10 ` Paolo Bonzini [this message]
2012-06-07 15:10 ` [Qemu-devel] [PATCH 5/6] blkdebug: optionally tie errors to a specific sector Stefan Hajnoczi
2012-06-06 6:10 ` [Qemu-devel] [PATCH 6/6] raw: hook into blkdebug Paolo Bonzini
2012-07-03 14:50 ` [Qemu-devel] [PATCH 0/6] blkdebug changes extracted from 1.2 streaming patches Paolo Bonzini
2012-07-04 9:37 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1338963044-21445-6-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).