Revision e4780db4

b/block/blkdebug.c
59 59
            int error;
60 60
            int immediately;
61 61
            int once;
62
            int64_t sector;
62 63
        } inject;
63 64
        struct {
64 65
            int new_state;
......
85 86
            .type = QEMU_OPT_NUMBER,
86 87
        },
87 88
        {
89
            .name = "sector",
90
            .type = QEMU_OPT_NUMBER,
91
        },
92
        {
88 93
            .name = "once",
89 94
            .type = QEMU_OPT_BOOL,
90 95
        },
......
213 218
        rule->options.inject.once  = qemu_opt_get_bool(opts, "once", 0);
214 219
        rule->options.inject.immediately =
215 220
            qemu_opt_get_bool(opts, "immediately", 0);
221
        rule->options.inject.sector = qemu_opt_get_number(opts, "sector", -1);
216 222
        break;
217 223

  
218 224
    case ACTION_SET_STATE:
......
343 349
    BlockDriverCompletionFunc *cb, void *opaque)
344 350
{
345 351
    BDRVBlkdebugState *s = bs->opaque;
346
    BlkdebugRule *rule = QSIMPLEQ_FIRST(&s->active_rules);
352
    BlkdebugRule *rule = NULL;
353

  
354
    QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) {
355
        if (rule->options.inject.sector == -1 ||
356
            (rule->options.inject.sector >= sector_num &&
357
             rule->options.inject.sector < sector_num + nb_sectors)) {
358
            break;
359
        }
360
    }
347 361

  
348 362
    if (rule && rule->options.inject.error) {
349 363
        return inject_error(bs, cb, opaque, rule);
......
357 371
    BlockDriverCompletionFunc *cb, void *opaque)
358 372
{
359 373
    BDRVBlkdebugState *s = bs->opaque;
360
    BlkdebugRule *rule = QSIMPLEQ_FIRST(&s->active_rules);
374
    BlkdebugRule *rule = NULL;
375

  
376
    QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) {
377
        if (rule->options.inject.sector == -1 ||
378
            (rule->options.inject.sector >= sector_num &&
379
             rule->options.inject.sector < sector_num + nb_sectors)) {
380
            break;
381
        }
382
    }
361 383

  
362 384
    if (rule && rule->options.inject.error) {
363 385
        return inject_error(bs, cb, opaque, rule);

Also available in: Unified diff