blkdebug.c (a31939e6c854e26e391efaec49c9d7f796369bbb) | blkdebug.c (7fb1cf1606c78c9d5b538f29176fd5a101726a9d) |
---|---|
1/* 2 * Block protocol for I/O error injection 3 * 4 * Copyright (c) 2010 Kevin Wolf <kwolf@redhat.com> 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 22 unchanged lines hidden (view full) --- 31#include "qapi/qmp/qint.h" 32#include "qapi/qmp/qstring.h" 33#include "sysemu/qtest.h" 34 35typedef struct BDRVBlkdebugState { 36 int state; 37 int new_state; 38 | 1/* 2 * Block protocol for I/O error injection 3 * 4 * Copyright (c) 2010 Kevin Wolf <kwolf@redhat.com> 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 22 unchanged lines hidden (view full) --- 31#include "qapi/qmp/qint.h" 32#include "qapi/qmp/qstring.h" 33#include "sysemu/qtest.h" 34 35typedef struct BDRVBlkdebugState { 36 int state; 37 int new_state; 38 |
39 QLIST_HEAD(, BlkdebugRule) rules[BLKDBG_MAX]; | 39 QLIST_HEAD(, BlkdebugRule) rules[BLKDBG__MAX]; |
40 QSIMPLEQ_HEAD(, BlkdebugRule) active_rules; 41 QLIST_HEAD(, BlkdebugSuspendedReq) suspended_reqs; 42} BDRVBlkdebugState; 43 44typedef struct BlkdebugAIOCB { 45 BlockAIOCB common; 46 QEMUBH *bh; 47 int ret; --- 94 unchanged lines hidden (view full) --- 142 &set_state_opts, 143 NULL 144}; 145 146static int get_event_by_name(const char *name, BlkdebugEvent *event) 147{ 148 int i; 149 | 40 QSIMPLEQ_HEAD(, BlkdebugRule) active_rules; 41 QLIST_HEAD(, BlkdebugSuspendedReq) suspended_reqs; 42} BDRVBlkdebugState; 43 44typedef struct BlkdebugAIOCB { 45 BlockAIOCB common; 46 QEMUBH *bh; 47 int ret; --- 94 unchanged lines hidden (view full) --- 142 &set_state_opts, 143 NULL 144}; 145 146static int get_event_by_name(const char *name, BlkdebugEvent *event) 147{ 148 int i; 149 |
150 for (i = 0; i < BLKDBG_MAX; i++) { | 150 for (i = 0; i < BLKDBG__MAX; i++) { |
151 if (!strcmp(BlkdebugEvent_lookup[i], name)) { 152 *event = i; 153 return 0; 154 } 155 } 156 157 return -1; 158} --- 343 unchanged lines hidden (view full) --- 502 503 504static void blkdebug_close(BlockDriverState *bs) 505{ 506 BDRVBlkdebugState *s = bs->opaque; 507 BlkdebugRule *rule, *next; 508 int i; 509 | 151 if (!strcmp(BlkdebugEvent_lookup[i], name)) { 152 *event = i; 153 return 0; 154 } 155 } 156 157 return -1; 158} --- 343 unchanged lines hidden (view full) --- 502 503 504static void blkdebug_close(BlockDriverState *bs) 505{ 506 BDRVBlkdebugState *s = bs->opaque; 507 BlkdebugRule *rule, *next; 508 int i; 509 |
510 for (i = 0; i < BLKDBG_MAX; i++) { | 510 for (i = 0; i < BLKDBG__MAX; i++) { |
511 QLIST_FOREACH_SAFE(rule, &s->rules[i], next, next) { 512 remove_rule(rule); 513 } 514 } 515} 516 517static void suspend_request(BlockDriverState *bs, BlkdebugRule *rule) 518{ --- 52 unchanged lines hidden (view full) --- 571} 572 573static void blkdebug_debug_event(BlockDriverState *bs, BlkdebugEvent event) 574{ 575 BDRVBlkdebugState *s = bs->opaque; 576 struct BlkdebugRule *rule, *next; 577 bool injected; 578 | 511 QLIST_FOREACH_SAFE(rule, &s->rules[i], next, next) { 512 remove_rule(rule); 513 } 514 } 515} 516 517static void suspend_request(BlockDriverState *bs, BlkdebugRule *rule) 518{ --- 52 unchanged lines hidden (view full) --- 571} 572 573static void blkdebug_debug_event(BlockDriverState *bs, BlkdebugEvent event) 574{ 575 BDRVBlkdebugState *s = bs->opaque; 576 struct BlkdebugRule *rule, *next; 577 bool injected; 578 |
579 assert((int)event >= 0 && event < BLKDBG_MAX); | 579 assert((int)event >= 0 && event < BLKDBG__MAX); |
580 581 injected = false; 582 s->new_state = s->state; 583 QLIST_FOREACH_SAFE(rule, &s->rules[event], next, next) { 584 injected = process_rule(bs, rule, injected); 585 } 586 s->state = s->new_state; 587} --- 40 unchanged lines hidden (view full) --- 628static int blkdebug_debug_remove_breakpoint(BlockDriverState *bs, 629 const char *tag) 630{ 631 BDRVBlkdebugState *s = bs->opaque; 632 BlkdebugSuspendedReq *r, *r_next; 633 BlkdebugRule *rule, *next; 634 int i, ret = -ENOENT; 635 | 580 581 injected = false; 582 s->new_state = s->state; 583 QLIST_FOREACH_SAFE(rule, &s->rules[event], next, next) { 584 injected = process_rule(bs, rule, injected); 585 } 586 s->state = s->new_state; 587} --- 40 unchanged lines hidden (view full) --- 628static int blkdebug_debug_remove_breakpoint(BlockDriverState *bs, 629 const char *tag) 630{ 631 BDRVBlkdebugState *s = bs->opaque; 632 BlkdebugSuspendedReq *r, *r_next; 633 BlkdebugRule *rule, *next; 634 int i, ret = -ENOENT; 635 |
636 for (i = 0; i < BLKDBG_MAX; i++) { | 636 for (i = 0; i < BLKDBG__MAX; i++) { |
637 QLIST_FOREACH_SAFE(rule, &s->rules[i], next, next) { 638 if (rule->action == ACTION_SUSPEND && 639 !strcmp(rule->options.suspend.tag, tag)) { 640 remove_rule(rule); 641 ret = 0; 642 } 643 } 644 } --- 111 unchanged lines hidden --- | 637 QLIST_FOREACH_SAFE(rule, &s->rules[i], next, next) { 638 if (rule->action == ACTION_SUSPEND && 639 !strcmp(rule->options.suspend.tag, tag)) { 640 remove_rule(rule); 641 ret = 0; 642 } 643 } 644 } --- 111 unchanged lines hidden --- |