target/arm: Fill in VL for tbflags when SME enabled and SVE disabled
[qemu/ar7.git] / include / block / blockjob.h
blob6525e16fd53d6a5c01aed389a47a92cb1c11c63d
1 /*
2 * Declarations for long-running block device operations
4 * Copyright (c) 2011 IBM Corp.
5 * Copyright (c) 2012 Red Hat, Inc.
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
26 #ifndef BLOCKJOB_H
27 #define BLOCKJOB_H
29 #include "qemu/job.h"
30 #include "block/block.h"
31 #include "qemu/ratelimit.h"
33 #define BLOCK_JOB_SLICE_TIME 100000000ULL /* ns */
35 typedef struct BlockJobDriver BlockJobDriver;
37 /**
38 * BlockJob:
40 * Long-running operation on a BlockDriverState.
42 typedef struct BlockJob {
43 /** Data belonging to the generic Job infrastructure */
44 Job job;
46 /** Status that is published by the query-block-jobs QMP API */
47 BlockDeviceIoStatus iostatus;
49 /** Speed that was set with @block_job_set_speed. */
50 int64_t speed;
52 /** Rate limiting data structure for implementing @speed. */
53 RateLimit limit;
55 /** Block other operations when block job is running */
56 Error *blocker;
58 /** Called when a cancelled job is finalised. */
59 Notifier finalize_cancelled_notifier;
61 /** Called when a successfully completed job is finalised. */
62 Notifier finalize_completed_notifier;
64 /** Called when the job transitions to PENDING */
65 Notifier pending_notifier;
67 /** Called when the job transitions to READY */
68 Notifier ready_notifier;
70 /** Called when the job coroutine yields or terminates */
71 Notifier idle_notifier;
73 /** BlockDriverStates that are involved in this block job */
74 GSList *nodes;
75 } BlockJob;
78 * Global state (GS) API. These functions run under the BQL.
80 * See include/block/block-global-state.h for more information about
81 * the GS API.
84 /**
85 * block_job_next:
86 * @job: A block job, or %NULL.
88 * Get the next element from the list of block jobs after @job, or the
89 * first one if @job is %NULL.
91 * Returns the requested job, or %NULL if there are no more jobs left.
93 BlockJob *block_job_next(BlockJob *job);
95 /**
96 * block_job_get:
97 * @id: The id of the block job.
99 * Get the block job identified by @id (which must not be %NULL).
101 * Returns the requested job, or %NULL if it doesn't exist.
103 BlockJob *block_job_get(const char *id);
106 * block_job_add_bdrv:
107 * @job: A block job
108 * @name: The name to assign to the new BdrvChild
109 * @bs: A BlockDriverState that is involved in @job
110 * @perm, @shared_perm: Permissions to request on the node
112 * Add @bs to the list of BlockDriverState that are involved in
113 * @job. This means that all operations will be blocked on @bs while
114 * @job exists.
116 int block_job_add_bdrv(BlockJob *job, const char *name, BlockDriverState *bs,
117 uint64_t perm, uint64_t shared_perm, Error **errp);
120 * block_job_remove_all_bdrv:
121 * @job: The block job
123 * Remove all BlockDriverStates from the list of nodes that are involved in the
124 * job. This removes the blockers added with block_job_add_bdrv().
126 void block_job_remove_all_bdrv(BlockJob *job);
129 * block_job_has_bdrv:
130 * @job: The block job
132 * Searches for @bs in the list of nodes that are involved in the
133 * job.
135 bool block_job_has_bdrv(BlockJob *job, BlockDriverState *bs);
138 * block_job_set_speed:
139 * @job: The job to set the speed for.
140 * @speed: The new value
141 * @errp: Error object.
143 * Set a rate-limiting parameter for the job; the actual meaning may
144 * vary depending on the job type.
146 bool block_job_set_speed(BlockJob *job, int64_t speed, Error **errp);
149 * block_job_query:
150 * @job: The job to get information about.
152 * Return information about a job.
154 BlockJobInfo *block_job_query(BlockJob *job, Error **errp);
157 * block_job_iostatus_reset:
158 * @job: The job whose I/O status should be reset.
160 * Reset I/O status on @job and on BlockDriverState objects it uses,
161 * other than job->blk.
163 void block_job_iostatus_reset(BlockJob *job);
166 * block_job_get_aio_context:
168 * Returns aio context associated with a block job.
170 AioContext *block_job_get_aio_context(BlockJob *job);
174 * Common functions that are neither I/O nor Global State.
176 * See include/block/block-common.h for more information about
177 * the Common API.
181 * block_job_is_internal:
182 * @job: The job to determine if it is user-visible or not.
184 * Returns true if the job should not be visible to the management layer.
186 bool block_job_is_internal(BlockJob *job);
189 * block_job_driver:
191 * Returns the driver associated with a block job.
193 const BlockJobDriver *block_job_driver(BlockJob *job);
195 #endif