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. */
|
|
|
|
|
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;
|
2015-11-06 19:09:01 +00:00
|
|
|
typedef struct AllwinnerAHCIState AllwinnerAHCIState;
|
2012-10-23 23:41:52 +00:00
|
|
|
typedef struct AudioState AudioState;
|
2016-03-08 04:44:54 +00:00
|
|
|
typedef struct BdrvDirtyBitmap BdrvDirtyBitmap;
|
2016-10-13 21:58:21 +00:00
|
|
|
typedef struct BdrvDirtyBitmapIter BdrvDirtyBitmapIter;
|
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;
|
2015-10-19 15:53:24 +00:00
|
|
|
typedef struct BlockBackendRootState BlockBackendRootState;
|
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;
|
2016-12-07 13:20:22 +00:00
|
|
|
typedef struct Chardev Chardev;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct CompatProperty CompatProperty;
|
2015-10-01 14:29:50 +00:00
|
|
|
typedef struct CPUAddressSpace CPUAddressSpace;
|
2016-02-25 16:43:32 +00:00
|
|
|
typedef struct CPUState CPUState;
|
2015-01-20 11:05:07 +00:00
|
|
|
typedef struct DeviceListener DeviceListener;
|
2015-11-19 12:29:28 +00:00
|
|
|
typedef struct DeviceState DeviceState;
|
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;
|
include/qemu/osdep.h: Don't include qapi/error.h
Commit 57cb38b included qapi/error.h into qemu/osdep.h to get the
Error typedef. Since then, we've moved to include qemu/osdep.h
everywhere. Its file comment explains: "To avoid getting into
possible circular include dependencies, this file should not include
any other QEMU headers, with the exceptions of config-host.h,
compiler.h, os-posix.h and os-win32.h, all of which are doing a
similar job to this file and are under similar constraints."
qapi/error.h doesn't do a similar job, and it doesn't adhere to
similar constraints: it includes qapi-types.h. That's in excess of
100KiB of crap most .c files don't actually need.
Add the typedef to qemu/typedefs.h, and include that instead of
qapi/error.h. Include qapi/error.h in .c files that need it and don't
get it now. Include qapi-types.h in qom/object.h for uint16List.
Update scripts/clean-includes accordingly. Update it further to match
reality: replace config.h by config-target.h, add sysemu/os-posix.h,
sysemu/os-win32.h. Update the list of includes in the qemu/osdep.h
comment quoted above similarly.
This reduces the number of objects depending on qapi/error.h from "all
of them" to less than a third. Unfortunately, the number depending on
qapi-types.h shrinks only a little. More work is needed for that one.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
[Fix compilation without the spice devel packages. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-14 08:01:28 +00:00
|
|
|
typedef struct Error Error;
|
2014-12-11 11:46:36 +00:00
|
|
|
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;
|
2016-02-03 16:28:57 +00:00
|
|
|
typedef struct IsaDma IsaDma;
|
2015-05-21 12:24:16 +00:00
|
|
|
typedef struct LoadStateEntry LoadStateEntry;
|
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;
|
2016-11-22 11:04:52 +00:00
|
|
|
typedef struct MemoryRegionCache MemoryRegionCache;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct MemoryRegionSection MemoryRegionSection;
|
2015-05-21 12:24:14 +00:00
|
|
|
typedef struct MigrationIncomingState MigrationIncomingState;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct MigrationParams MigrationParams;
|
2015-11-05 18:10:40 +00:00
|
|
|
typedef struct MigrationState MigrationState;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct Monitor Monitor;
|
2015-11-19 12:29:28 +00:00
|
|
|
typedef struct MonitorDef MonitorDef;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct MouseTransformInfo MouseTransformInfo;
|
|
|
|
typedef struct MSIMessage MSIMessage;
|
|
|
|
typedef struct NetClientState NetClientState;
|
2015-10-07 03:52:14 +00:00
|
|
|
typedef struct NetFilterState NetFilterState;
|
2014-12-11 11:46:36 +00:00
|
|
|
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;
|
2016-03-09 12:44:19 +00:00
|
|
|
typedef struct PCIHostDeviceAddress PCIHostDeviceAddress;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct PCIHostState PCIHostState;
|
2015-08-07 19:55:46 +00:00
|
|
|
typedef struct PCMachineClass PCMachineClass;
|
2015-11-19 12:29:28 +00:00
|
|
|
typedef struct PCMachineState PCMachineState;
|
2012-10-23 23:41:52 +00:00
|
|
|
typedef struct PCMCIACardState PCMCIACardState;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct PixelFormat PixelFormat;
|
2015-11-05 18:11:02 +00:00
|
|
|
typedef struct PostcopyDiscardState PostcopyDiscardState;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct Property Property;
|
2015-11-19 12:29:28 +00:00
|
|
|
typedef struct PropertyInfo PropertyInfo;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct QEMUBH QEMUBH;
|
|
|
|
typedef struct QemuConsole QemuConsole;
|
|
|
|
typedef struct QEMUFile QEMUFile;
|
2015-09-17 16:25:01 +00:00
|
|
|
typedef struct QemuOpt QemuOpt;
|
|
|
|
typedef struct QemuOpts QemuOpts;
|
|
|
|
typedef struct QemuOptsList QemuOptsList;
|
2012-10-23 23:41:52 +00:00
|
|
|
typedef struct QEMUSGList QEMUSGList;
|
2014-12-11 11:46:36 +00:00
|
|
|
typedef struct QEMUTimer QEMUTimer;
|
2015-11-19 12:29:28 +00:00
|
|
|
typedef struct QEMUTimerListGroup QEMUTimerListGroup;
|
qapi: Convert QType into QAPI built-in enum type
What's more meta than using qapi to define qapi? :)
Convert QType into a full-fledged[*] builtin qapi enum type, so
that a subsequent patch can then use it as the discriminator
type of qapi alternate types. Fortunately, the judicious use of
'prefix' in the qapi definition avoids churn to the spelling of
the enum constants.
To avoid circular definitions, we have to flip the order of
inclusion between "qobject.h" vs. "qapi-types.h". Back in commit
28770e0, we had the latter include the former, so that we could
use 'QObject *' for our implementation of 'any'. But that usage
also works with only a forward declaration, whereas the
definition of QObject requires QType to be a complete type.
[*] The type has to be builtin, rather than declared in
qapi/common.json, because we want to use it for alternates even
when common.json is not included. But since it is the first
builtin enum type, we have to add special cases to qapi-types
and qapi-visit to only emit definitions once, even when two
qapi files are being compiled into the same binary (the way we
already handled builtin list types like 'intList'). We may
need to revisit how multiple qapi files share common types,
but that's a project for another day.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1449033659-25497-4-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-12-02 05:20:47 +00:00
|
|
|
typedef struct QObject QObject;
|
2015-11-05 18:10:32 +00:00
|
|
|
typedef struct RAMBlock RAMBlock;
|
2015-11-19 12:29:28 +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 */
|