xref: /qemu/qapi/job.json (revision 61a3a5a7)
1bf42508fSKevin Wolf# -*- Mode: Python -*-
2f7160f32SAndrea Bolognani# vim: filetype=python
3bf42508fSKevin Wolf
4bf42508fSKevin Wolf##
54622c706SMarkus Armbruster# = Background jobs
6bf42508fSKevin Wolf##
7bf42508fSKevin Wolf
8bf42508fSKevin Wolf##
9bf42508fSKevin Wolf# @JobType:
10bf42508fSKevin Wolf#
11bf42508fSKevin Wolf# Type of a background job.
12bf42508fSKevin Wolf#
13bf42508fSKevin Wolf# @commit: block commit job type, see "block-commit"
14bf42508fSKevin Wolf#
15bf42508fSKevin Wolf# @stream: block stream job type, see "block-stream"
16bf42508fSKevin Wolf#
17bf42508fSKevin Wolf# @mirror: drive mirror job type, see "drive-mirror"
18bf42508fSKevin Wolf#
19bf42508fSKevin Wolf# @backup: drive backup job type, see "drive-backup"
20bf42508fSKevin Wolf#
213fb588a0SKevin Wolf# @create: image creation job type, see "blockdev-create" (since 3.0)
22e5ab4347SKevin Wolf#
23a937b6aaSMarkus Armbruster# @amend: image options amend job type, see "x-blockdev-amend" (since
24a937b6aaSMarkus Armbruster#     5.1)
25ced914d0SMaxim Levitsky#
26a937b6aaSMarkus Armbruster# @snapshot-load: snapshot load job type, see "snapshot-load" (since
27a937b6aaSMarkus Armbruster#     6.0)
280f0d83a4SDaniel P. Berrangé#
29a937b6aaSMarkus Armbruster# @snapshot-save: snapshot save job type, see "snapshot-save" (since
30a937b6aaSMarkus Armbruster#     6.0)
310f0d83a4SDaniel P. Berrangé#
32a937b6aaSMarkus Armbruster# @snapshot-delete: snapshot delete job type, see "snapshot-delete"
33a937b6aaSMarkus Armbruster#     (since 6.0)
340f0d83a4SDaniel P. Berrangé#
35bf42508fSKevin Wolf# Since: 1.7
36bf42508fSKevin Wolf##
37bf42508fSKevin Wolf{ 'enum': 'JobType',
380f0d83a4SDaniel P. Berrangé  'data': ['commit', 'stream', 'mirror', 'backup', 'create', 'amend',
390f0d83a4SDaniel P. Berrangé           'snapshot-load', 'snapshot-save', 'snapshot-delete'] }
40bf42508fSKevin Wolf
41bf42508fSKevin Wolf##
42bf42508fSKevin Wolf# @JobStatus:
43bf42508fSKevin Wolf#
44bf42508fSKevin Wolf# Indicates the present state of a given job in its lifetime.
45bf42508fSKevin Wolf#
46bf42508fSKevin Wolf# @undefined: Erroneous, default state.  Should not ever be visible.
47bf42508fSKevin Wolf#
48bf42508fSKevin Wolf# @created: The job has been created, but not yet started.
49bf42508fSKevin Wolf#
50bf42508fSKevin Wolf# @running: The job is currently running.
51bf42508fSKevin Wolf#
52a937b6aaSMarkus Armbruster# @paused: The job is running, but paused.  The pause may be requested
53a937b6aaSMarkus Armbruster#     by either the QMP user or by internal processes.
54bf42508fSKevin Wolf#
55a937b6aaSMarkus Armbruster# @ready: The job is running, but is ready for the user to signal
56a937b6aaSMarkus Armbruster#     completion.  This is used for long-running jobs like mirror that
57a937b6aaSMarkus Armbruster#     are designed to run indefinitely.
58bf42508fSKevin Wolf#
59a937b6aaSMarkus Armbruster# @standby: The job is ready, but paused.  This is nearly identical to
60a937b6aaSMarkus Armbruster#     @paused.  The job may return to @ready or otherwise be canceled.
61bf42508fSKevin Wolf#
62a937b6aaSMarkus Armbruster# @waiting: The job is waiting for other jobs in the transaction to
63a937b6aaSMarkus Armbruster#     converge to the waiting state.  This status will likely not be
64a937b6aaSMarkus Armbruster#     visible for the last job in a transaction.
65bf42508fSKevin Wolf#
66a937b6aaSMarkus Armbruster# @pending: The job has finished its work, but has finalization steps
67a937b6aaSMarkus Armbruster#     that it needs to make prior to completing.  These changes will
68a937b6aaSMarkus Armbruster#     require manual intervention via @job-finalize if auto-finalize
69a937b6aaSMarkus Armbruster#     was set to false.  These pending changes may still fail.
70bf42508fSKevin Wolf#
71a937b6aaSMarkus Armbruster# @aborting: The job is in the process of being aborted, and will
72a937b6aaSMarkus Armbruster#     finish with an error.  The job will afterwards report that it is
73a937b6aaSMarkus Armbruster#     @concluded.  This status may not be visible to the management
74a937b6aaSMarkus Armbruster#     process.
75bf42508fSKevin Wolf#
76a937b6aaSMarkus Armbruster# @concluded: The job has finished all work.  If auto-dismiss was set
77a937b6aaSMarkus Armbruster#     to false, the job will remain in the query list until it is
78a937b6aaSMarkus Armbruster#     dismissed via @job-dismiss.
79bf42508fSKevin Wolf#
80a937b6aaSMarkus Armbruster# @null: The job is in the process of being dismantled.  This state
81a937b6aaSMarkus Armbruster#     should not ever be visible externally.
82bf42508fSKevin Wolf#
83bf42508fSKevin Wolf# Since: 2.12
84bf42508fSKevin Wolf##
85bf42508fSKevin Wolf{ 'enum': 'JobStatus',
86bf42508fSKevin Wolf  'data': ['undefined', 'created', 'running', 'paused', 'ready', 'standby',
87bf42508fSKevin Wolf           'waiting', 'pending', 'aborting', 'concluded', 'null' ] }
88bf42508fSKevin Wolf
89bf42508fSKevin Wolf##
90bf42508fSKevin Wolf# @JobVerb:
91bf42508fSKevin Wolf#
92bf42508fSKevin Wolf# Represents command verbs that can be applied to a job.
93bf42508fSKevin Wolf#
94b8a366feSJohn Snow# @cancel: see @job-cancel
95bf42508fSKevin Wolf#
96b8a366feSJohn Snow# @pause: see @job-pause
97bf42508fSKevin Wolf#
98b8a366feSJohn Snow# @resume: see @job-resume
99bf42508fSKevin Wolf#
100bf42508fSKevin Wolf# @set-speed: see @block-job-set-speed
101bf42508fSKevin Wolf#
102b8a366feSJohn Snow# @complete: see @job-complete
103bf42508fSKevin Wolf#
104b8a366feSJohn Snow# @dismiss: see @job-dismiss
105bf42508fSKevin Wolf#
106b8a366feSJohn Snow# @finalize: see @job-finalize
107bf42508fSKevin Wolf#
10861a3a5a7SFiona Ebner# @change: see @block-job-change (since 8.2)
10961a3a5a7SFiona Ebner#
110bf42508fSKevin Wolf# Since: 2.12
111bf42508fSKevin Wolf##
112bf42508fSKevin Wolf{ 'enum': 'JobVerb',
113bf42508fSKevin Wolf  'data': ['cancel', 'pause', 'resume', 'set-speed', 'complete', 'dismiss',
11461a3a5a7SFiona Ebner           'finalize', 'change' ] }
1151dac83f1SKevin Wolf
1161dac83f1SKevin Wolf##
1171dac83f1SKevin Wolf# @JOB_STATUS_CHANGE:
1181dac83f1SKevin Wolf#
1191dac83f1SKevin Wolf# Emitted when a job transitions to a different status.
1201dac83f1SKevin Wolf#
1211dac83f1SKevin Wolf# @id: The job identifier
122a937b6aaSMarkus Armbruster#
1231dac83f1SKevin Wolf# @status: The new job status
1241dac83f1SKevin Wolf#
1250ab1c41dSKevin Wolf# Since: 3.0
1261dac83f1SKevin Wolf##
1271dac83f1SKevin Wolf{ 'event': 'JOB_STATUS_CHANGE',
1281dac83f1SKevin Wolf  'data': { 'id': 'str',
1291dac83f1SKevin Wolf            'status': 'JobStatus' } }
1301a90bc81SKevin Wolf
1311a90bc81SKevin Wolf##
1321a90bc81SKevin Wolf# @job-pause:
1331a90bc81SKevin Wolf#
1341a90bc81SKevin Wolf# Pause an active job.
1351a90bc81SKevin Wolf#
136a937b6aaSMarkus Armbruster# This command returns immediately after marking the active job for
137a937b6aaSMarkus Armbruster# pausing.  Pausing an already paused job is an error.
1381a90bc81SKevin Wolf#
139a937b6aaSMarkus Armbruster# The job will pause as soon as possible, which means transitioning
140a937b6aaSMarkus Armbruster# into the PAUSED state if it was RUNNING, or into STANDBY if it was
141a937b6aaSMarkus Armbruster# READY. The corresponding JOB_STATUS_CHANGE event will be emitted.
1421a90bc81SKevin Wolf#
1431a90bc81SKevin Wolf# Cancelling a paused job automatically resumes it.
1441a90bc81SKevin Wolf#
1451a90bc81SKevin Wolf# @id: The job identifier.
1461a90bc81SKevin Wolf#
1470ab1c41dSKevin Wolf# Since: 3.0
1481a90bc81SKevin Wolf##
1491a90bc81SKevin Wolf{ 'command': 'job-pause', 'data': { 'id': 'str' } }
1501a90bc81SKevin Wolf
1511a90bc81SKevin Wolf##
1521a90bc81SKevin Wolf# @job-resume:
1531a90bc81SKevin Wolf#
1541a90bc81SKevin Wolf# Resume a paused job.
1551a90bc81SKevin Wolf#
156a937b6aaSMarkus Armbruster# This command returns immediately after resuming a paused job.
157a937b6aaSMarkus Armbruster# Resuming an already running job is an error.
1581a90bc81SKevin Wolf#
1591a90bc81SKevin Wolf# @id: The job identifier.
1601a90bc81SKevin Wolf#
1610ab1c41dSKevin Wolf# Since: 3.0
1621a90bc81SKevin Wolf##
1631a90bc81SKevin Wolf{ 'command': 'job-resume', 'data': { 'id': 'str' } }
1641a90bc81SKevin Wolf
1651a90bc81SKevin Wolf##
1661a90bc81SKevin Wolf# @job-cancel:
1671a90bc81SKevin Wolf#
1681a90bc81SKevin Wolf# Instruct an active background job to cancel at the next opportunity.
1691a90bc81SKevin Wolf# This command returns immediately after marking the active job for
1701a90bc81SKevin Wolf# cancellation.
1711a90bc81SKevin Wolf#
172a937b6aaSMarkus Armbruster# The job will cancel as soon as possible and then emit a
173a937b6aaSMarkus Armbruster# JOB_STATUS_CHANGE event.  Usually, the status will change to
174a937b6aaSMarkus Armbruster# ABORTING, but it is possible that a job successfully completes (e.g.
175a937b6aaSMarkus Armbruster# because it was almost done and there was no opportunity to cancel
176a937b6aaSMarkus Armbruster# earlier than completing the job) and transitions to PENDING instead.
1771a90bc81SKevin Wolf#
1781a90bc81SKevin Wolf# @id: The job identifier.
1791a90bc81SKevin Wolf#
1800ab1c41dSKevin Wolf# Since: 3.0
1811a90bc81SKevin Wolf##
1821a90bc81SKevin Wolf{ 'command': 'job-cancel', 'data': { 'id': 'str' } }
1831a90bc81SKevin Wolf
1841a90bc81SKevin Wolf##
1851a90bc81SKevin Wolf# @job-complete:
1861a90bc81SKevin Wolf#
1871a90bc81SKevin Wolf# Manually trigger completion of an active job in the READY state.
1881a90bc81SKevin Wolf#
1891a90bc81SKevin Wolf# @id: The job identifier.
1901a90bc81SKevin Wolf#
1910ab1c41dSKevin Wolf# Since: 3.0
1921a90bc81SKevin Wolf##
1931a90bc81SKevin Wolf{ 'command': 'job-complete', 'data': { 'id': 'str' } }
1941a90bc81SKevin Wolf
1951a90bc81SKevin Wolf##
1961a90bc81SKevin Wolf# @job-dismiss:
1971a90bc81SKevin Wolf#
198a937b6aaSMarkus Armbruster# Deletes a job that is in the CONCLUDED state.  This command only
199a937b6aaSMarkus Armbruster# needs to be run explicitly for jobs that don't have automatic
200a937b6aaSMarkus Armbruster# dismiss enabled.
2011a90bc81SKevin Wolf#
202a937b6aaSMarkus Armbruster# This command will refuse to operate on any job that has not yet
203a937b6aaSMarkus Armbruster# reached its terminal state, JOB_STATUS_CONCLUDED. For jobs that make
204a937b6aaSMarkus Armbruster# use of JOB_READY event, job-cancel or job-complete will still need
205a937b6aaSMarkus Armbruster# to be used as appropriate.
2061a90bc81SKevin Wolf#
2071a90bc81SKevin Wolf# @id: The job identifier.
2081a90bc81SKevin Wolf#
2090ab1c41dSKevin Wolf# Since: 3.0
2101a90bc81SKevin Wolf##
2111a90bc81SKevin Wolf{ 'command': 'job-dismiss', 'data': { 'id': 'str' } }
2121a90bc81SKevin Wolf
2131a90bc81SKevin Wolf##
2141a90bc81SKevin Wolf# @job-finalize:
2151a90bc81SKevin Wolf#
216a937b6aaSMarkus Armbruster# Instructs all jobs in a transaction (or a single job if it is not
217a937b6aaSMarkus Armbruster# part of any transaction) to finalize any graph changes and do any
218a937b6aaSMarkus Armbruster# necessary cleanup.  This command requires that all involved jobs are
219a937b6aaSMarkus Armbruster# in the PENDING state.
2201a90bc81SKevin Wolf#
221a937b6aaSMarkus Armbruster# For jobs in a transaction, instructing one job to finalize will
222a937b6aaSMarkus Armbruster# force ALL jobs in the transaction to finalize, so it is only
223a937b6aaSMarkus Armbruster# necessary to instruct a single member job to finalize.
2241a90bc81SKevin Wolf#
225a937b6aaSMarkus Armbruster# @id: The identifier of any job in the transaction, or of a job that
226a937b6aaSMarkus Armbruster#     is not part of any transaction.
2271a90bc81SKevin Wolf#
2280ab1c41dSKevin Wolf# Since: 3.0
2291a90bc81SKevin Wolf##
2301a90bc81SKevin Wolf{ 'command': 'job-finalize', 'data': { 'id': 'str' } }
231456273b0SKevin Wolf
232456273b0SKevin Wolf##
233456273b0SKevin Wolf# @JobInfo:
234456273b0SKevin Wolf#
235456273b0SKevin Wolf# Information about a job.
236456273b0SKevin Wolf#
237456273b0SKevin Wolf# @id: The job identifier
238456273b0SKevin Wolf#
239456273b0SKevin Wolf# @type: The kind of job that is being performed
240456273b0SKevin Wolf#
241456273b0SKevin Wolf# @status: Current job state/status
242456273b0SKevin Wolf#
243a937b6aaSMarkus Armbruster# @current-progress: Progress made until now.  The unit is arbitrary
244a937b6aaSMarkus Armbruster#     and the value can only meaningfully be used for the ratio of
245456273b0SKevin Wolf#     @current-progress to @total-progress.  The value is
246456273b0SKevin Wolf#     monotonically increasing.
247456273b0SKevin Wolf#
248a937b6aaSMarkus Armbruster# @total-progress: Estimated @current-progress value at the completion
249a937b6aaSMarkus Armbruster#     of the job.  This value can arbitrarily change while the job is
250a937b6aaSMarkus Armbruster#     running, in both directions.
251456273b0SKevin Wolf#
252a937b6aaSMarkus Armbruster# @error: If this field is present, the job failed; if it is still
253a937b6aaSMarkus Armbruster#     missing in the CONCLUDED state, this indicates successful
254a937b6aaSMarkus Armbruster#     completion.
255456273b0SKevin Wolf#
256a937b6aaSMarkus Armbruster#     The value is a human-readable error message to describe the
257a937b6aaSMarkus Armbruster#     reason for the job failure.  It should not be parsed by
258a937b6aaSMarkus Armbruster#     applications.
259456273b0SKevin Wolf#
2600ab1c41dSKevin Wolf# Since: 3.0
261456273b0SKevin Wolf##
262456273b0SKevin Wolf{ 'struct': 'JobInfo',
263456273b0SKevin Wolf  'data': { 'id': 'str', 'type': 'JobType', 'status': 'JobStatus',
264456273b0SKevin Wolf            'current-progress': 'int', 'total-progress': 'int',
265456273b0SKevin Wolf            '*error': 'str' } }
266456273b0SKevin Wolf
267456273b0SKevin Wolf##
268456273b0SKevin Wolf# @query-jobs:
269456273b0SKevin Wolf#
270456273b0SKevin Wolf# Return information about jobs.
271456273b0SKevin Wolf#
272456273b0SKevin Wolf# Returns: a list with a @JobInfo for each active job
273456273b0SKevin Wolf#
2740ab1c41dSKevin Wolf# Since: 3.0
275456273b0SKevin Wolf##
276456273b0SKevin Wolf{ 'command': 'query-jobs', 'returns': ['JobInfo'] }
277