1bf42508fSKevin Wolf# -*- Mode: Python -*- 2bf42508fSKevin Wolf 3bf42508fSKevin Wolf## 4bf42508fSKevin Wolf# == Background jobs 5bf42508fSKevin Wolf## 6bf42508fSKevin Wolf 7bf42508fSKevin Wolf## 8bf42508fSKevin Wolf# @JobType: 9bf42508fSKevin Wolf# 10bf42508fSKevin Wolf# Type of a background job. 11bf42508fSKevin Wolf# 12bf42508fSKevin Wolf# @commit: block commit job type, see "block-commit" 13bf42508fSKevin Wolf# 14bf42508fSKevin Wolf# @stream: block stream job type, see "block-stream" 15bf42508fSKevin Wolf# 16bf42508fSKevin Wolf# @mirror: drive mirror job type, see "drive-mirror" 17bf42508fSKevin Wolf# 18bf42508fSKevin Wolf# @backup: drive backup job type, see "drive-backup" 19bf42508fSKevin Wolf# 203fb588a0SKevin Wolf# @create: image creation job type, see "blockdev-create" (since 3.0) 21e5ab4347SKevin Wolf# 22bf42508fSKevin Wolf# Since: 1.7 23bf42508fSKevin Wolf## 24bf42508fSKevin Wolf{ 'enum': 'JobType', 25e5ab4347SKevin Wolf 'data': ['commit', 'stream', 'mirror', 'backup', 'create'] } 26bf42508fSKevin Wolf 27bf42508fSKevin Wolf## 28bf42508fSKevin Wolf# @JobStatus: 29bf42508fSKevin Wolf# 30bf42508fSKevin Wolf# Indicates the present state of a given job in its lifetime. 31bf42508fSKevin Wolf# 32bf42508fSKevin Wolf# @undefined: Erroneous, default state. Should not ever be visible. 33bf42508fSKevin Wolf# 34bf42508fSKevin Wolf# @created: The job has been created, but not yet started. 35bf42508fSKevin Wolf# 36bf42508fSKevin Wolf# @running: The job is currently running. 37bf42508fSKevin Wolf# 38bf42508fSKevin Wolf# @paused: The job is running, but paused. The pause may be requested by 39bf42508fSKevin Wolf# either the QMP user or by internal processes. 40bf42508fSKevin Wolf# 41bf42508fSKevin Wolf# @ready: The job is running, but is ready for the user to signal completion. 42bf42508fSKevin Wolf# This is used for long-running jobs like mirror that are designed to 43bf42508fSKevin Wolf# run indefinitely. 44bf42508fSKevin Wolf# 45bf42508fSKevin Wolf# @standby: The job is ready, but paused. This is nearly identical to @paused. 46bf42508fSKevin Wolf# The job may return to @ready or otherwise be canceled. 47bf42508fSKevin Wolf# 48bf42508fSKevin Wolf# @waiting: The job is waiting for other jobs in the transaction to converge 49bf42508fSKevin Wolf# to the waiting state. This status will likely not be visible for 50bf42508fSKevin Wolf# the last job in a transaction. 51bf42508fSKevin Wolf# 52bf42508fSKevin Wolf# @pending: The job has finished its work, but has finalization steps that it 53c5b09f3fSJohn Snow# needs to make prior to completing. These changes will require 54c5b09f3fSJohn Snow# manual intervention via @job-finalize if auto-finalize was set to 55c5b09f3fSJohn Snow# false. These pending changes may still fail. 56bf42508fSKevin Wolf# 57bf42508fSKevin Wolf# @aborting: The job is in the process of being aborted, and will finish with 58bf42508fSKevin Wolf# an error. The job will afterwards report that it is @concluded. 59bf42508fSKevin Wolf# This status may not be visible to the management process. 60bf42508fSKevin Wolf# 61c5b09f3fSJohn Snow# @concluded: The job has finished all work. If auto-dismiss was set to false, 62c5b09f3fSJohn Snow# the job will remain in the query list until it is dismissed via 63c5b09f3fSJohn Snow# @job-dismiss. 64bf42508fSKevin Wolf# 65bf42508fSKevin Wolf# @null: The job is in the process of being dismantled. This state should not 66bf42508fSKevin Wolf# ever be visible externally. 67bf42508fSKevin Wolf# 68bf42508fSKevin Wolf# Since: 2.12 69bf42508fSKevin Wolf## 70bf42508fSKevin Wolf{ 'enum': 'JobStatus', 71bf42508fSKevin Wolf 'data': ['undefined', 'created', 'running', 'paused', 'ready', 'standby', 72bf42508fSKevin Wolf 'waiting', 'pending', 'aborting', 'concluded', 'null' ] } 73bf42508fSKevin Wolf 74bf42508fSKevin Wolf## 75bf42508fSKevin Wolf# @JobVerb: 76bf42508fSKevin Wolf# 77bf42508fSKevin Wolf# Represents command verbs that can be applied to a job. 78bf42508fSKevin Wolf# 79*b8a366feSJohn Snow# @cancel: see @job-cancel 80bf42508fSKevin Wolf# 81*b8a366feSJohn Snow# @pause: see @job-pause 82bf42508fSKevin Wolf# 83*b8a366feSJohn Snow# @resume: see @job-resume 84bf42508fSKevin Wolf# 85bf42508fSKevin Wolf# @set-speed: see @block-job-set-speed 86bf42508fSKevin Wolf# 87*b8a366feSJohn Snow# @complete: see @job-complete 88bf42508fSKevin Wolf# 89*b8a366feSJohn Snow# @dismiss: see @job-dismiss 90bf42508fSKevin Wolf# 91*b8a366feSJohn Snow# @finalize: see @job-finalize 92bf42508fSKevin Wolf# 93bf42508fSKevin Wolf# Since: 2.12 94bf42508fSKevin Wolf## 95bf42508fSKevin Wolf{ 'enum': 'JobVerb', 96bf42508fSKevin Wolf 'data': ['cancel', 'pause', 'resume', 'set-speed', 'complete', 'dismiss', 97bf42508fSKevin Wolf 'finalize' ] } 981dac83f1SKevin Wolf 991dac83f1SKevin Wolf## 1001dac83f1SKevin Wolf# @JOB_STATUS_CHANGE: 1011dac83f1SKevin Wolf# 1021dac83f1SKevin Wolf# Emitted when a job transitions to a different status. 1031dac83f1SKevin Wolf# 1041dac83f1SKevin Wolf# @id: The job identifier 1051dac83f1SKevin Wolf# @status: The new job status 1061dac83f1SKevin Wolf# 1071dac83f1SKevin Wolf# Since: 2.13 1081dac83f1SKevin Wolf## 1091dac83f1SKevin Wolf{ 'event': 'JOB_STATUS_CHANGE', 1101dac83f1SKevin Wolf 'data': { 'id': 'str', 1111dac83f1SKevin Wolf 'status': 'JobStatus' } } 1121a90bc81SKevin Wolf 1131a90bc81SKevin Wolf## 1141a90bc81SKevin Wolf# @job-pause: 1151a90bc81SKevin Wolf# 1161a90bc81SKevin Wolf# Pause an active job. 1171a90bc81SKevin Wolf# 1181a90bc81SKevin Wolf# This command returns immediately after marking the active job for pausing. 1191a90bc81SKevin Wolf# Pausing an already paused job is an error. 1201a90bc81SKevin Wolf# 1211a90bc81SKevin Wolf# The job will pause as soon as possible, which means transitioning into the 1221a90bc81SKevin Wolf# PAUSED state if it was RUNNING, or into STANDBY if it was READY. The 1231a90bc81SKevin Wolf# corresponding JOB_STATUS_CHANGE event will be emitted. 1241a90bc81SKevin Wolf# 1251a90bc81SKevin Wolf# Cancelling a paused job automatically resumes it. 1261a90bc81SKevin Wolf# 1271a90bc81SKevin Wolf# @id: The job identifier. 1281a90bc81SKevin Wolf# 1291a90bc81SKevin Wolf# Since: 2.13 1301a90bc81SKevin Wolf## 1311a90bc81SKevin Wolf{ 'command': 'job-pause', 'data': { 'id': 'str' } } 1321a90bc81SKevin Wolf 1331a90bc81SKevin Wolf## 1341a90bc81SKevin Wolf# @job-resume: 1351a90bc81SKevin Wolf# 1361a90bc81SKevin Wolf# Resume a paused job. 1371a90bc81SKevin Wolf# 1381a90bc81SKevin Wolf# This command returns immediately after resuming a paused job. Resuming an 1391a90bc81SKevin Wolf# already running job is an error. 1401a90bc81SKevin Wolf# 1411a90bc81SKevin Wolf# @id : The job identifier. 1421a90bc81SKevin Wolf# 1431a90bc81SKevin Wolf# Since: 2.13 1441a90bc81SKevin Wolf## 1451a90bc81SKevin Wolf{ 'command': 'job-resume', 'data': { 'id': 'str' } } 1461a90bc81SKevin Wolf 1471a90bc81SKevin Wolf## 1481a90bc81SKevin Wolf# @job-cancel: 1491a90bc81SKevin Wolf# 1501a90bc81SKevin Wolf# Instruct an active background job to cancel at the next opportunity. 1511a90bc81SKevin Wolf# This command returns immediately after marking the active job for 1521a90bc81SKevin Wolf# cancellation. 1531a90bc81SKevin Wolf# 1541a90bc81SKevin Wolf# The job will cancel as soon as possible and then emit a JOB_STATUS_CHANGE 1551a90bc81SKevin Wolf# event. Usually, the status will change to ABORTING, but it is possible that 1561a90bc81SKevin Wolf# a job successfully completes (e.g. because it was almost done and there was 1571a90bc81SKevin Wolf# no opportunity to cancel earlier than completing the job) and transitions to 1581a90bc81SKevin Wolf# PENDING instead. 1591a90bc81SKevin Wolf# 1601a90bc81SKevin Wolf# @id: The job identifier. 1611a90bc81SKevin Wolf# 1621a90bc81SKevin Wolf# Since: 2.13 1631a90bc81SKevin Wolf## 1641a90bc81SKevin Wolf{ 'command': 'job-cancel', 'data': { 'id': 'str' } } 1651a90bc81SKevin Wolf 1661a90bc81SKevin Wolf 1671a90bc81SKevin Wolf## 1681a90bc81SKevin Wolf# @job-complete: 1691a90bc81SKevin Wolf# 1701a90bc81SKevin Wolf# Manually trigger completion of an active job in the READY state. 1711a90bc81SKevin Wolf# 1721a90bc81SKevin Wolf# @id: The job identifier. 1731a90bc81SKevin Wolf# 1741a90bc81SKevin Wolf# Since: 2.13 1751a90bc81SKevin Wolf## 1761a90bc81SKevin Wolf{ 'command': 'job-complete', 'data': { 'id': 'str' } } 1771a90bc81SKevin Wolf 1781a90bc81SKevin Wolf## 1791a90bc81SKevin Wolf# @job-dismiss: 1801a90bc81SKevin Wolf# 1811a90bc81SKevin Wolf# Deletes a job that is in the CONCLUDED state. This command only needs to be 1821a90bc81SKevin Wolf# run explicitly for jobs that don't have automatic dismiss enabled. 1831a90bc81SKevin Wolf# 1841a90bc81SKevin Wolf# This command will refuse to operate on any job that has not yet reached its 1851a90bc81SKevin Wolf# terminal state, JOB_STATUS_CONCLUDED. For jobs that make use of JOB_READY 1861a90bc81SKevin Wolf# event, job-cancel or job-complete will still need to be used as appropriate. 1871a90bc81SKevin Wolf# 1881a90bc81SKevin Wolf# @id: The job identifier. 1891a90bc81SKevin Wolf# 1901a90bc81SKevin Wolf# Since: 2.13 1911a90bc81SKevin Wolf## 1921a90bc81SKevin Wolf{ 'command': 'job-dismiss', 'data': { 'id': 'str' } } 1931a90bc81SKevin Wolf 1941a90bc81SKevin Wolf## 1951a90bc81SKevin Wolf# @job-finalize: 1961a90bc81SKevin Wolf# 1971a90bc81SKevin Wolf# Instructs all jobs in a transaction (or a single job if it is not part of any 1981a90bc81SKevin Wolf# transaction) to finalize any graph changes and do any necessary cleanup. This 1991a90bc81SKevin Wolf# command requires that all involved jobs are in the PENDING state. 2001a90bc81SKevin Wolf# 2011a90bc81SKevin Wolf# For jobs in a transaction, instructing one job to finalize will force 2021a90bc81SKevin Wolf# ALL jobs in the transaction to finalize, so it is only necessary to instruct 2031a90bc81SKevin Wolf# a single member job to finalize. 2041a90bc81SKevin Wolf# 2051a90bc81SKevin Wolf# @id: The identifier of any job in the transaction, or of a job that is not 2061a90bc81SKevin Wolf# part of any transaction. 2071a90bc81SKevin Wolf# 2081a90bc81SKevin Wolf# Since: 2.13 2091a90bc81SKevin Wolf## 2101a90bc81SKevin Wolf{ 'command': 'job-finalize', 'data': { 'id': 'str' } } 211456273b0SKevin Wolf 212456273b0SKevin Wolf## 213456273b0SKevin Wolf# @JobInfo: 214456273b0SKevin Wolf# 215456273b0SKevin Wolf# Information about a job. 216456273b0SKevin Wolf# 217456273b0SKevin Wolf# @id: The job identifier 218456273b0SKevin Wolf# 219456273b0SKevin Wolf# @type: The kind of job that is being performed 220456273b0SKevin Wolf# 221456273b0SKevin Wolf# @status: Current job state/status 222456273b0SKevin Wolf# 223456273b0SKevin Wolf# @current-progress: Progress made until now. The unit is arbitrary and the 224456273b0SKevin Wolf# value can only meaningfully be used for the ratio of 225456273b0SKevin Wolf# @current-progress to @total-progress. The value is 226456273b0SKevin Wolf# monotonically increasing. 227456273b0SKevin Wolf# 228456273b0SKevin Wolf# @total-progress: Estimated @current-progress value at the completion of 229456273b0SKevin Wolf# the job. This value can arbitrarily change while the 230456273b0SKevin Wolf# job is running, in both directions. 231456273b0SKevin Wolf# 232456273b0SKevin Wolf# @error: If this field is present, the job failed; if it is 233456273b0SKevin Wolf# still missing in the CONCLUDED state, this indicates 234456273b0SKevin Wolf# successful completion. 235456273b0SKevin Wolf# 236456273b0SKevin Wolf# The value is a human-readable error message to describe 237456273b0SKevin Wolf# the reason for the job failure. It should not be parsed 238456273b0SKevin Wolf# by applications. 239456273b0SKevin Wolf# 240456273b0SKevin Wolf# Since: 2.13 241456273b0SKevin Wolf## 242456273b0SKevin Wolf{ 'struct': 'JobInfo', 243456273b0SKevin Wolf 'data': { 'id': 'str', 'type': 'JobType', 'status': 'JobStatus', 244456273b0SKevin Wolf 'current-progress': 'int', 'total-progress': 'int', 245456273b0SKevin Wolf '*error': 'str' } } 246456273b0SKevin Wolf 247456273b0SKevin Wolf## 248456273b0SKevin Wolf# @query-jobs: 249456273b0SKevin Wolf# 250456273b0SKevin Wolf# Return information about jobs. 251456273b0SKevin Wolf# 252456273b0SKevin Wolf# Returns: a list with a @JobInfo for each active job 253456273b0SKevin Wolf# 254456273b0SKevin Wolf# Since: 2.13 255456273b0SKevin Wolf## 256456273b0SKevin Wolf{ 'command': 'query-jobs', 'returns': ['JobInfo'] } 257