mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
include/sysemu/block-backend: split header into I/O and global state (GS) API
Similarly to the previous patches, split block-backend.h in block-backend-io.h and block-backend-global-state.h In addition, remove "block/block.h" include as it seems it is not necessary anymore, together with "qemu/iov.h" block-backend-common.h contains the structures shared between the two headers, and the functions that can't be categorized as I/O or global state. Assertions are added in the next patch. Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Message-Id: <20220303151616.325444-8-eesposit@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
8cc5882c7f
commit
a2c4c3b19b
5 changed files with 368 additions and 269 deletions
84
include/sysemu/block-backend-common.h
Normal file
84
include/sysemu/block-backend-common.h
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* QEMU Block backends
|
||||
*
|
||||
* Copyright (C) 2014-2016 Red Hat, Inc.
|
||||
*
|
||||
* Authors:
|
||||
* Markus Armbruster <armbru@redhat.com>,
|
||||
*
|
||||
* This work is licensed under the terms of the GNU LGPL, version 2.1
|
||||
* or later. See the COPYING.LIB file in the top-level directory.
|
||||
*/
|
||||
|
||||
#ifndef BLOCK_BACKEND_COMMON_H
|
||||
#define BLOCK_BACKEND_COMMON_H
|
||||
|
||||
#include "qemu/iov.h"
|
||||
#include "block/throttle-groups.h"
|
||||
|
||||
/*
|
||||
* TODO Have to include block/block.h for a bunch of block layer
|
||||
* types. Unfortunately, this pulls in the whole BlockDriverState
|
||||
* API, which we don't want used by many BlockBackend users. Some of
|
||||
* the types belong here, and the rest should be split into a common
|
||||
* header and one for the BlockDriverState API.
|
||||
*/
|
||||
#include "block/block.h"
|
||||
|
||||
/* Callbacks for block device models */
|
||||
typedef struct BlockDevOps {
|
||||
/*
|
||||
* Runs when virtual media changed (monitor commands eject, change)
|
||||
* Argument load is true on load and false on eject.
|
||||
* Beware: doesn't run when a host device's physical media
|
||||
* changes. Sure would be useful if it did.
|
||||
* Device models with removable media must implement this callback.
|
||||
*/
|
||||
void (*change_media_cb)(void *opaque, bool load, Error **errp);
|
||||
/*
|
||||
* Runs when an eject request is issued from the monitor, the tray
|
||||
* is closed, and the medium is locked.
|
||||
* Device models that do not implement is_medium_locked will not need
|
||||
* this callback. Device models that can lock the medium or tray might
|
||||
* want to implement the callback and unlock the tray when "force" is
|
||||
* true, even if they do not support eject requests.
|
||||
*/
|
||||
void (*eject_request_cb)(void *opaque, bool force);
|
||||
/*
|
||||
* Is the virtual tray open?
|
||||
* Device models implement this only when the device has a tray.
|
||||
*/
|
||||
bool (*is_tray_open)(void *opaque);
|
||||
/*
|
||||
* Is the virtual medium locked into the device?
|
||||
* Device models implement this only when device has such a lock.
|
||||
*/
|
||||
bool (*is_medium_locked)(void *opaque);
|
||||
/*
|
||||
* Runs when the size changed (e.g. monitor command block_resize)
|
||||
*/
|
||||
void (*resize_cb)(void *opaque);
|
||||
/*
|
||||
* Runs when the backend receives a drain request.
|
||||
*/
|
||||
void (*drained_begin)(void *opaque);
|
||||
/*
|
||||
* Runs when the backend's last drain request ends.
|
||||
*/
|
||||
void (*drained_end)(void *opaque);
|
||||
/*
|
||||
* Is the device still busy?
|
||||
*/
|
||||
bool (*drained_poll)(void *opaque);
|
||||
} BlockDevOps;
|
||||
|
||||
/*
|
||||
* This struct is embedded in (the private) BlockBackend struct and contains
|
||||
* fields that must be public. This is in particular for QLIST_ENTRY() and
|
||||
* friends so that BlockBackends can be kept in lists outside block-backend.c
|
||||
*/
|
||||
typedef struct BlockBackendPublic {
|
||||
ThrottleGroupMember throttle_group_member;
|
||||
} BlockBackendPublic;
|
||||
|
||||
#endif /* BLOCK_BACKEND_COMMON_H */
|
Loading…
Add table
Add a link
Reference in a new issue