mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
block: Introduce BlockBackendPublic
Some features, like I/O throttling, are implemented outside block-backend.c, but still want to keep information in BlockBackend, e.g. list entries that allow keeping a list of BlockBackends. In order to avoid exposing the whole struct layout in the public header file, this patch introduces an embedded public struct where such information can be added and a pair of functions to convert between BlockBackend and BlockBackendPublic. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Eric Blake <eblake@redhat.com> Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
a5614993d7
commit
f2cd875d54
2 changed files with 27 additions and 0 deletions
|
@ -34,6 +34,7 @@ struct BlockBackend {
|
|||
DriveInfo *legacy_dinfo; /* null unless created by drive_new() */
|
||||
QTAILQ_ENTRY(BlockBackend) link; /* for block_backends */
|
||||
QTAILQ_ENTRY(BlockBackend) monitor_link; /* for monitor_block_backends */
|
||||
BlockBackendPublic public;
|
||||
|
||||
void *dev; /* attached device model, if any */
|
||||
/* TODO change to DeviceState when all users are qdevified */
|
||||
|
@ -410,6 +411,22 @@ BlockBackend *blk_by_legacy_dinfo(DriveInfo *dinfo)
|
|||
abort();
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a pointer to the publicly accessible fields of @blk.
|
||||
*/
|
||||
BlockBackendPublic *blk_get_public(BlockBackend *blk)
|
||||
{
|
||||
return &blk->public;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a BlockBackend given the associated @public fields.
|
||||
*/
|
||||
BlockBackend *blk_by_public(BlockBackendPublic *public)
|
||||
{
|
||||
return container_of(public, BlockBackend, public);
|
||||
}
|
||||
|
||||
/*
|
||||
* Disassociates the currently associated BlockDriverState from @blk.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue