Revision abd7f68d
b/block.c | ||
---|---|---|
1206 | 1206 |
return bs->translation; |
1207 | 1207 |
} |
1208 | 1208 |
|
1209 |
void bdrv_set_on_error(BlockDriverState *bs, BlockErrorAction on_read_error, |
|
1210 |
BlockErrorAction on_write_error) |
|
1211 |
{ |
|
1212 |
bs->on_read_error = on_read_error; |
|
1213 |
bs->on_write_error = on_write_error; |
|
1214 |
} |
|
1215 |
|
|
1216 |
BlockErrorAction bdrv_get_on_error(BlockDriverState *bs, int is_read) |
|
1217 |
{ |
|
1218 |
return is_read ? bs->on_read_error : bs->on_write_error; |
|
1219 |
} |
|
1220 |
|
|
1209 | 1221 |
int bdrv_is_removable(BlockDriverState *bs) |
1210 | 1222 |
{ |
1211 | 1223 |
return bs->removable; |
b/block.h | ||
---|---|---|
42 | 42 |
#define BDRV_SECTOR_MASK ~(BDRV_SECTOR_SIZE - 1) |
43 | 43 |
|
44 | 44 |
typedef enum { |
45 |
BLOCK_ERR_REPORT, BLOCK_ERR_IGNORE, BLOCK_ERR_STOP_ENOSPC, |
|
46 |
BLOCK_ERR_STOP_ANY |
|
47 |
} BlockErrorAction; |
|
48 |
|
|
49 |
typedef enum { |
|
45 | 50 |
BDRV_ACTION_REPORT, BDRV_ACTION_IGNORE, BDRV_ACTION_STOP |
46 | 51 |
} BlockMonEventAction; |
47 | 52 |
|
... | ... | |
146 | 151 |
int *pcyls, int *pheads, int *psecs); |
147 | 152 |
int bdrv_get_type_hint(BlockDriverState *bs); |
148 | 153 |
int bdrv_get_translation_hint(BlockDriverState *bs); |
154 |
void bdrv_set_on_error(BlockDriverState *bs, BlockErrorAction on_read_error, |
|
155 |
BlockErrorAction on_write_error); |
|
156 |
BlockErrorAction bdrv_get_on_error(BlockDriverState *bs, int is_read); |
|
149 | 157 |
int bdrv_is_removable(BlockDriverState *bs); |
150 | 158 |
int bdrv_is_read_only(BlockDriverState *bs); |
151 | 159 |
int bdrv_is_sg(BlockDriverState *bs); |
b/block_int.h | ||
---|---|---|
182 | 182 |
drivers. They are not used by the block driver */ |
183 | 183 |
int cyls, heads, secs, translation; |
184 | 184 |
int type; |
185 |
BlockErrorAction on_read_error, on_write_error; |
|
185 | 186 |
char device_name[32]; |
186 | 187 |
unsigned long *dirty_bitmap; |
187 | 188 |
int64_t dirty_count; |
b/blockdev.c | ||
---|---|---|
90 | 90 |
return "\0"; |
91 | 91 |
} |
92 | 92 |
|
93 |
BlockInterfaceErrorAction drive_get_on_error( |
|
94 |
BlockDriverState *bdrv, int is_read) |
|
95 |
{ |
|
96 |
DriveInfo *dinfo; |
|
97 |
|
|
98 |
QTAILQ_FOREACH(dinfo, &drives, next) { |
|
99 |
if (dinfo->bdrv == bdrv) |
|
100 |
return is_read ? dinfo->on_read_error : dinfo->on_write_error; |
|
101 |
} |
|
102 |
|
|
103 |
return is_read ? BLOCK_ERR_REPORT : BLOCK_ERR_STOP_ENOSPC; |
|
104 |
} |
|
105 |
|
|
106 | 93 |
static void bdrv_format_print(void *opaque, const char *name) |
107 | 94 |
{ |
108 | 95 |
fprintf(stderr, " %s", name); |
... | ... | |
418 | 405 |
dinfo->type = type; |
419 | 406 |
dinfo->bus = bus_id; |
420 | 407 |
dinfo->unit = unit_id; |
421 |
dinfo->on_read_error = on_read_error; |
|
422 |
dinfo->on_write_error = on_write_error; |
|
423 | 408 |
dinfo->opts = opts; |
424 | 409 |
if (serial) |
425 | 410 |
strncpy(dinfo->serial, serial, sizeof(dinfo->serial) - 1); |
426 | 411 |
QTAILQ_INSERT_TAIL(&drives, dinfo, next); |
427 | 412 |
|
413 |
bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error); |
|
414 |
|
|
428 | 415 |
switch(type) { |
429 | 416 |
case IF_IDE: |
430 | 417 |
case IF_SCSI: |
b/blockdev.h | ||
---|---|---|
19 | 19 |
IF_COUNT |
20 | 20 |
} BlockInterfaceType; |
21 | 21 |
|
22 |
typedef enum { |
|
23 |
BLOCK_ERR_REPORT, BLOCK_ERR_IGNORE, BLOCK_ERR_STOP_ENOSPC, |
|
24 |
BLOCK_ERR_STOP_ANY |
|
25 |
} BlockInterfaceErrorAction; |
|
26 |
|
|
27 | 22 |
#define BLOCK_SERIAL_STRLEN 20 |
28 | 23 |
|
29 | 24 |
typedef struct DriveInfo { |
... | ... | |
34 | 29 |
int bus; |
35 | 30 |
int unit; |
36 | 31 |
QemuOpts *opts; |
37 |
BlockInterfaceErrorAction on_read_error; |
|
38 |
BlockInterfaceErrorAction on_write_error; |
|
39 | 32 |
char serial[BLOCK_SERIAL_STRLEN + 1]; |
40 | 33 |
QTAILQ_ENTRY(DriveInfo) next; |
41 | 34 |
} DriveInfo; |
... | ... | |
51 | 44 |
extern void drive_uninit(DriveInfo *dinfo); |
52 | 45 |
extern const char *drive_get_serial(BlockDriverState *bdrv); |
53 | 46 |
|
54 |
extern BlockInterfaceErrorAction drive_get_on_error( |
|
55 |
BlockDriverState *bdrv, int is_read); |
|
56 |
|
|
57 | 47 |
extern QemuOpts *drive_add(const char *file, const char *fmt, ...); |
58 | 48 |
extern DriveInfo *drive_init(QemuOpts *arg, int default_to_scsi, |
59 | 49 |
int *fatal_error); |
b/hw/ide/core.c | ||
---|---|---|
481 | 481 |
static int ide_handle_rw_error(IDEState *s, int error, int op) |
482 | 482 |
{ |
483 | 483 |
int is_read = (op & BM_STATUS_RETRY_READ); |
484 |
BlockInterfaceErrorAction action = drive_get_on_error(s->bs, is_read);
|
|
484 |
BlockErrorAction action = bdrv_get_on_error(s->bs, is_read);
|
|
485 | 485 |
|
486 | 486 |
if (action == BLOCK_ERR_IGNORE) { |
487 | 487 |
bdrv_mon_event(s->bs, BDRV_ACTION_IGNORE, is_read); |
b/hw/scsi-disk.c | ||
---|---|---|
182 | 182 |
static int scsi_handle_write_error(SCSIDiskReq *r, int error) |
183 | 183 |
{ |
184 | 184 |
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); |
185 |
BlockInterfaceErrorAction action = drive_get_on_error(s->bs, 0);
|
|
185 |
BlockErrorAction action = bdrv_get_on_error(s->bs, 0);
|
|
186 | 186 |
|
187 | 187 |
if (action == BLOCK_ERR_IGNORE) { |
188 | 188 |
bdrv_mon_event(s->bs, BDRV_ACTION_IGNORE, 0); |
b/hw/virtio-blk.c | ||
---|---|---|
58 | 58 |
static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error, |
59 | 59 |
int is_read) |
60 | 60 |
{ |
61 |
BlockInterfaceErrorAction action = |
|
62 |
drive_get_on_error(req->dev->bs, is_read); |
|
61 |
BlockErrorAction action = bdrv_get_on_error(req->dev->bs, is_read); |
|
63 | 62 |
VirtIOBlock *s = req->dev; |
64 | 63 |
|
65 | 64 |
if (action == BLOCK_ERR_IGNORE) { |
Also available in: Unified diff