Merge commit 'a4673e276248ada38f40d39191a197e7e35d3f8b' into upstream-merge
[qemu-kvm/stefanha.git] / blockdev.h
blob30ea28e85cef0aa63e2ada32f31b6a4ff02051b6
1 /*
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.
8 */
10 #ifndef BLOCKDEV_H
11 #define BLOCKDEV_H
13 #include "block.h"
14 #include "qemu-queue.h"
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;
22 typedef enum {
23 BLOCK_ERR_REPORT, BLOCK_ERR_IGNORE, BLOCK_ERR_STOP_ENOSPC,
24 BLOCK_ERR_STOP_ANY
25 } BlockInterfaceErrorAction;
27 #define BLOCK_SERIAL_STRLEN 20
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;
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,
59 int *fatal_error);
61 /* device-hotplug */
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);
71 extern DriveInfo *extboot_drive;
73 #endif