xref: /openbmc/qemu/qapi/job.json (revision 560375cff3ccedabf1fe5ca1bc7a31b13fdc68e5)
1# -*- Mode: Python -*-
2# vim: filetype=python
3
4##
5# = Background jobs
6##
7
8##
9# @JobType:
10#
11# Type of a background job.
12#
13# @commit: block commit job type, see "block-commit"
14#
15# @stream: block stream job type, see "block-stream"
16#
17# @mirror: drive mirror job type, see "drive-mirror"
18#
19# @backup: drive backup job type, see "drive-backup"
20#
21# @create: image creation job type, see "blockdev-create" (since 3.0)
22#
23# @amend: image options amend job type, see "x-blockdev-amend" (since
24#     5.1)
25#
26# @snapshot-load: snapshot load job type, see "snapshot-load" (since
27#     6.0)
28#
29# @snapshot-save: snapshot save job type, see "snapshot-save" (since
30#     6.0)
31#
32# @snapshot-delete: snapshot delete job type, see "snapshot-delete"
33#     (since 6.0)
34#
35# Since: 1.7
36##
37{ 'enum': 'JobType',
38  'data': ['commit', 'stream', 'mirror', 'backup', 'create', 'amend',
39           'snapshot-load', 'snapshot-save', 'snapshot-delete'] }
40
41##
42# @JobStatus:
43#
44# Indicates the present state of a given job in its lifetime.
45#
46# @undefined: Erroneous, default state.  Should not ever be visible.
47#
48# @created: The job has been created, but not yet started.
49#
50# @running: The job is currently running.
51#
52# @paused: The job is running, but paused.  The pause may be requested
53#     by either the QMP user or by internal processes.
54#
55# @ready: The job is running, but is ready for the user to signal
56#     completion.  This is used for long-running jobs like mirror that
57#     are designed to run indefinitely.
58#
59# @standby: The job is ready, but paused.  This is nearly identical to
60#     @paused.  The job may return to @ready or otherwise be canceled.
61#
62# @waiting: The job is waiting for other jobs in the transaction to
63#     converge to the waiting state.  This status will likely not be
64#     visible for the last job in a transaction.
65#
66# @pending: The job has finished its work, but has finalization steps
67#     that it needs to make prior to completing.  These changes will
68#     require manual intervention via @job-finalize if auto-finalize
69#     was set to false.  These pending changes may still fail.
70#
71# @aborting: The job is in the process of being aborted, and will
72#     finish with an error.  The job will afterwards report that it is
73#     @concluded.  This status may not be visible to the management
74#     process.
75#
76# @concluded: The job has finished all work.  If auto-dismiss was set
77#     to false, the job will remain in the query list until it is
78#     dismissed via @job-dismiss.
79#
80# @null: The job is in the process of being dismantled.  This state
81#     should not ever be visible externally.
82#
83# Since: 2.12
84##
85{ 'enum': 'JobStatus',
86  'data': ['undefined', 'created', 'running', 'paused', 'ready', 'standby',
87           'waiting', 'pending', 'aborting', 'concluded', 'null' ] }
88
89##
90# @JobVerb:
91#
92# Represents command verbs that can be applied to a job.
93#
94# @cancel: see @job-cancel
95#
96# @pause: see @job-pause
97#
98# @resume: see @job-resume
99#
100# @set-speed: see @block-job-set-speed
101#
102# @complete: see @job-complete
103#
104# @dismiss: see @job-dismiss
105#
106# @finalize: see @job-finalize
107#
108# @change: see @block-job-change (since 8.2)
109#
110# Since: 2.12
111##
112{ 'enum': 'JobVerb',
113  'data': ['cancel', 'pause', 'resume', 'set-speed', 'complete', 'dismiss',
114           'finalize', 'change' ] }
115
116##
117# @JOB_STATUS_CHANGE:
118#
119# Emitted when a job transitions to a different status.
120#
121# @id: The job identifier
122#
123# @status: The new job status
124#
125# Since: 3.0
126##
127{ 'event': 'JOB_STATUS_CHANGE',
128  'data': { 'id': 'str',
129            'status': 'JobStatus' } }
130
131##
132# @job-pause:
133#
134# Pause an active job.
135#
136# This command returns immediately after marking the active job for
137# pausing.  Pausing an already paused job is an error.
138#
139# The job will pause as soon as possible, which means transitioning
140# into the PAUSED state if it was RUNNING, or into STANDBY if it was
141# READY.  The corresponding JOB_STATUS_CHANGE event will be emitted.
142#
143# Cancelling a paused job automatically resumes it.
144#
145# @id: The job identifier.
146#
147# Since: 3.0
148##
149{ 'command': 'job-pause', 'data': { 'id': 'str' } }
150
151##
152# @job-resume:
153#
154# Resume a paused job.
155#
156# This command returns immediately after resuming a paused job.
157# Resuming an already running job is an error.
158#
159# This command also clears the error status for block-jobs (stream,
160# commit, mirror, backup).
161#
162# @id: The job identifier.
163#
164# Since: 3.0
165##
166{ 'command': 'job-resume', 'data': { 'id': 'str' } }
167
168##
169# @job-cancel:
170#
171# Instruct an active background job to cancel at the next opportunity.
172# This command returns immediately after marking the active job for
173# cancellation.
174#
175# The job will cancel as soon as possible and then emit a
176# JOB_STATUS_CHANGE event.  Usually, the status will change to
177# ABORTING, but it is possible that a job successfully completes (e.g.
178# because it was almost done and there was no opportunity to cancel
179# earlier than completing the job) and transitions to PENDING instead.
180#
181# @id: The job identifier.
182#
183# Since: 3.0
184##
185{ 'command': 'job-cancel', 'data': { 'id': 'str' } }
186
187##
188# @job-complete:
189#
190# Manually trigger completion of an active job in the READY or STANDBY
191# state.  Completing the job in any other state is an error.
192#
193# This is supported only for drive mirroring, where it also switches
194# the device to write to the target path only. Note that drive
195# mirroring includes drive-mirror, blockdev-mirror and block-commit
196# job (only in case of "active commit", when the node being commited
197# is used by the guest). The ability to complete is signaled with a
198# BLOCK_JOB_READY event.
199#
200# This command completes an active background block operation
201# synchronously.  The ordering of this command's return with the
202# BLOCK_JOB_COMPLETED event is not defined.  Note that if an I/O error
203# occurs during the processing of this command: 1) the command itself
204# will fail; 2) the error will be processed according to the
205# rerror/werror arguments that were specified when starting the
206# operation.
207#
208# @id: The job identifier.
209#
210# Since: 3.0
211##
212{ 'command': 'job-complete', 'data': { 'id': 'str' } }
213
214##
215# @job-dismiss:
216#
217# Deletes a job that is in the CONCLUDED state.  This command only
218# needs to be run explicitly for jobs that don't have automatic
219# dismiss enabled. In turn, automatic dismiss may be enabled only
220# for jobs that have @auto-dismiss option, which are drive-backup,
221# blockdev-backup, drive-mirror, blockdev-mirror, block-commit and
222# block-stream. @auto-dismiss is enabled by default for these
223# jobs.
224#
225# This command will refuse to operate on any job that has not yet
226# reached its terminal state, JOB_STATUS_CONCLUDED.  For jobs that
227# make use of JOB_READY event, job-cancel or job-complete will still
228# need to be used as appropriate.
229#
230# @id: The job identifier.
231#
232# Since: 3.0
233##
234{ 'command': 'job-dismiss', 'data': { 'id': 'str' } }
235
236##
237# @job-finalize:
238#
239# Instructs all jobs in a transaction (or a single job if it is not
240# part of any transaction) to finalize any graph changes and do any
241# necessary cleanup.  This command requires that all involved jobs are
242# in the PENDING state.
243#
244# For jobs in a transaction, instructing one job to finalize will
245# force ALL jobs in the transaction to finalize, so it is only
246# necessary to instruct a single member job to finalize.
247#
248# The command is applicable only to jobs which have @auto-finalize option
249# and only when this option is set to false.
250#
251# @id: The identifier of any job in the transaction, or of a job that
252#     is not part of any transaction.
253#
254# Since: 3.0
255##
256{ 'command': 'job-finalize', 'data': { 'id': 'str' } }
257
258##
259# @JobInfo:
260#
261# Information about a job.
262#
263# @id: The job identifier
264#
265# @type: The kind of job that is being performed
266#
267# @status: Current job state/status
268#
269# @current-progress: Progress made until now.  The unit is arbitrary
270#     and the value can only meaningfully be used for the ratio of
271#     @current-progress to @total-progress.  The value is
272#     monotonically increasing.
273#
274# @total-progress: Estimated @current-progress value at the completion
275#     of the job.  This value can arbitrarily change while the job is
276#     running, in both directions.
277#
278# @error: If this field is present, the job failed; if it is still
279#     missing in the CONCLUDED state, this indicates successful
280#     completion.
281#
282#     The value is a human-readable error message to describe the
283#     reason for the job failure.  It should not be parsed by
284#     applications.
285#
286# Since: 3.0
287##
288{ 'struct': 'JobInfo',
289  'data': { 'id': 'str', 'type': 'JobType', 'status': 'JobStatus',
290            'current-progress': 'int', 'total-progress': 'int',
291            '*error': 'str' } }
292
293##
294# @query-jobs:
295#
296# Return information about jobs.
297#
298# Returns: a list with a @JobInfo for each active job
299#
300# Since: 3.0
301##
302{ 'command': 'query-jobs', 'returns': ['JobInfo'] }
303