]> git.proxmox.com Git - qemu.git/blame - blockdev.h
ehci: Fix NULL ptr deref when unplugging an USB dev with an iso stream active
[qemu.git] / blockdev.h
CommitLineData
666daa68
MA
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"
333a96ec 14#include "error.h"
666daa68
MA
15#include "qemu-queue.h"
16
14bafc54
MA
17void blockdev_mark_auto_del(BlockDriverState *bs);
18void blockdev_auto_del(BlockDriverState *bs);
19
666daa68
MA
20#define BLOCK_SERIAL_STRLEN 20
21
904ebffe 22typedef enum {
2292ddae 23 IF_DEFAULT = -1, /* for use with drive_add() only */
904ebffe
MA
24 IF_NONE,
25 IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN,
26 IF_COUNT
27} BlockInterfaceType;
28
2446333c 29struct DriveInfo {
666daa68
MA
30 BlockDriverState *bdrv;
31 char *id;
32 const char *devaddr;
33 BlockInterfaceType type;
34 int bus;
35 int unit;
14bafc54 36 int auto_del; /* see blockdev_mark_auto_del() */
95b5edcd 37 int media_cd;
666daa68 38 QemuOpts *opts;
666daa68
MA
39 char serial[BLOCK_SERIAL_STRLEN + 1];
40 QTAILQ_ENTRY(DriveInfo) next;
84fb3925 41 int refcount;
2446333c 42};
666daa68 43
6ea421fe 44DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit);
f1bd51ac 45DriveInfo *drive_get_by_index(BlockInterfaceType type, int index);
6ea421fe 46int drive_get_max_bus(BlockInterfaceType type);
13839974 47DriveInfo *drive_get_next(BlockInterfaceType type);
84fb3925
MT
48void drive_get_ref(DriveInfo *dinfo);
49void drive_put_ref(DriveInfo *dinfo);
6ea421fe
SW
50DriveInfo *drive_get_by_blockdev(BlockDriverState *bs);
51
2292ddae
MA
52QemuOpts *drive_def(const char *optstr);
53QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file,
5645b0f4 54 const char *optstr);
319ae529 55DriveInfo *drive_init(QemuOpts *arg, int default_to_scsi);
666daa68
MA
56
57/* device-hotplug */
58
59DriveInfo *add_init_drive(const char *opts);
60
333a96ec
LC
61void qmp_change_blockdev(const char *device, const char *filename,
62 bool has_format, const char *format, Error **errp);
666daa68 63void do_commit(Monitor *mon, const QDict *qdict);
9063f814 64int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
666daa68 65#endif