2012-10-24 01:41:52 +02:00
|
|
|
#ifndef QEMU_TYPEDEFS_H
|
|
|
|
#define QEMU_TYPEDEFS_H
|
|
|
|
|
2019-08-12 07:23:41 +02:00
|
|
|
/*
|
|
|
|
* This header is for selectively avoiding #include just to get a
|
|
|
|
* typedef name.
|
|
|
|
*
|
|
|
|
* Declaring a typedef name in its "obvious" place can result in
|
|
|
|
* inclusion cycles, in particular for complete struct and union
|
|
|
|
* types that need more types for their members. It can also result
|
|
|
|
* in headers pulling in many more headers, slowing down builds.
|
|
|
|
*
|
|
|
|
* You can break such cycles and unwanted dependencies by declaring
|
|
|
|
* the typedef name here.
|
|
|
|
*
|
|
|
|
* For struct types used in only a few headers, judicious use of the
|
|
|
|
* struct tag instead of the typedef name is commonly preferable.
|
|
|
|
*/
|
2012-10-24 01:41:52 +02:00
|
|
|
|
2019-08-12 07:23:41 +02:00
|
|
|
/*
|
|
|
|
* Incomplete struct types
|
|
|
|
* Please keep this list in case-insensitive alphabetical order.
|
|
|
|
*/
|
2022-11-30 14:56:40 +01:00
|
|
|
typedef struct AccelState AccelState;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct AdapterInfo AdapterInfo;
|
2013-04-09 11:10:27 +02:00
|
|
|
typedef struct AddressSpace AddressSpace;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct AioContext AioContext;
|
2020-04-29 15:59:49 +02:00
|
|
|
typedef struct Aml Aml;
|
2019-02-27 14:24:05 +01:00
|
|
|
typedef struct AnnounceTimer AnnounceTimer;
|
2022-02-14 17:15:16 +01:00
|
|
|
typedef struct ArchCPU ArchCPU;
|
2016-03-08 05:44:54 +01:00
|
|
|
typedef struct BdrvDirtyBitmap BdrvDirtyBitmap;
|
2016-10-13 23:58:21 +02: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 13:59:04 +02:00
|
|
|
typedef struct BlockBackend BlockBackend;
|
2015-10-19 17:53:24 +02:00
|
|
|
typedef struct BlockBackendRootState BlockBackendRootState;
|
2012-10-24 01:41:52 +02:00
|
|
|
typedef struct BlockDriverState BlockDriverState;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct BusClass BusClass;
|
|
|
|
typedef struct BusState BusState;
|
2016-12-07 14:20:22 +01:00
|
|
|
typedef struct Chardev Chardev;
|
2021-01-28 12:41:21 +01:00
|
|
|
typedef struct Clock Clock;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct CompatProperty CompatProperty;
|
2018-02-03 16:39:32 +01:00
|
|
|
typedef struct CoMutex CoMutex;
|
2020-05-05 09:00:30 +02:00
|
|
|
typedef struct ConfidentialGuestSupport ConfidentialGuestSupport;
|
2015-10-01 16:29:50 +02:00
|
|
|
typedef struct CPUAddressSpace CPUAddressSpace;
|
2022-02-07 13:35:58 +01:00
|
|
|
typedef struct CPUArchState CPUArchState;
|
2022-08-15 22:13:05 +02:00
|
|
|
typedef struct CPUJumpCache CPUJumpCache;
|
2016-02-25 17:43:32 +01:00
|
|
|
typedef struct CPUState CPUState;
|
2022-08-20 00:49:41 +02:00
|
|
|
typedef struct CPUTLBEntryFull CPUTLBEntryFull;
|
2015-01-20 12:05:07 +01:00
|
|
|
typedef struct DeviceListener DeviceListener;
|
2015-11-19 13:29:28 +01:00
|
|
|
typedef struct DeviceState DeviceState;
|
2017-04-21 11:16:25 +02:00
|
|
|
typedef struct DirtyBitmapSnapshot DirtyBitmapSnapshot;
|
2012-10-24 01:41:52 +02:00
|
|
|
typedef struct DisplayChangeListener DisplayChangeListener;
|
2014-12-11 12:46:36 +01: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 09:01:28 +01:00
|
|
|
typedef struct Error Error;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct EventNotifier EventNotifier;
|
2017-09-21 12:34:00 +02:00
|
|
|
typedef struct FlatView FlatView;
|
2017-07-14 11:40:08 +02:00
|
|
|
typedef struct FWCfgEntry FWCfgEntry;
|
2014-12-22 13:11:35 +01:00
|
|
|
typedef struct FWCfgIoState FWCfgIoState;
|
|
|
|
typedef struct FWCfgMemState FWCfgMemState;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct FWCfgState FWCfgState;
|
2019-08-12 07:23:54 +02:00
|
|
|
typedef struct HostMemoryBackend HostMemoryBackend;
|
2013-08-03 00:18:51 +02:00
|
|
|
typedef struct I2CBus I2CBus;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct I2SCodec I2SCodec;
|
2018-11-15 22:17:51 +01:00
|
|
|
typedef struct IOMMUMemoryRegion IOMMUMemoryRegion;
|
2012-10-24 01:41:52 +02:00
|
|
|
typedef struct ISABus ISABus;
|
|
|
|
typedef struct ISADevice ISADevice;
|
2016-02-03 17:28:57 +01:00
|
|
|
typedef struct IsaDma IsaDma;
|
2020-12-11 18:11:48 +01:00
|
|
|
typedef struct JSONWriter JSONWriter;
|
2014-12-11 12:46:36 +01: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 12:04:52 +01:00
|
|
|
typedef struct MemoryRegionCache MemoryRegionCache;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct MemoryRegionSection MemoryRegionSection;
|
2015-05-21 14:24:14 +02:00
|
|
|
typedef struct MigrationIncomingState MigrationIncomingState;
|
2015-11-05 19:10:40 +01:00
|
|
|
typedef struct MigrationState MigrationState;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct Monitor Monitor;
|
2015-11-19 13:29:28 +01:00
|
|
|
typedef struct MonitorDef MonitorDef;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct MSIMessage MSIMessage;
|
|
|
|
typedef struct NetClientState NetClientState;
|
2015-10-07 05:52:14 +02:00
|
|
|
typedef struct NetFilterState NetFilterState;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct NICInfo NICInfo;
|
2018-11-15 22:17:52 +01:00
|
|
|
typedef struct NodeInfo NodeInfo;
|
2017-08-29 17:30:20 +02:00
|
|
|
typedef struct NumaNodeMem NumaNodeMem;
|
2020-05-04 13:56:54 +02:00
|
|
|
typedef struct Object Object;
|
2018-11-06 11:23:30 +01:00
|
|
|
typedef struct ObjectClass ObjectClass;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct PCIBridge PCIBridge;
|
2012-10-24 01:41:52 +02:00
|
|
|
typedef struct PCIBus PCIBus;
|
|
|
|
typedef struct PCIDevice PCIDevice;
|
|
|
|
typedef struct PCIEAERErr PCIEAERErr;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct PCIEAERLog PCIEAERLog;
|
|
|
|
typedef struct PCIEAERMsg PCIEAERMsg;
|
2022-02-17 18:44:50 +01:00
|
|
|
typedef struct PCIESriovPF PCIESriovPF;
|
|
|
|
typedef struct PCIESriovVF PCIESriovVF;
|
2012-10-24 01:41:52 +02:00
|
|
|
typedef struct PCIEPort PCIEPort;
|
|
|
|
typedef struct PCIESlot PCIESlot;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct PCIExpressDevice PCIExpressDevice;
|
|
|
|
typedef struct PCIExpressHost PCIExpressHost;
|
2016-03-09 13:44:19 +01:00
|
|
|
typedef struct PCIHostDeviceAddress PCIHostDeviceAddress;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct PCIHostState PCIHostState;
|
2023-01-09 18:23:22 +01:00
|
|
|
typedef struct PICCommonState PICCommonState;
|
2015-11-05 19:11:02 +01:00
|
|
|
typedef struct PostcopyDiscardState PostcopyDiscardState;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct Property Property;
|
2015-11-19 13:29:28 +01:00
|
|
|
typedef struct PropertyInfo PropertyInfo;
|
2018-11-15 22:17:51 +01:00
|
|
|
typedef struct QBool QBool;
|
|
|
|
typedef struct QDict QDict;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct QEMUBH QEMUBH;
|
|
|
|
typedef struct QemuConsole QemuConsole;
|
|
|
|
typedef struct QEMUFile QEMUFile;
|
2018-02-03 16:39:32 +01:00
|
|
|
typedef struct QemuLockable QemuLockable;
|
|
|
|
typedef struct QemuMutex QemuMutex;
|
2015-09-17 18:25:01 +02:00
|
|
|
typedef struct QemuOpt QemuOpt;
|
|
|
|
typedef struct QemuOpts QemuOpts;
|
|
|
|
typedef struct QemuOptsList QemuOptsList;
|
2012-10-24 01:41:52 +02:00
|
|
|
typedef struct QEMUSGList QEMUSGList;
|
2018-11-15 22:17:51 +01:00
|
|
|
typedef struct QemuSpin QemuSpin;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct QEMUTimer QEMUTimer;
|
2015-11-19 13:29:28 +01:00
|
|
|
typedef struct QEMUTimerListGroup QEMUTimerListGroup;
|
2018-02-01 12:18:34 +01:00
|
|
|
typedef struct QList QList;
|
2017-06-26 19:25:14 +02:00
|
|
|
typedef struct QNull QNull;
|
2018-02-01 12:18:34 +01:00
|
|
|
typedef struct QNum QNum;
|
|
|
|
typedef struct QObject QObject;
|
|
|
|
typedef struct QString QString;
|
2015-11-05 19:10:32 +01:00
|
|
|
typedef struct RAMBlock RAMBlock;
|
2015-11-19 13:29:28 +01:00
|
|
|
typedef struct Range Range;
|
2020-12-11 18:11:48 +01:00
|
|
|
typedef struct ReservedRegion ReservedRegion;
|
2020-07-13 22:04:10 +02:00
|
|
|
typedef struct SavedIOTLB SavedIOTLB;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct SHPCDevice SHPCDevice;
|
|
|
|
typedef struct SSIBus SSIBus;
|
2021-02-13 14:03:12 +01:00
|
|
|
typedef struct TranslationBlock TranslationBlock;
|
2014-12-11 12:46:36 +01:00
|
|
|
typedef struct VirtIODevice VirtIODevice;
|
|
|
|
typedef struct Visitor Visitor;
|
2019-08-12 07:23:58 +02:00
|
|
|
typedef struct VMChangeStateEntry VMChangeStateEntry;
|
2019-08-12 07:23:44 +02:00
|
|
|
typedef struct VMStateDescription VMStateDescription;
|
2022-08-11 14:10:54 +02:00
|
|
|
typedef struct DumpState DumpState;
|
2022-11-09 23:21:23 +01:00
|
|
|
typedef struct GraphicHwOps GraphicHwOps;
|
|
|
|
typedef struct QEMUCursor QEMUCursor;
|
2019-08-12 07:23:41 +02:00
|
|
|
|
2019-08-12 07:23:42 +02:00
|
|
|
/*
|
|
|
|
* Pointer types
|
|
|
|
* Such typedefs should be limited to cases where the typedef's users
|
|
|
|
* are oblivious of its "pointer-ness".
|
|
|
|
* Please keep this list in case-insensitive alphabetical order.
|
|
|
|
*/
|
|
|
|
typedef struct IRQState *qemu_irq;
|
|
|
|
|
2019-08-12 07:23:41 +02:00
|
|
|
/*
|
|
|
|
* Function types
|
|
|
|
*/
|
2017-06-14 10:34:34 +02:00
|
|
|
typedef void SaveStateHandler(QEMUFile *f, void *opaque);
|
|
|
|
typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
|
2019-08-12 07:23:42 +02:00
|
|
|
typedef void (*qemu_irq_handler)(void *opaque, int n, int level);
|
2012-10-24 01:41:52 +02:00
|
|
|
|
|
|
|
#endif /* QEMU_TYPEDEFS_H */
|