2012-10-23 23:41:52 +00:00
|
|
|
#ifndef QEMU_TYPEDEFS_H
|
|
|
|
#define QEMU_TYPEDEFS_H
|
|
|
|
|
|
|
|
/* A load of opaque types so that device init declarations don't have to
|
|
|
|
pull in all the real definitions. */
|
|
|
|
struct Monitor;
|
|
|
|
|
2014-12-11 11:46:36 +00:00
|
|
|
/* Please keep this list in alphabetical order */
|
|
|
|
typedef struct AdapterInfo AdapterInfo;
|
2013-04-09 09:10:27 +00:00
|
|
|
typedef struct AddressSpace AddressSpace;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct AioContext AioContext;
|
2012-10-23 23:41:52 +00:00
|
|
|
typedef struct AudioState AudioState;
|
block: New BlockBackend
A block device consists of a frontend device model and a backend.
A block backend has a tree of block drivers doing the actual work.
The tree is managed by the block layer.
We currently use a single abstraction BlockDriverState both for tree
nodes and the backend as a whole. Drawbacks:
* Its API includes both stuff that makes sense only at the block
backend level (root of the tree) and stuff that's only for use
within the block layer. This makes the API bigger and more complex
than necessary. Moreover, it's not obvious which interfaces are
meant for device models, and which really aren't.
* Since device models keep a reference to their backend, the backend
object can't just be destroyed. But for media change, we need to
replace the tree. Our solution is to make the BlockDriverState
generic, with actual driver state in a separate object, pointed to
by member opaque. That lets us replace the tree by deinitializing
and reinitializing its root. This special need of the root makes
the data structure awkward everywhere in the tree.
The general plan is to separate the APIs into "block backend", for use
by device models, monitor and whatever other code dealing with block
backends, and "block driver", for use by the block layer and whatever
other code (if any) dealing with trees and tree nodes.
Code dealing with block backends, device models in particular, should
become completely oblivious of BlockDriverState. This should let us
clean up both APIs, and the tree data structures.
This commit is a first step. It creates a minimal "block backend"
API: type BlockBackend and functions to create, destroy and find them.
BlockBackend objects are created and destroyed exactly when root
BlockDriverState objects are created and destroyed. "Root" in the
sense of "in bdrv_states". They're not yet used for anything; that'll
come shortly.
A root BlockDriverState is created with bdrv_new_root(), so where to
create a BlockBackend is obvious. Where these roots get destroyed
isn't always as obvious.
It is obvious in qemu-img.c, qemu-io.c and qemu-nbd.c, and in error
paths of blockdev_init(), blk_connect(). That leaves destruction of
objects successfully created by blockdev_init() and blk_connect().
blockdev_init() is used only by drive_new() and qmp_blockdev_add().
Objects created by the latter are currently indestructible (see commit
48f364d "blockdev: Refuse to drive_del something added with
blockdev-add" and commit 2d246f0 "blockdev: Introduce
DriveInfo.enable_auto_del"). Objects created by the former get
destroyed by drive_del().
Objects created by blk_connect() get destroyed by blk_disconnect().
BlockBackend is reference-counted. Its reference count never exceeds
one so far, but that's going to change.
In drive_del(), the BB's reference count is surely one now. The BDS's
reference count is greater than one when something else is holding a
reference, such as a block job. In this case, the BB is destroyed
right away, but the BDS lives on until all extra references get
dropped.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-10-07 11:59:04 +00:00
|
|
|
typedef struct BlockBackend BlockBackend;
|
2012-10-23 23:41:52 +00:00
|
|
|
typedef struct BlockDriverState BlockDriverState;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct BusClass BusClass;
|
|
|
|
typedef struct BusState BusState;
|
|
|
|
typedef struct CharDriverState CharDriverState;
|
|
|
|
typedef struct CompatProperty CompatProperty;
|
|
|
|
typedef struct DeviceState DeviceState;
|
2015-01-20 11:05:07 +00:00
|
|
|
typedef struct DeviceListener DeviceListener;
|
2012-10-23 23:41:52 +00:00
|
|
|
typedef struct DisplayChangeListener DisplayChangeListener;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct DisplayState DisplayState;
|
2012-10-23 23:41:52 +00:00
|
|
|
typedef struct DisplaySurface DisplaySurface;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct DriveInfo DriveInfo;
|
|
|
|
typedef struct EventNotifier EventNotifier;
|
2014-12-22 12:11:35 +00:00
|
|
|
typedef struct FWCfgIoState FWCfgIoState;
|
|
|
|
typedef struct FWCfgMemState FWCfgMemState;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct FWCfgState FWCfgState;
|
|
|
|
typedef struct HCIInfo HCIInfo;
|
2013-08-02 22:18:51 +00:00
|
|
|
typedef struct I2CBus I2CBus;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct I2SCodec I2SCodec;
|
2012-10-23 23:41:52 +00:00
|
|
|
typedef struct ISABus ISABus;
|
|
|
|
typedef struct ISADevice ISADevice;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct MACAddr MACAddr;
|
|
|
|
typedef struct MachineClass MachineClass;
|
|
|
|
typedef struct MachineState MachineState;
|
|
|
|
typedef struct MemoryListener MemoryListener;
|
|
|
|
typedef struct MemoryMappingList MemoryMappingList;
|
|
|
|
typedef struct MemoryRegion MemoryRegion;
|
|
|
|
typedef struct MemoryRegionSection MemoryRegionSection;
|
|
|
|
typedef struct MigrationParams MigrationParams;
|
|
|
|
typedef struct Monitor Monitor;
|
|
|
|
typedef struct MouseTransformInfo MouseTransformInfo;
|
|
|
|
typedef struct MSIMessage MSIMessage;
|
|
|
|
typedef struct NetClientState NetClientState;
|
|
|
|
typedef struct NICInfo NICInfo;
|
|
|
|
typedef struct PcGuestInfo PcGuestInfo;
|
|
|
|
typedef struct PCIBridge PCIBridge;
|
2012-10-23 23:41:52 +00:00
|
|
|
typedef struct PCIBus PCIBus;
|
|
|
|
typedef struct PCIDevice PCIDevice;
|
|
|
|
typedef struct PCIEAERErr PCIEAERErr;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct PCIEAERLog PCIEAERLog;
|
|
|
|
typedef struct PCIEAERMsg PCIEAERMsg;
|
2012-10-23 23:41:52 +00:00
|
|
|
typedef struct PCIEPort PCIEPort;
|
|
|
|
typedef struct PCIESlot PCIESlot;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct PCIExpressDevice PCIExpressDevice;
|
|
|
|
typedef struct PCIExpressHost PCIExpressHost;
|
|
|
|
typedef struct PCIHostState PCIHostState;
|
2012-10-23 23:41:52 +00:00
|
|
|
typedef struct PCMCIACardState PCMCIACardState;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct PixelFormat PixelFormat;
|
|
|
|
typedef struct PropertyInfo PropertyInfo;
|
|
|
|
typedef struct Property Property;
|
|
|
|
typedef struct QEMUBH QEMUBH;
|
|
|
|
typedef struct QemuConsole QemuConsole;
|
|
|
|
typedef struct QEMUFile QEMUFile;
|
|
|
|
typedef struct QEMUMachine QEMUMachine;
|
2012-10-23 23:41:52 +00:00
|
|
|
typedef struct QEMUSGList QEMUSGList;
|
2014-10-10 11:39:04 +00:00
|
|
|
typedef struct QEMUSizedBuffer QEMUSizedBuffer;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct QEMUTimerListGroup QEMUTimerListGroup;
|
|
|
|
typedef struct QEMUTimer QEMUTimer;
|
2013-09-02 08:41:37 +00:00
|
|
|
typedef struct Range Range;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct SerialState SerialState;
|
|
|
|
typedef struct SHPCDevice SHPCDevice;
|
|
|
|
typedef struct SMBusDevice SMBusDevice;
|
|
|
|
typedef struct SSIBus SSIBus;
|
|
|
|
typedef struct uWireSlave uWireSlave;
|
|
|
|
typedef struct VirtIODevice VirtIODevice;
|
|
|
|
typedef struct Visitor Visitor;
|
2012-10-23 23:41:52 +00:00
|
|
|
|
|
|
|
#endif /* QEMU_TYPEDEFS_H */
|