root / blockdev.h @ 666daa68
History | View | Annotate | Download (2 kB)
1 |
/*
|
---|---|
2 |
* QEMU host block devices
|
3 |
*
|
4 |
* Copyright (c) 2003-2008 Fabrice Bellard
|
5 |
*
|
6 |
* This work is licensed under the terms of the GNU GPL, version 2 or
|
7 |
* later. See the COPYING file in the top-level directory.
|
8 |
*/
|
9 |
|
10 |
#ifndef BLOCKDEV_H
|
11 |
#define BLOCKDEV_H
|
12 |
|
13 |
#include "block.h" |
14 |
#include "qemu-queue.h" |
15 |
|
16 |
typedef enum { |
17 |
IF_NONE, |
18 |
IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN, |
19 |
IF_COUNT |
20 |
} BlockInterfaceType; |
21 |
|
22 |
typedef enum { |
23 |
BLOCK_ERR_REPORT, BLOCK_ERR_IGNORE, BLOCK_ERR_STOP_ENOSPC, |
24 |
BLOCK_ERR_STOP_ANY |
25 |
} BlockInterfaceErrorAction; |
26 |
|
27 |
#define BLOCK_SERIAL_STRLEN 20 |
28 |
|
29 |
typedef struct DriveInfo { |
30 |
BlockDriverState *bdrv; |
31 |
char *id;
|
32 |
const char *devaddr; |
33 |
BlockInterfaceType type; |
34 |
int bus;
|
35 |
int unit;
|
36 |
QemuOpts *opts; |
37 |
BlockInterfaceErrorAction on_read_error; |
38 |
BlockInterfaceErrorAction on_write_error; |
39 |
char serial[BLOCK_SERIAL_STRLEN + 1]; |
40 |
QTAILQ_ENTRY(DriveInfo) next; |
41 |
} DriveInfo; |
42 |
|
43 |
#define MAX_IDE_DEVS 2 |
44 |
#define MAX_SCSI_DEVS 7 |
45 |
|
46 |
extern QTAILQ_HEAD(drivelist, DriveInfo) drives;
|
47 |
|
48 |
extern DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit); |
49 |
extern DriveInfo *drive_get_by_id(const char *id); |
50 |
extern int drive_get_max_bus(BlockInterfaceType type); |
51 |
extern void drive_uninit(DriveInfo *dinfo); |
52 |
extern const char *drive_get_serial(BlockDriverState *bdrv); |
53 |
|
54 |
extern BlockInterfaceErrorAction drive_get_on_error(
|
55 |
BlockDriverState *bdrv, int is_read);
|
56 |
|
57 |
extern QemuOpts *drive_add(const char *file, const char *fmt, ...); |
58 |
extern DriveInfo *drive_init(QemuOpts *arg, int default_to_scsi, |
59 |
int *fatal_error);
|
60 |
|
61 |
/* device-hotplug */
|
62 |
|
63 |
DriveInfo *add_init_drive(const char *opts); |
64 |
|
65 |
void do_commit(Monitor *mon, const QDict *qdict); |
66 |
int do_eject(Monitor *mon, const QDict *qdict, QObject **ret_data); |
67 |
int do_block_set_passwd(Monitor *mon, const QDict *qdict, QObject **ret_data); |
68 |
int do_change_block(Monitor *mon, const char *device, |
69 |
const char *filename, const char *fmt); |
70 |
|
71 |
#endif
|