2 * QEMU host block devices
4 * Copyright (c) 2003-2008 Fabrice Bellard
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.
14 #include "qemu-queue.h"
18 IF_IDE
, IF_SCSI
, IF_FLOPPY
, IF_PFLASH
, IF_MTD
, IF_SD
, IF_VIRTIO
, IF_XEN
,
23 BLOCK_ERR_REPORT
, BLOCK_ERR_IGNORE
, BLOCK_ERR_STOP_ENOSPC
,
25 } BlockInterfaceErrorAction
;
27 #define BLOCK_SERIAL_STRLEN 20
29 typedef struct DriveInfo
{
30 BlockDriverState
*bdrv
;
33 BlockInterfaceType type
;
37 BlockInterfaceErrorAction on_read_error
;
38 BlockInterfaceErrorAction on_write_error
;
39 char serial
[BLOCK_SERIAL_STRLEN
+ 1];
40 QTAILQ_ENTRY(DriveInfo
) next
;
43 #define MAX_IDE_DEVS 2
44 #define MAX_SCSI_DEVS 7
46 extern QTAILQ_HEAD(drivelist
, DriveInfo
) drives
;
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
);
54 extern BlockInterfaceErrorAction
drive_get_on_error(
55 BlockDriverState
*bdrv
, int is_read
);
57 extern QemuOpts
*drive_add(const char *file
, const char *fmt
, ...);
58 extern DriveInfo
*drive_init(QemuOpts
*arg
, int default_to_scsi
,
63 DriveInfo
*add_init_drive(const char *opts
);
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
);