xref: /openbmc/qemu/qapi/migration.json (revision 0d70c5aa1bbfb0f5099d53d6e084337a8246cc0c)
1# -*- Mode: Python -*-
2# vim: filetype=python
3#
4
5##
6# *********
7# Migration
8# *********
9##
10
11{ 'include': 'common.json' }
12{ 'include': 'sockets.json' }
13
14##
15# @MigrationStats:
16#
17# Detailed migration status.
18#
19# @transferred: amount of bytes already transferred to the target VM
20#
21# @remaining: amount of bytes remaining to be transferred to the
22#     target VM
23#
24# @total: total amount of bytes involved in the migration process
25#
26# @duplicate: number of duplicate (zero) pages (since 1.2)
27#
28# @normal: number of normal pages (since 1.2)
29#
30# @normal-bytes: number of normal bytes sent (since 1.2)
31#
32# @dirty-pages-rate: number of pages dirtied by second by the guest
33#     (since 1.3)
34#
35# @mbps: throughput in megabits/sec.  (since 1.6)
36#
37# @dirty-sync-count: number of times that dirty ram was synchronized
38#     (since 2.1)
39#
40# @postcopy-requests: The number of page requests received from the
41#     destination (since 2.7)
42#
43# @page-size: The number of bytes per page for the various page-based
44#     statistics (since 2.10)
45#
46# @multifd-bytes: The number of bytes sent through multifd (since 3.0)
47#
48# @pages-per-second: the number of memory pages transferred per second
49#     (Since 4.0)
50#
51# @precopy-bytes: The number of bytes sent in the pre-copy phase
52#     (since 7.0).
53#
54# @downtime-bytes: The number of bytes sent while the guest is paused
55#     (since 7.0).
56#
57# @postcopy-bytes: The number of bytes sent during the post-copy phase
58#     (since 7.0).
59#
60# @dirty-sync-missed-zero-copy: Number of times dirty RAM
61#     synchronization could not avoid copying dirty pages.  This is
62#     between 0 and @dirty-sync-count * @multifd-channels.
63#     (since 7.1)
64#
65# Since: 0.14
66##
67{ 'struct': 'MigrationStats',
68  'data': {'transferred': 'int', 'remaining': 'int', 'total': 'int' ,
69           'duplicate': 'int',
70           'normal': 'int',
71           'normal-bytes': 'int', 'dirty-pages-rate': 'int',
72           'mbps': 'number', 'dirty-sync-count': 'int',
73           'postcopy-requests': 'int', 'page-size': 'int',
74           'multifd-bytes': 'uint64', 'pages-per-second': 'uint64',
75           'precopy-bytes': 'uint64', 'downtime-bytes': 'uint64',
76           'postcopy-bytes': 'uint64',
77           'dirty-sync-missed-zero-copy': 'uint64' } }
78
79##
80# @XBZRLECacheStats:
81#
82# Detailed XBZRLE migration cache statistics
83#
84# @cache-size: XBZRLE cache size
85#
86# @bytes: amount of bytes already transferred to the target VM
87#
88# @pages: amount of pages transferred to the target VM
89#
90# @cache-miss: number of cache miss
91#
92# @cache-miss-rate: rate of cache miss (since 2.1)
93#
94# @encoding-rate: rate of encoded bytes (since 5.1)
95#
96# @overflow: number of overflows
97#
98# Since: 1.2
99##
100{ 'struct': 'XBZRLECacheStats',
101  'data': {'cache-size': 'size', 'bytes': 'int', 'pages': 'int',
102           'cache-miss': 'int', 'cache-miss-rate': 'number',
103           'encoding-rate': 'number', 'overflow': 'int' } }
104
105##
106# @CompressionStats:
107#
108# Detailed migration compression statistics
109#
110# @pages: amount of pages compressed and transferred to the target VM
111#
112# @busy: count of times that no free thread was available to compress
113#     data
114#
115# @busy-rate: rate of thread busy
116#
117# @compressed-size: amount of bytes after compression
118#
119# @compression-rate: rate of compressed size
120#
121# Since: 3.1
122##
123{ 'struct': 'CompressionStats',
124  'data': {'pages': 'int', 'busy': 'int', 'busy-rate': 'number',
125           'compressed-size': 'int', 'compression-rate': 'number' } }
126
127##
128# @MigrationStatus:
129#
130# An enumeration of migration status.
131#
132# @none: no migration has ever happened.
133#
134# @setup: migration process has been initiated.
135#
136# @cancelling: in the process of cancelling migration.
137#
138# @cancelled: cancelling migration is finished.
139#
140# @active: in the process of doing migration.
141#
142# @postcopy-active: like active, but now in postcopy mode.
143#     (since 2.5)
144#
145# @postcopy-paused: during postcopy but paused.  (since 3.0)
146#
147# @postcopy-recover-setup: setup phase for a postcopy recovery
148#     process, preparing for a recovery phase to start.  (since 9.1)
149#
150# @postcopy-recover: trying to recover from a paused postcopy.
151#     (since 3.0)
152#
153# @completed: migration is finished.
154#
155# @failed: some error occurred during migration process.
156#
157# @colo: VM is in the process of fault tolerance, VM can not get into
158#     this state unless colo capability is enabled for migration.
159#     (since 2.8)
160#
161# @pre-switchover: Paused before device serialisation.  (since 2.11)
162#
163# @device: During device serialisation (also known as switchover phase).
164#     Before 9.2, this is only used when (1) in precopy, and (2) when
165#     pre-switchover capability is enabled.  After 10.0, this state will
166#     always be present for every migration procedure as the switchover
167#     phase.  (since 2.11)
168#
169# @wait-unplug: wait for device unplug request by guest OS to be
170#     completed.  (since 4.2)
171#
172# Since: 2.3
173##
174{ 'enum': 'MigrationStatus',
175  'data': [ 'none', 'setup', 'cancelling', 'cancelled',
176            'active', 'postcopy-active', 'postcopy-paused',
177            'postcopy-recover-setup',
178            'postcopy-recover', 'completed', 'failed', 'colo',
179            'pre-switchover', 'device', 'wait-unplug' ] }
180##
181# @VfioStats:
182#
183# Detailed VFIO devices migration statistics
184#
185# @transferred: amount of bytes transferred to the target VM by VFIO
186#     devices
187#
188# Since: 5.2
189##
190{ 'struct': 'VfioStats',
191  'data': {'transferred': 'int' } }
192
193##
194# @MigrationInfo:
195#
196# Information about current migration process.
197#
198# @status: `MigrationStatus` describing the current migration status.
199#     If this field is not returned, no migration process has been
200#     initiated
201#
202# @ram: `MigrationStats` containing detailed migration status, only
203#     returned if status is 'active' or 'completed'(since 1.2)
204#
205# @xbzrle-cache: `XBZRLECacheStats` containing detailed XBZRLE
206#     migration statistics, only returned if XBZRLE feature is on and
207#     status is 'active' or 'completed' (since 1.2)
208#
209# @total-time: total amount of milliseconds since migration started.
210#     If migration has ended, it returns the total migration time.
211#     (since 1.2)
212#
213# @downtime: only present when migration finishes correctly total
214#     downtime in milliseconds for the guest.  (since 1.3)
215#
216# @expected-downtime: only present while migration is active expected
217#     downtime in milliseconds for the guest in last walk of the dirty
218#     bitmap.  (since 1.3)
219#
220# @setup-time: amount of setup time in milliseconds *before* the
221#     iterations begin but *after* the QMP command is issued.  This is
222#     designed to provide an accounting of any activities (such as
223#     RDMA pinning) which may be expensive, but do not actually occur
224#     during the iterative migration rounds themselves.  (since 1.6)
225#
226# @cpu-throttle-percentage: percentage of time guest cpus are being
227#     throttled during auto-converge.  This is only present when
228#     auto-converge has started throttling guest cpus.  (Since 2.7)
229#
230# @error-desc: the human readable error description string.  Clients
231#     should not attempt to parse the error strings.  (Since 2.7)
232#
233# @postcopy-blocktime: total time when all vCPU were blocked during
234#     postcopy live migration.  This is only present when the
235#     postcopy-blocktime migration capability is enabled.  (Since 3.0)
236#
237# @postcopy-vcpu-blocktime: list of the postcopy blocktime per vCPU.
238#     This is only present when the postcopy-blocktime migration
239#     capability is enabled.  (Since 3.0)
240#
241# @postcopy-latency: average remote page fault latency (in ns).  Note that
242#     this doesn't include all faults, but only the ones that require a
243#     remote page request.  So it should be always bigger than the real
244#     average page fault latency. This is only present when the
245#     postcopy-blocktime migration capability is enabled.  (Since 10.1)
246#
247# @postcopy-latency-dist: remote page fault latency distributions.  Each
248#     element of the array is the number of faults that fall into the
249#     bucket period.  For the N-th bucket (N>=0), the latency window is
250#     [2^Nus, 2^(N+1)us).  For example, the 8th element stores how many
251#     remote faults got resolved within [256us, 512us) window. This is only
252#     present when the postcopy-blocktime migration capability is enabled.
253#     (Since 10.1)
254#
255# @postcopy-vcpu-latency: average remote page fault latency per vCPU (in
256#     ns).  It has the same definition of @postcopy-latency, but instead
257#     this is the per-vCPU statistics.  This is only present when the
258#     postcopy-blocktime migration capability is enabled.  (Since 10.1)
259#
260# @postcopy-non-vcpu-latency: average remote page fault latency for all
261#     faults happend in non-vCPU threads (in ns).  It has the same
262#     definition of @postcopy-latency but this only provides statistics to
263#     non-vCPU faults.  This is only present when the postcopy-blocktime
264#     migration capability is enabled.  (Since 10.1)
265#
266# @socket-address: Only used for tcp, to know what the real port is
267#     (Since 4.0)
268#
269# @vfio: `VfioStats` containing detailed VFIO devices migration
270#     statistics, only returned if VFIO device is present, migration
271#     is supported by all VFIO devices and status is 'active' or
272#     'completed' (since 5.2)
273#
274# @blocked-reasons: A list of reasons an outgoing migration is
275#     blocked.  Present and non-empty when migration is blocked.
276#     (since 6.0)
277#
278# @dirty-limit-throttle-time-per-round: Maximum throttle time (in
279#     microseconds) of virtual CPUs each dirty ring full round, which
280#     shows how `MigrationCapability` dirty-limit affects the guest
281#     during live migration.  (Since 8.1)
282#
283# @dirty-limit-ring-full-time: Estimated average dirty ring full time
284#     (in microseconds) for each dirty ring full round.  The value
285#     equals the dirty ring memory size divided by the average dirty
286#     page rate of the virtual CPU, which can be used to observe the
287#     average memory load of the virtual CPU indirectly.  Note that
288#     zero means guest doesn't dirty memory.  (Since 8.1)
289#
290# Features:
291#
292# @unstable: Members @postcopy-latency, @postcopy-vcpu-latency,
293#     @postcopy-latency-dist, @postcopy-non-vcpu-latency are experimental.
294#
295# Since: 0.14
296##
297{ 'struct': 'MigrationInfo',
298  'data': {'*status': 'MigrationStatus', '*ram': 'MigrationStats',
299           '*vfio': 'VfioStats',
300           '*xbzrle-cache': 'XBZRLECacheStats',
301           '*total-time': 'int',
302           '*expected-downtime': 'int',
303           '*downtime': 'int',
304           '*setup-time': 'int',
305           '*cpu-throttle-percentage': 'int',
306           '*error-desc': 'str',
307           '*blocked-reasons': ['str'],
308           '*postcopy-blocktime': 'uint32',
309           '*postcopy-vcpu-blocktime': ['uint32'],
310           '*postcopy-latency': {
311               'type': 'uint64', 'features': [ 'unstable' ] },
312           '*postcopy-latency-dist': {
313               'type': ['uint64'], 'features': [ 'unstable' ] },
314           '*postcopy-vcpu-latency': {
315               'type': ['uint64'], 'features': [ 'unstable' ] },
316           '*postcopy-non-vcpu-latency': {
317               'type': 'uint64', 'features': [ 'unstable' ] },
318           '*socket-address': ['SocketAddress'],
319           '*dirty-limit-throttle-time-per-round': 'uint64',
320           '*dirty-limit-ring-full-time': 'uint64'} }
321
322##
323# @query-migrate:
324#
325# Return information about current migration process.  If migration
326# is active there will be another json-object with RAM migration
327# status.
328#
329# Since: 0.14
330#
331# .. qmp-example::
332#    :title: Before the first migration
333#
334#     -> { "execute": "query-migrate" }
335#     <- { "return": {} }
336#
337# .. qmp-example::
338#    :title: Migration is done and has succeeded
339#
340#     -> { "execute": "query-migrate" }
341#     <- { "return": {
342#             "status": "completed",
343#             "total-time":12345,
344#             "setup-time":12345,
345#             "downtime":12345,
346#             "ram":{
347#               "transferred":123,
348#               "remaining":123,
349#               "total":246,
350#               "duplicate":123,
351#               "normal":123,
352#               "normal-bytes":123456,
353#               "dirty-sync-count":15
354#             }
355#          }
356#        }
357#
358# .. qmp-example::
359#    :title: Migration is done and has failed
360#
361#     -> { "execute": "query-migrate" }
362#     <- { "return": { "status": "failed" } }
363#
364# .. qmp-example::
365#    :title: Migration is being performed
366#
367#     -> { "execute": "query-migrate" }
368#     <- {
369#           "return":{
370#              "status":"active",
371#              "total-time":12345,
372#              "setup-time":12345,
373#              "expected-downtime":12345,
374#              "ram":{
375#                 "transferred":123,
376#                 "remaining":123,
377#                 "total":246,
378#                 "duplicate":123,
379#                 "normal":123,
380#                 "normal-bytes":123456,
381#                 "dirty-sync-count":15
382#              }
383#           }
384#        }
385#
386# .. qmp-example::
387#    :title: Migration is being performed and XBZRLE is active
388#
389#     -> { "execute": "query-migrate" }
390#     <- {
391#           "return":{
392#              "status":"active",
393#              "total-time":12345,
394#              "setup-time":12345,
395#              "expected-downtime":12345,
396#              "ram":{
397#                 "total":1057024,
398#                 "remaining":1053304,
399#                 "transferred":3720,
400#                 "duplicate":10,
401#                 "normal":3333,
402#                 "normal-bytes":3412992,
403#                 "dirty-sync-count":15
404#              },
405#              "xbzrle-cache":{
406#                 "cache-size":67108864,
407#                 "bytes":20971520,
408#                 "pages":2444343,
409#                 "cache-miss":2244,
410#                 "cache-miss-rate":0.123,
411#                 "encoding-rate":80.1,
412#                 "overflow":34434
413#              }
414#           }
415#        }
416##
417{ 'command': 'query-migrate', 'returns': 'MigrationInfo' }
418
419##
420# @MigrationCapability:
421#
422# Migration capabilities enumeration
423#
424# @xbzrle: Migration supports xbzrle (Xor Based Zero Run Length
425#     Encoding).  This feature allows us to minimize migration traffic
426#     for certain work loads, by sending compressed difference of the
427#     pages
428#
429# @rdma-pin-all: Controls whether or not the entire VM memory
430#     footprint is mlock()'d on demand or all at once.  Refer to
431#     docs/rdma.txt for usage.  Disabled by default.  (since 2.0)
432#
433# @zero-blocks: During storage migration encode blocks of zeroes
434#     efficiently.  This essentially saves 1MB of zeroes per block on
435#     the wire.  Enabling requires source and target VM to support
436#     this feature.  To enable it is sufficient to enable the
437#     capability on the source VM.  The feature is disabled by
438#     default.  (since 1.6)
439#
440# @events: generate events for each migration state change (since 2.4)
441#
442# @auto-converge: If enabled, QEMU will automatically throttle down
443#     the guest to speed up convergence of RAM migration.  (since 1.6)
444#
445# @postcopy-ram: Start executing on the migration target before all of
446#     RAM has been migrated, pulling the remaining pages along as
447#     needed.  The capacity must have the same setting on both source
448#     and target or migration will not even start.  **Note:** if the
449#     migration fails during postcopy the VM will fail.  (since 2.6)
450#
451# @x-colo: If enabled, migration will never end, and the state of the
452#     VM on the primary side will be migrated continuously to the VM
453#     on secondary side, this process is called COarse-Grain LOck
454#     Stepping (COLO) for Non-stop Service.  (since 2.8)
455#
456# @release-ram: if enabled, QEMU will free the migrated ram pages on
457#     the source during postcopy-ram migration.  (since 2.9)
458#
459# @return-path: If enabled, migration will use the return path even
460#     for precopy.  (since 2.10)
461#
462# @pause-before-switchover: Pause outgoing migration before
463#     serialising device state and before disabling block IO
464#     (since 2.11)
465#
466# @multifd: Use more than one fd for migration (since 4.0)
467#
468# @dirty-bitmaps: If enabled, QEMU will migrate named dirty bitmaps.
469#     (since 2.12)
470#
471# @postcopy-blocktime: Calculate downtime for postcopy live migration
472#     (since 3.0)
473#
474# @late-block-activate: If enabled, the destination will not activate
475#     block devices (and thus take locks) immediately at the end of
476#     migration.  (since 3.0)
477#
478# @x-ignore-shared: If enabled, QEMU will not migrate shared memory
479#     that is accessible on the destination machine.  (since 4.0)
480#
481# @validate-uuid: Send the UUID of the source to allow the destination
482#     to ensure it is the same.  (since 4.2)
483#
484# @background-snapshot: If enabled, the migration stream will be a
485#     snapshot of the VM exactly at the point when the migration
486#     procedure starts.  The VM RAM is saved with running VM.
487#     (since 6.0)
488#
489# @zero-copy-send: Controls behavior on sending memory pages on
490#     migration.  When true, enables a zero-copy mechanism for sending
491#     memory pages, if host supports it.  Requires that QEMU be
492#     permitted to use locked memory for guest RAM pages.  (since 7.1)
493#
494# @postcopy-preempt: If enabled, the migration process will allow
495#     postcopy requests to preempt precopy stream, so postcopy
496#     requests will be handled faster.  This is a performance feature
497#     and should not affect the correctness of postcopy migration.
498#     (since 7.1)
499#
500# @switchover-ack: If enabled, migration will not stop the source VM
501#     and complete the migration until an ACK is received from the
502#     destination that it's OK to do so.  Exactly when this ACK is
503#     sent depends on the migrated devices that use this feature.  For
504#     example, a device can use it to make sure some of its data is
505#     sent and loaded in the destination before doing switchover.
506#     This can reduce downtime if devices that support this capability
507#     are present.  'return-path' capability must be enabled to use
508#     it.  (since 8.1)
509#
510# @dirty-limit: If enabled, migration will throttle vCPUs as needed to
511#     keep their dirty page rate within @vcpu-dirty-limit.  This can
512#     improve responsiveness of large guests during live migration,
513#     and can result in more stable read performance.  Requires KVM
514#     with accelerator property "dirty-ring-size" set.  (Since 8.1)
515#
516# @mapped-ram: Migrate using fixed offsets in the migration file for
517#     each RAM page.  Requires a migration URI that supports seeking,
518#     such as a file.  (since 9.0)
519#
520# Features:
521#
522# @unstable: Members @x-colo and @x-ignore-shared are experimental.
523# @deprecated: Member @zero-blocks is deprecated as being part of
524#     block migration which was already removed.
525#
526# Since: 1.2
527##
528{ 'enum': 'MigrationCapability',
529  'data': ['xbzrle', 'rdma-pin-all', 'auto-converge',
530           { 'name': 'zero-blocks', 'features': [ 'deprecated' ] },
531           'events', 'postcopy-ram',
532           { 'name': 'x-colo', 'features': [ 'unstable' ] },
533           'release-ram',
534           'return-path', 'pause-before-switchover', 'multifd',
535           'dirty-bitmaps', 'postcopy-blocktime', 'late-block-activate',
536           { 'name': 'x-ignore-shared', 'features': [ 'unstable' ] },
537           'validate-uuid', 'background-snapshot',
538           'zero-copy-send', 'postcopy-preempt', 'switchover-ack',
539           'dirty-limit', 'mapped-ram'] }
540
541##
542# @MigrationCapabilityStatus:
543#
544# Migration capability information
545#
546# @capability: capability enum
547#
548# @state: capability state bool
549#
550# Since: 1.2
551##
552{ 'struct': 'MigrationCapabilityStatus',
553  'data': { 'capability': 'MigrationCapability', 'state': 'bool' } }
554
555##
556# @migrate-set-capabilities:
557#
558# Enable/Disable the following migration capabilities (like xbzrle)
559#
560# @capabilities: json array of capability modifications to make
561#
562# Since: 1.2
563#
564# .. qmp-example::
565#
566#     -> { "execute": "migrate-set-capabilities" , "arguments":
567#          { "capabilities": [ { "capability": "xbzrle", "state": true } ] } }
568#     <- { "return": {} }
569##
570{ 'command': 'migrate-set-capabilities',
571  'data': { 'capabilities': ['MigrationCapabilityStatus'] } }
572
573##
574# @query-migrate-capabilities:
575#
576# Return information about the current migration capabilities status
577#
578# Since: 1.2
579#
580# .. qmp-example::
581#
582#     -> { "execute": "query-migrate-capabilities" }
583#     <- { "return": [
584#           {"state": false, "capability": "xbzrle"},
585#           {"state": false, "capability": "rdma-pin-all"},
586#           {"state": false, "capability": "auto-converge"},
587#           {"state": false, "capability": "zero-blocks"},
588#           {"state": true, "capability": "events"},
589#           {"state": false, "capability": "postcopy-ram"},
590#           {"state": false, "capability": "x-colo"}
591#        ]}
592##
593{ 'command': 'query-migrate-capabilities', 'returns':   ['MigrationCapabilityStatus']}
594
595##
596# @MultiFDCompression:
597#
598# An enumeration of multifd compression methods.
599#
600# @none: no compression.
601#
602# @zlib: use zlib compression method.
603#
604# @zstd: use zstd compression method.
605#
606# @qatzip: use qatzip compression method.  (Since 9.2)
607#
608# @qpl: use qpl compression method.  Query Processing Library(qpl) is
609#     based on the deflate compression algorithm and use the Intel
610#     In-Memory Analytics Accelerator(IAA) accelerated compression and
611#     decompression.  (Since 9.1)
612#
613# @uadk: use UADK library compression method.  (Since 9.1)
614#
615# Since: 5.0
616##
617{ 'enum': 'MultiFDCompression',
618  'prefix': 'MULTIFD_COMPRESSION',
619  'data': [ 'none', 'zlib',
620            { 'name': 'zstd', 'if': 'CONFIG_ZSTD' },
621            { 'name': 'qatzip', 'if': 'CONFIG_QATZIP'},
622            { 'name': 'qpl', 'if': 'CONFIG_QPL' },
623            { 'name': 'uadk', 'if': 'CONFIG_UADK' } ] }
624
625##
626# @MigMode:
627#
628# @normal: the original form of migration.  (since 8.2)
629#
630# @cpr-reboot: The `migrate` command stops the VM and saves state to the
631#     URI.  After quitting QEMU, the user resumes by running QEMU
632#     -incoming.
633#
634#     This mode allows the user to quit QEMU, optionally update and
635#     reboot the OS, and restart QEMU.  If the user reboots, the URI
636#     must persist across the reboot, such as by using a file.
637#
638#     Unlike normal mode, the use of certain local storage options
639#     does not block the migration, but the user must not modify the
640#     contents of guest block devices between the quit and restart.
641#
642#     This mode supports VFIO devices provided the user first puts the
643#     guest in the suspended runstate, such as by issuing
644#     guest-suspend-ram to the QEMU guest agent.
645#
646#     Best performance is achieved when the memory backend is shared
647#     and the @x-ignore-shared migration capability is set, but this
648#     is not required.  Further, if the user reboots before restarting
649#     such a configuration, the shared memory must persist across the
650#     reboot, such as by backing it with a dax device.
651#
652#     @cpr-reboot may not be used with postcopy, background-snapshot,
653#     or COLO.
654#
655#     (since 8.2)
656#
657# @cpr-transfer: This mode allows the user to transfer a guest to a
658#     new QEMU instance on the same host with minimal guest pause
659#     time by preserving guest RAM in place.
660#
661#     Devices and their pinned pages are also preserved for VFIO and
662#     IOMMUFD. (since 10.1)
663#
664#     The user starts new QEMU on the same host as old QEMU, with
665#     command-line arguments to create the same machine, plus the
666#     -incoming option for the main migration channel, like normal
667#     live migration.  In addition, the user adds a second -incoming
668#     option with channel type "cpr".  This CPR channel must support
669#     file descriptor transfer with SCM_RIGHTS, i.e. it must be a
670#     UNIX domain socket.
671#
672#     To initiate CPR, the user issues a migrate command to old QEMU,
673#     adding a second migration channel of type "cpr" in the channels
674#     argument.  Old QEMU stops the VM, saves state to the migration
675#     channels, and enters the postmigrate state.  Execution resumes
676#     in new QEMU.
677#
678#     New QEMU reads the CPR channel before opening a monitor, hence
679#     the CPR channel cannot be specified in the list of channels for
680#     a `migrate-incoming` command.  It may only be specified on the
681#     command line.
682#
683#     The main channel address cannot be a file type, and for an
684#     inet socket, the port cannot be 0 (meaning dynamically choose
685#     a port).
686#
687#     Memory-backend objects must have the share=on attribute, but
688#     memory-backend-epc is not supported.  The VM must be started
689#     with the '-machine aux-ram-share=on' option.
690#
691#     When using -incoming defer, you must issue the `migrate` command
692#     to old QEMU before issuing any monitor commands to new QEMU.
693#     However, new QEMU does not open and read the migration stream
694#     until you issue the `migrate-incoming` command.
695#
696#     (since 10.0)
697##
698{ 'enum': 'MigMode',
699  'data': [ 'normal', 'cpr-reboot', 'cpr-transfer' ] }
700
701##
702# @ZeroPageDetection:
703#
704# @none: Do not perform zero page checking.
705#
706# @legacy: Perform zero page checking in main migration thread.
707#
708# @multifd: Perform zero page checking in multifd sender thread if
709#     multifd migration is enabled, else in the main migration thread
710#     as for @legacy.
711#
712# Since: 9.0
713##
714{ 'enum': 'ZeroPageDetection',
715  'data': [ 'none', 'legacy', 'multifd' ] }
716
717##
718# @BitmapMigrationBitmapAliasTransform:
719#
720# @persistent: If present, the bitmap will be made persistent or
721#     transient depending on this parameter.
722#
723# Since: 6.0
724##
725{ 'struct': 'BitmapMigrationBitmapAliasTransform',
726  'data': {
727      '*persistent': 'bool'
728  } }
729
730##
731# @BitmapMigrationBitmapAlias:
732#
733# @name: The name of the bitmap.
734#
735# @alias: An alias name for migration (for example the bitmap name on
736#     the opposite site).
737#
738# @transform: Allows the modification of the migrated bitmap.
739#     (since 6.0)
740#
741# Since: 5.2
742##
743{ 'struct': 'BitmapMigrationBitmapAlias',
744  'data': {
745      'name': 'str',
746      'alias': 'str',
747      '*transform': 'BitmapMigrationBitmapAliasTransform'
748  } }
749
750##
751# @BitmapMigrationNodeAlias:
752#
753# Maps a block node name and the bitmaps it has to aliases for dirty
754# bitmap migration.
755#
756# @node-name: A block node name.
757#
758# @alias: An alias block node name for migration (for example the node
759#     name on the opposite site).
760#
761# @bitmaps: Mappings for the bitmaps on this node.
762#
763# Since: 5.2
764##
765{ 'struct': 'BitmapMigrationNodeAlias',
766  'data': {
767      'node-name': 'str',
768      'alias': 'str',
769      'bitmaps': [ 'BitmapMigrationBitmapAlias' ]
770  } }
771
772##
773# @MigrationParameter:
774#
775# Migration parameters enumeration
776#
777# @announce-initial: Initial delay (in milliseconds) before sending
778#     the first announce (Since 4.0)
779#
780# @announce-max: Maximum delay (in milliseconds) between packets in
781#     the announcement (Since 4.0)
782#
783# @announce-rounds: Number of self-announce packets sent after
784#     migration (Since 4.0)
785#
786# @announce-step: Increase in delay (in milliseconds) between
787#     subsequent packets in the announcement (Since 4.0)
788#
789# @throttle-trigger-threshold: The ratio of bytes_dirty_period and
790#     bytes_xfer_period to trigger throttling.  It is expressed as
791#     percentage.  The default value is 50.  (Since 5.0)
792#
793# @cpu-throttle-initial: Initial percentage of time guest cpus are
794#     throttled when migration auto-converge is activated.  The
795#     default value is 20.  (Since 2.7)
796#
797# @cpu-throttle-increment: throttle percentage increase each time
798#     auto-converge detects that migration is not making progress.
799#     The default value is 10.  (Since 2.7)
800#
801# @cpu-throttle-tailslow: Make CPU throttling slower at tail stage.
802#     At the tail stage of throttling, the Guest is very sensitive to
803#     CPU percentage while the @cpu-throttle -increment is excessive
804#     usually at tail stage.  If this parameter is true, we will
805#     compute the ideal CPU percentage used by the Guest, which may
806#     exactly make the dirty rate match the dirty rate threshold.
807#     Then we will choose a smaller throttle increment between the one
808#     specified by @cpu-throttle-increment and the one generated by
809#     ideal CPU percentage.  Therefore, it is compatible to
810#     traditional throttling, meanwhile the throttle increment won't
811#     be excessive at tail stage.  The default value is false.
812#     (Since 5.1)
813#
814# @tls-creds: ID of the 'tls-creds' object that provides credentials
815#     for establishing a TLS connection over the migration data
816#     channel.  On the outgoing side of the migration, the credentials
817#     must be for a 'client' endpoint, while for the incoming side the
818#     credentials must be for a 'server' endpoint.  Setting this to a
819#     non-empty string enables TLS for all migrations.  An empty
820#     string means that QEMU will use plain text mode for migration,
821#     rather than TLS.  (Since 2.7)
822#
823# @tls-hostname: migration target's hostname for validating the
824#     server's x509 certificate identity.  If empty, QEMU will use the
825#     hostname from the migration URI, if any.  A non-empty value is
826#     required when using x509 based TLS credentials and the migration
827#     URI does not include a hostname, such as fd: or exec: based
828#     migration.  (Since 2.7)
829#
830#     Note: empty value works only since 2.9.
831#
832# @tls-authz: ID of the 'authz' object subclass that provides access
833#     control checking of the TLS x509 certificate distinguished name.
834#     This object is only resolved at time of use, so can be deleted
835#     and recreated on the fly while the migration server is active.
836#     If missing, it will default to denying access (Since 4.0)
837#
838# @max-bandwidth: maximum speed for migration, in bytes per second.
839#     (Since 2.8)
840#
841# @avail-switchover-bandwidth: to set the available bandwidth that
842#     migration can use during switchover phase.  **Note:** this does
843#     not limit the bandwidth during switchover, but only for
844#     calculations when making decisions to switchover.  By default,
845#     this value is zero, which means QEMU will estimate the bandwidth
846#     automatically.  This can be set when the estimated value is not
847#     accurate, while the user is able to guarantee such bandwidth is
848#     available when switching over.  When specified correctly, this
849#     can make the switchover decision much more accurate.
850#     (Since 8.2)
851#
852# @downtime-limit: set maximum tolerated downtime for migration.
853#     maximum downtime in milliseconds (Since 2.8)
854#
855# @x-checkpoint-delay: The delay time (in ms) between two COLO
856#     checkpoints in periodic mode.  (Since 2.8)
857#
858# @multifd-channels: Number of channels used to migrate data in
859#     parallel.  This is the same number that the number of sockets
860#     used for migration.  The default value is 2 (since 4.0)
861#
862# @xbzrle-cache-size: cache size to be used by XBZRLE migration.  It
863#     needs to be a multiple of the target page size and a power of 2
864#     (Since 2.11)
865#
866# @max-postcopy-bandwidth: Background transfer bandwidth during
867#     postcopy.  Defaults to 0 (unlimited).  In bytes per second.
868#     (Since 3.0)
869#
870# @max-cpu-throttle: maximum cpu throttle percentage.  Defaults to 99.
871#     (Since 3.1)
872#
873# @multifd-compression: Which compression method to use.  Defaults to
874#     none.  (Since 5.0)
875#
876# @multifd-zlib-level: Set the compression level to be used in live
877#     migration, the compression level is an integer between 0 and 9,
878#     where 0 means no compression, 1 means the best compression
879#     speed, and 9 means best compression ratio which will consume
880#     more CPU.  Defaults to 1.  (Since 5.0)
881#
882# @multifd-qatzip-level: Set the compression level to be used in live
883#     migration.  The level is an integer between 1 and 9, where 1 means
884#     the best compression speed, and 9 means the best compression
885#     ratio which will consume more CPU.  Defaults to 1.  (Since 9.2)
886#
887# @multifd-zstd-level: Set the compression level to be used in live
888#     migration, the compression level is an integer between 0 and 20,
889#     where 0 means no compression, 1 means the best compression
890#     speed, and 20 means best compression ratio which will consume
891#     more CPU.  Defaults to 1.  (Since 5.0)
892#
893# @block-bitmap-mapping: Maps block nodes and bitmaps on them to
894#     aliases for the purpose of dirty bitmap migration.  Such aliases
895#     may for example be the corresponding names on the opposite site.
896#     The mapping must be one-to-one, but not necessarily complete: On
897#     the source, unmapped bitmaps and all bitmaps on unmapped nodes
898#     will be ignored.  On the destination, encountering an unmapped
899#     alias in the incoming migration stream will result in a report,
900#     and all further bitmap migration data will then be discarded.
901#     Note that the destination does not know about bitmaps it does
902#     not receive, so there is no limitation or requirement regarding
903#     the number of bitmaps received, or how they are named, or on
904#     which nodes they are placed.  By default (when this parameter
905#     has never been set), bitmap names are mapped to themselves.
906#     Nodes are mapped to their block device name if there is one, and
907#     to their node name otherwise.  (Since 5.2)
908#
909# @x-vcpu-dirty-limit-period: Periodic time (in milliseconds) of dirty
910#     limit during live migration.  Should be in the range 1 to
911#     1000ms.  Defaults to 1000ms.  (Since 8.1)
912#
913# @vcpu-dirty-limit: Dirtyrate limit (MB/s) during live migration.
914#     Defaults to 1.  (Since 8.1)
915#
916# @mode: Migration mode.  See description in `MigMode`.  Default is
917#     'normal'.  (Since 8.2)
918#
919# @zero-page-detection: Whether and how to detect zero pages.
920#     See description in `ZeroPageDetection`.  Default is 'multifd'.
921#     (since 9.0)
922#
923# @direct-io: Open migration files with O_DIRECT when possible.  This
924#     only has effect if the @mapped-ram capability is enabled.
925#     (Since 9.1)
926#
927# Features:
928#
929# @unstable: Members @x-checkpoint-delay and
930#     @x-vcpu-dirty-limit-period are experimental.
931#
932# Since: 2.4
933##
934{ 'enum': 'MigrationParameter',
935  'data': ['announce-initial', 'announce-max',
936           'announce-rounds', 'announce-step',
937           'throttle-trigger-threshold',
938           'cpu-throttle-initial', 'cpu-throttle-increment',
939           'cpu-throttle-tailslow',
940           'tls-creds', 'tls-hostname', 'tls-authz', 'max-bandwidth',
941           'avail-switchover-bandwidth', 'downtime-limit',
942           { 'name': 'x-checkpoint-delay', 'features': [ 'unstable' ] },
943           'multifd-channels',
944           'xbzrle-cache-size', 'max-postcopy-bandwidth',
945           'max-cpu-throttle', 'multifd-compression',
946           'multifd-zlib-level', 'multifd-zstd-level',
947           'multifd-qatzip-level',
948           'block-bitmap-mapping',
949           { 'name': 'x-vcpu-dirty-limit-period', 'features': ['unstable'] },
950           'vcpu-dirty-limit',
951           'mode',
952           'zero-page-detection',
953           'direct-io'] }
954
955##
956# @MigrateSetParameters:
957#
958# @announce-initial: Initial delay (in milliseconds) before sending
959#     the first announce (Since 4.0)
960#
961# @announce-max: Maximum delay (in milliseconds) between packets in
962#     the announcement (Since 4.0)
963#
964# @announce-rounds: Number of self-announce packets sent after
965#     migration (Since 4.0)
966#
967# @announce-step: Increase in delay (in milliseconds) between
968#     subsequent packets in the announcement (Since 4.0)
969#
970# @throttle-trigger-threshold: The ratio of bytes_dirty_period and
971#     bytes_xfer_period to trigger throttling.  It is expressed as
972#     percentage.  The default value is 50.  (Since 5.0)
973#
974# @cpu-throttle-initial: Initial percentage of time guest cpus are
975#     throttled when migration auto-converge is activated.  The
976#     default value is 20.  (Since 2.7)
977#
978# @cpu-throttle-increment: throttle percentage increase each time
979#     auto-converge detects that migration is not making progress.
980#     The default value is 10.  (Since 2.7)
981#
982# @cpu-throttle-tailslow: Make CPU throttling slower at tail stage.
983#     At the tail stage of throttling, the Guest is very sensitive to
984#     CPU percentage while the @cpu-throttle -increment is excessive
985#     usually at tail stage.  If this parameter is true, we will
986#     compute the ideal CPU percentage used by the Guest, which may
987#     exactly make the dirty rate match the dirty rate threshold.
988#     Then we will choose a smaller throttle increment between the one
989#     specified by @cpu-throttle-increment and the one generated by
990#     ideal CPU percentage.  Therefore, it is compatible to
991#     traditional throttling, meanwhile the throttle increment won't
992#     be excessive at tail stage.  The default value is false.
993#     (Since 5.1)
994#
995# @tls-creds: ID of the 'tls-creds' object that provides credentials
996#     for establishing a TLS connection over the migration data
997#     channel.  On the outgoing side of the migration, the credentials
998#     must be for a 'client' endpoint, while for the incoming side the
999#     credentials must be for a 'server' endpoint.  Setting this to a
1000#     non-empty string enables TLS for all migrations.  An empty
1001#     string means that QEMU will use plain text mode for migration,
1002#     rather than TLS.  This is the default.  (Since 2.7)
1003#
1004# @tls-hostname: migration target's hostname for validating the
1005#     server's x509 certificate identity.  If empty, QEMU will use the
1006#     hostname from the migration URI, if any.  A non-empty value is
1007#     required when using x509 based TLS credentials and the migration
1008#     URI does not include a hostname, such as fd: or exec: based
1009#     migration.  (Since 2.7)
1010#
1011#     Note: empty value works only since 2.9.
1012#
1013# @tls-authz: ID of the 'authz' object subclass that provides access
1014#     control checking of the TLS x509 certificate distinguished name.
1015#     This object is only resolved at time of use, so can be deleted
1016#     and recreated on the fly while the migration server is active.
1017#     If missing, it will default to denying access (Since 4.0)
1018#
1019# @max-bandwidth: maximum speed for migration, in bytes per second.
1020#     (Since 2.8)
1021#
1022# @avail-switchover-bandwidth: to set the available bandwidth that
1023#     migration can use during switchover phase.  **Note:** this does
1024#     not limit the bandwidth during switchover, but only for
1025#     calculations when making decisions to switchover.  By default,
1026#     this value is zero, which means QEMU will estimate the bandwidth
1027#     automatically.  This can be set when the estimated value is not
1028#     accurate, while the user is able to guarantee such bandwidth is
1029#     available when switching over.  When specified correctly, this
1030#     can make the switchover decision much more accurate.
1031#     (Since 8.2)
1032#
1033# @downtime-limit: set maximum tolerated downtime for migration.
1034#     maximum downtime in milliseconds (Since 2.8)
1035#
1036# @x-checkpoint-delay: The delay time (in ms) between two COLO
1037#     checkpoints in periodic mode.  (Since 2.8)
1038#
1039# @multifd-channels: Number of channels used to migrate data in
1040#     parallel.  This is the same number that the number of sockets
1041#     used for migration.  The default value is 2 (since 4.0)
1042#
1043# @xbzrle-cache-size: cache size to be used by XBZRLE migration.  It
1044#     needs to be a multiple of the target page size and a power of 2
1045#     (Since 2.11)
1046#
1047# @max-postcopy-bandwidth: Background transfer bandwidth during
1048#     postcopy.  Defaults to 0 (unlimited).  In bytes per second.
1049#     (Since 3.0)
1050#
1051# @max-cpu-throttle: maximum cpu throttle percentage.  Defaults to 99.
1052#     (Since 3.1)
1053#
1054# @multifd-compression: Which compression method to use.  Defaults to
1055#     none.  (Since 5.0)
1056#
1057# @multifd-zlib-level: Set the compression level to be used in live
1058#     migration, the compression level is an integer between 0 and 9,
1059#     where 0 means no compression, 1 means the best compression
1060#     speed, and 9 means best compression ratio which will consume
1061#     more CPU.  Defaults to 1.  (Since 5.0)
1062#
1063# @multifd-qatzip-level: Set the compression level to be used in live
1064#     migration.  The level is an integer between 1 and 9, where 1 means
1065#     the best compression speed, and 9 means the best compression
1066#     ratio which will consume more CPU.  Defaults to 1.  (Since 9.2)
1067#
1068# @multifd-zstd-level: Set the compression level to be used in live
1069#     migration, the compression level is an integer between 0 and 20,
1070#     where 0 means no compression, 1 means the best compression
1071#     speed, and 20 means best compression ratio which will consume
1072#     more CPU.  Defaults to 1.  (Since 5.0)
1073#
1074# @block-bitmap-mapping: Maps block nodes and bitmaps on them to
1075#     aliases for the purpose of dirty bitmap migration.  Such aliases
1076#     may for example be the corresponding names on the opposite site.
1077#     The mapping must be one-to-one, but not necessarily complete: On
1078#     the source, unmapped bitmaps and all bitmaps on unmapped nodes
1079#     will be ignored.  On the destination, encountering an unmapped
1080#     alias in the incoming migration stream will result in a report,
1081#     and all further bitmap migration data will then be discarded.
1082#     Note that the destination does not know about bitmaps it does
1083#     not receive, so there is no limitation or requirement regarding
1084#     the number of bitmaps received, or how they are named, or on
1085#     which nodes they are placed.  By default (when this parameter
1086#     has never been set), bitmap names are mapped to themselves.
1087#     Nodes are mapped to their block device name if there is one, and
1088#     to their node name otherwise.  (Since 5.2)
1089#
1090# @x-vcpu-dirty-limit-period: Periodic time (in milliseconds) of dirty
1091#     limit during live migration.  Should be in the range 1 to
1092#     1000ms.  Defaults to 1000ms.  (Since 8.1)
1093#
1094# @vcpu-dirty-limit: Dirtyrate limit (MB/s) during live migration.
1095#     Defaults to 1.  (Since 8.1)
1096#
1097# @mode: Migration mode.  See description in `MigMode`.  Default is
1098#     'normal'.  (Since 8.2)
1099#
1100# @zero-page-detection: Whether and how to detect zero pages.
1101#     See description in `ZeroPageDetection`.  Default is 'multifd'.
1102#     (since 9.0)
1103#
1104# @direct-io: Open migration files with O_DIRECT when possible.  This
1105#     only has effect if the @mapped-ram capability is enabled.
1106#     (Since 9.1)
1107#
1108# Features:
1109#
1110# @unstable: Members @x-checkpoint-delay and
1111#     @x-vcpu-dirty-limit-period are experimental.
1112#
1113# TODO: either fuse back into `MigrationParameters`, or make
1114#     `MigrationParameters` members mandatory
1115#
1116# Since: 2.4
1117##
1118{ 'struct': 'MigrateSetParameters',
1119  'data': { '*announce-initial': 'size',
1120            '*announce-max': 'size',
1121            '*announce-rounds': 'size',
1122            '*announce-step': 'size',
1123            '*throttle-trigger-threshold': 'uint8',
1124            '*cpu-throttle-initial': 'uint8',
1125            '*cpu-throttle-increment': 'uint8',
1126            '*cpu-throttle-tailslow': 'bool',
1127            '*tls-creds': 'StrOrNull',
1128            '*tls-hostname': 'StrOrNull',
1129            '*tls-authz': 'StrOrNull',
1130            '*max-bandwidth': 'size',
1131            '*avail-switchover-bandwidth': 'size',
1132            '*downtime-limit': 'uint64',
1133            '*x-checkpoint-delay': { 'type': 'uint32',
1134                                     'features': [ 'unstable' ] },
1135            '*multifd-channels': 'uint8',
1136            '*xbzrle-cache-size': 'size',
1137            '*max-postcopy-bandwidth': 'size',
1138            '*max-cpu-throttle': 'uint8',
1139            '*multifd-compression': 'MultiFDCompression',
1140            '*multifd-zlib-level': 'uint8',
1141            '*multifd-qatzip-level': 'uint8',
1142            '*multifd-zstd-level': 'uint8',
1143            '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ],
1144            '*x-vcpu-dirty-limit-period': { 'type': 'uint64',
1145                                            'features': [ 'unstable' ] },
1146            '*vcpu-dirty-limit': 'uint64',
1147            '*mode': 'MigMode',
1148            '*zero-page-detection': 'ZeroPageDetection',
1149            '*direct-io': 'bool' } }
1150
1151##
1152# @migrate-set-parameters:
1153#
1154# Set various migration parameters.
1155#
1156# Since: 2.4
1157#
1158# .. qmp-example::
1159#
1160#     -> { "execute": "migrate-set-parameters" ,
1161#          "arguments": { "multifd-channels": 5 } }
1162#     <- { "return": {} }
1163##
1164{ 'command': 'migrate-set-parameters', 'boxed': true,
1165  'data': 'MigrateSetParameters' }
1166
1167##
1168# @MigrationParameters:
1169#
1170# The optional members aren't actually optional.
1171#
1172# @announce-initial: Initial delay (in milliseconds) before sending
1173#     the first announce (Since 4.0)
1174#
1175# @announce-max: Maximum delay (in milliseconds) between packets in
1176#     the announcement (Since 4.0)
1177#
1178# @announce-rounds: Number of self-announce packets sent after
1179#     migration (Since 4.0)
1180#
1181# @announce-step: Increase in delay (in milliseconds) between
1182#     subsequent packets in the announcement (Since 4.0)
1183#
1184# @throttle-trigger-threshold: The ratio of bytes_dirty_period and
1185#     bytes_xfer_period to trigger throttling.  It is expressed as
1186#     percentage.  The default value is 50.  (Since 5.0)
1187#
1188# @cpu-throttle-initial: Initial percentage of time guest cpus are
1189#     throttled when migration auto-converge is activated.
1190#     (Since 2.7)
1191#
1192# @cpu-throttle-increment: throttle percentage increase each time
1193#     auto-converge detects that migration is not making progress.
1194#     (Since 2.7)
1195#
1196# @cpu-throttle-tailslow: Make CPU throttling slower at tail stage.
1197#     At the tail stage of throttling, the Guest is very sensitive to
1198#     CPU percentage while the @cpu-throttle -increment is excessive
1199#     usually at tail stage.  If this parameter is true, we will
1200#     compute the ideal CPU percentage used by the Guest, which may
1201#     exactly make the dirty rate match the dirty rate threshold.
1202#     Then we will choose a smaller throttle increment between the one
1203#     specified by @cpu-throttle-increment and the one generated by
1204#     ideal CPU percentage.  Therefore, it is compatible to
1205#     traditional throttling, meanwhile the throttle increment won't
1206#     be excessive at tail stage.  The default value is false.
1207#     (Since 5.1)
1208#
1209# @tls-creds: ID of the 'tls-creds' object that provides credentials
1210#     for establishing a TLS connection over the migration data
1211#     channel.  On the outgoing side of the migration, the credentials
1212#     must be for a 'client' endpoint, while for the incoming side the
1213#     credentials must be for a 'server' endpoint.  An empty string
1214#     means that QEMU will use plain text mode for migration, rather
1215#     than TLS.  (Since 2.7)
1216#
1217#     Note: 2.8 omits empty @tls-creds instead.
1218#
1219# @tls-hostname: migration target's hostname for validating the
1220#     server's x509 certificate identity.  If empty, QEMU will use the
1221#     hostname from the migration URI, if any.  (Since 2.7)
1222#
1223#     Note: 2.8 omits empty @tls-hostname instead.
1224#
1225# @tls-authz: ID of the 'authz' object subclass that provides access
1226#     control checking of the TLS x509 certificate distinguished name.
1227#     (Since 4.0)
1228#
1229# @max-bandwidth: maximum speed for migration, in bytes per second.
1230#     (Since 2.8)
1231#
1232# @avail-switchover-bandwidth: to set the available bandwidth that
1233#     migration can use during switchover phase.  **Note:** this does
1234#     not limit the bandwidth during switchover, but only for
1235#     calculations when making decisions to switchover.  By default,
1236#     this value is zero, which means QEMU will estimate the bandwidth
1237#     automatically.  This can be set when the estimated value is not
1238#     accurate, while the user is able to guarantee such bandwidth is
1239#     available when switching over.  When specified correctly, this
1240#     can make the switchover decision much more accurate.
1241#     (Since 8.2)
1242#
1243# @downtime-limit: set maximum tolerated downtime for migration.
1244#     maximum downtime in milliseconds (Since 2.8)
1245#
1246# @x-checkpoint-delay: the delay time between two COLO checkpoints.
1247#     (Since 2.8)
1248#
1249# @multifd-channels: Number of channels used to migrate data in
1250#     parallel.  This is the same number that the number of sockets
1251#     used for migration.  The default value is 2 (since 4.0)
1252#
1253# @xbzrle-cache-size: cache size to be used by XBZRLE migration.  It
1254#     needs to be a multiple of the target page size and a power of 2
1255#     (Since 2.11)
1256#
1257# @max-postcopy-bandwidth: Background transfer bandwidth during
1258#     postcopy.  Defaults to 0 (unlimited).  In bytes per second.
1259#     (Since 3.0)
1260#
1261# @max-cpu-throttle: maximum cpu throttle percentage.  Defaults to 99.
1262#     (Since 3.1)
1263#
1264# @multifd-compression: Which compression method to use.  Defaults to
1265#     none.  (Since 5.0)
1266#
1267# @multifd-zlib-level: Set the compression level to be used in live
1268#     migration, the compression level is an integer between 0 and 9,
1269#     where 0 means no compression, 1 means the best compression
1270#     speed, and 9 means best compression ratio which will consume
1271#     more CPU.  Defaults to 1.  (Since 5.0)
1272#
1273# @multifd-qatzip-level: Set the compression level to be used in live
1274#     migration.  The level is an integer between 1 and 9, where 1 means
1275#     the best compression speed, and 9 means the best compression
1276#     ratio which will consume more CPU.  Defaults to 1.  (Since 9.2)
1277#
1278# @multifd-zstd-level: Set the compression level to be used in live
1279#     migration, the compression level is an integer between 0 and 20,
1280#     where 0 means no compression, 1 means the best compression
1281#     speed, and 20 means best compression ratio which will consume
1282#     more CPU.  Defaults to 1.  (Since 5.0)
1283#
1284# @block-bitmap-mapping: Maps block nodes and bitmaps on them to
1285#     aliases for the purpose of dirty bitmap migration.  Such aliases
1286#     may for example be the corresponding names on the opposite site.
1287#     The mapping must be one-to-one, but not necessarily complete: On
1288#     the source, unmapped bitmaps and all bitmaps on unmapped nodes
1289#     will be ignored.  On the destination, encountering an unmapped
1290#     alias in the incoming migration stream will result in a report,
1291#     and all further bitmap migration data will then be discarded.
1292#     Note that the destination does not know about bitmaps it does
1293#     not receive, so there is no limitation or requirement regarding
1294#     the number of bitmaps received, or how they are named, or on
1295#     which nodes they are placed.  By default (when this parameter
1296#     has never been set), bitmap names are mapped to themselves.
1297#     Nodes are mapped to their block device name if there is one, and
1298#     to their node name otherwise.  (Since 5.2)
1299#
1300# @x-vcpu-dirty-limit-period: Periodic time (in milliseconds) of dirty
1301#     limit during live migration.  Should be in the range 1 to
1302#     1000ms.  Defaults to 1000ms.  (Since 8.1)
1303#
1304# @vcpu-dirty-limit: Dirtyrate limit (MB/s) during live migration.
1305#     Defaults to 1.  (Since 8.1)
1306#
1307# @mode: Migration mode.  See description in `MigMode`.  Default is
1308#     'normal'.  (Since 8.2)
1309#
1310# @zero-page-detection: Whether and how to detect zero pages.
1311#     See description in `ZeroPageDetection`.  Default is 'multifd'.
1312#     (since 9.0)
1313#
1314# @direct-io: Open migration files with O_DIRECT when possible.  This
1315#     only has effect if the @mapped-ram capability is enabled.
1316#     (Since 9.1)
1317#
1318# Features:
1319#
1320# @unstable: Members @x-checkpoint-delay and
1321#     @x-vcpu-dirty-limit-period are experimental.
1322#
1323# Since: 2.4
1324##
1325{ 'struct': 'MigrationParameters',
1326  'data': { '*announce-initial': 'size',
1327            '*announce-max': 'size',
1328            '*announce-rounds': 'size',
1329            '*announce-step': 'size',
1330            '*throttle-trigger-threshold': 'uint8',
1331            '*cpu-throttle-initial': 'uint8',
1332            '*cpu-throttle-increment': 'uint8',
1333            '*cpu-throttle-tailslow': 'bool',
1334            '*tls-creds': 'str',
1335            '*tls-hostname': 'str',
1336            '*tls-authz': 'str',
1337            '*max-bandwidth': 'size',
1338            '*avail-switchover-bandwidth': 'size',
1339            '*downtime-limit': 'uint64',
1340            '*x-checkpoint-delay': { 'type': 'uint32',
1341                                     'features': [ 'unstable' ] },
1342            '*multifd-channels': 'uint8',
1343            '*xbzrle-cache-size': 'size',
1344            '*max-postcopy-bandwidth': 'size',
1345            '*max-cpu-throttle': 'uint8',
1346            '*multifd-compression': 'MultiFDCompression',
1347            '*multifd-zlib-level': 'uint8',
1348            '*multifd-qatzip-level': 'uint8',
1349            '*multifd-zstd-level': 'uint8',
1350            '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ],
1351            '*x-vcpu-dirty-limit-period': { 'type': 'uint64',
1352                                            'features': [ 'unstable' ] },
1353            '*vcpu-dirty-limit': 'uint64',
1354            '*mode': 'MigMode',
1355            '*zero-page-detection': 'ZeroPageDetection',
1356            '*direct-io': 'bool' } }
1357
1358##
1359# @query-migrate-parameters:
1360#
1361# Return information about the current migration parameters
1362#
1363# Since: 2.4
1364#
1365# .. qmp-example::
1366#
1367#     -> { "execute": "query-migrate-parameters" }
1368#     <- { "return": {
1369#              "multifd-channels": 2,
1370#              "cpu-throttle-increment": 10,
1371#              "cpu-throttle-initial": 20,
1372#              "max-bandwidth": 33554432,
1373#              "downtime-limit": 300
1374#           }
1375#        }
1376##
1377{ 'command': 'query-migrate-parameters',
1378  'returns': 'MigrationParameters' }
1379
1380##
1381# @migrate-start-postcopy:
1382#
1383# Followup to a migration command to switch the migration to postcopy
1384# mode.  The postcopy-ram capability must be set on both source and
1385# destination before the original migration command.
1386#
1387# Since: 2.5
1388#
1389# .. qmp-example::
1390#
1391#     -> { "execute": "migrate-start-postcopy" }
1392#     <- { "return": {} }
1393##
1394{ 'command': 'migrate-start-postcopy' }
1395
1396##
1397# @MIGRATION:
1398#
1399# Emitted when a migration event happens
1400#
1401# @status: `MigrationStatus` describing the current migration status.
1402#
1403# Since: 2.4
1404#
1405# .. qmp-example::
1406#
1407#     <- {"timestamp": {"seconds": 1432121972, "microseconds": 744001},
1408#         "event": "MIGRATION",
1409#         "data": {"status": "completed"} }
1410##
1411{ 'event': 'MIGRATION',
1412  'data': {'status': 'MigrationStatus'}}
1413
1414##
1415# @MIGRATION_PASS:
1416#
1417# Emitted from the source side of a migration at the start of each
1418# pass (when it syncs the dirty bitmap)
1419#
1420# @pass: An incrementing count (starting at 1 on the first pass)
1421#
1422# Since: 2.6
1423#
1424# .. qmp-example::
1425#
1426#     <- { "timestamp": {"seconds": 1449669631, "microseconds": 239225},
1427#           "event": "MIGRATION_PASS", "data": {"pass": 2} }
1428##
1429{ 'event': 'MIGRATION_PASS',
1430  'data': { 'pass': 'int' } }
1431
1432##
1433# @COLOMessage:
1434#
1435# The message transmission between Primary side and Secondary side.
1436#
1437# @checkpoint-ready: Secondary VM (SVM) is ready for checkpointing
1438#
1439# @checkpoint-request: Primary VM (PVM) tells SVM to prepare for
1440#     checkpointing
1441#
1442# @checkpoint-reply: SVM gets PVM's checkpoint request
1443#
1444# @vmstate-send: VM's state will be sent by PVM.
1445#
1446# @vmstate-size: The total size of VMstate.
1447#
1448# @vmstate-received: VM's state has been received by SVM.
1449#
1450# @vmstate-loaded: VM's state has been loaded by SVM.
1451#
1452# Since: 2.8
1453##
1454{ 'enum': 'COLOMessage',
1455  'data': [ 'checkpoint-ready', 'checkpoint-request', 'checkpoint-reply',
1456            'vmstate-send', 'vmstate-size', 'vmstate-received',
1457            'vmstate-loaded' ] }
1458
1459##
1460# @COLOMode:
1461#
1462# The COLO current mode.
1463#
1464# @none: COLO is disabled.
1465#
1466# @primary: COLO node in primary side.
1467#
1468# @secondary: COLO node in slave side.
1469#
1470# Since: 2.8
1471##
1472{ 'enum': 'COLOMode',
1473  'data': [ 'none', 'primary', 'secondary'] }
1474
1475##
1476# @FailoverStatus:
1477#
1478# An enumeration of COLO failover status
1479#
1480# @none: no failover has ever happened
1481#
1482# @require: got failover requirement but not handled
1483#
1484# @active: in the process of doing failover
1485#
1486# @completed: finish the process of failover
1487#
1488# @relaunch: restart the failover process, from 'none' -> 'completed'
1489#     (Since 2.9)
1490#
1491# Since: 2.8
1492##
1493{ 'enum': 'FailoverStatus',
1494  'data': [ 'none', 'require', 'active', 'completed', 'relaunch' ] }
1495
1496##
1497# @COLO_EXIT:
1498#
1499# Emitted when VM finishes COLO mode due to some errors happening or
1500# at the request of users.
1501#
1502# @mode: report COLO mode when COLO exited.
1503#
1504# @reason: describes the reason for the COLO exit.
1505#
1506# Since: 3.1
1507#
1508# .. qmp-example::
1509#
1510#     <- { "timestamp": {"seconds": 2032141960, "microseconds": 417172},
1511#          "event": "COLO_EXIT", "data": {"mode": "primary", "reason": "request" } }
1512##
1513{ 'event': 'COLO_EXIT',
1514  'data': {'mode': 'COLOMode', 'reason': 'COLOExitReason' } }
1515
1516##
1517# @COLOExitReason:
1518#
1519# The reason for a COLO exit.
1520#
1521# @none: failover has never happened.  This state does not occur in
1522#     the `COLO_EXIT` event, and is only visible in the result of
1523#     `query-colo-status`.
1524#
1525# @request: COLO exit is due to an external request.
1526#
1527# @error: COLO exit is due to an internal error.
1528#
1529# @processing: COLO is currently handling a failover (since 4.0).
1530#
1531# Since: 3.1
1532##
1533{ 'enum': 'COLOExitReason',
1534  'data': [ 'none', 'request', 'error' , 'processing' ] }
1535
1536##
1537# @x-colo-lost-heartbeat:
1538#
1539# Tell QEMU that heartbeat is lost, request it to do takeover
1540# procedures.  If this command is sent to the PVM, the Primary side
1541# will exit COLO mode.  If sent to the Secondary, the Secondary side
1542# will run failover work, then takes over server operation to become
1543# the service VM.
1544#
1545# Features:
1546#
1547# @unstable: This command is experimental.
1548#
1549# Since: 2.8
1550#
1551# .. qmp-example::
1552#
1553#     -> { "execute": "x-colo-lost-heartbeat" }
1554#     <- { "return": {} }
1555##
1556{ 'command': 'x-colo-lost-heartbeat',
1557  'features': [ 'unstable' ],
1558  'if': 'CONFIG_REPLICATION' }
1559
1560##
1561# @migrate_cancel:
1562#
1563# Cancel the currently executing migration process.  Allows a new
1564# migration to be started right after.  When postcopy-ram is in use,
1565# cancelling is not allowed after the postcopy phase has started.
1566#
1567# .. note:: This command succeeds even if there is no migration
1568#    process running.
1569#
1570# Since: 0.14
1571#
1572# .. qmp-example::
1573#
1574#     -> { "execute": "migrate_cancel" }
1575#     <- { "return": {} }
1576##
1577{ 'command': 'migrate_cancel' }
1578
1579##
1580# @migrate-continue:
1581#
1582# Continue migration when it's in a paused state.
1583#
1584# @state: The state the migration is currently expected to be in
1585#
1586# Since: 2.11
1587#
1588# .. qmp-example::
1589#
1590#     -> { "execute": "migrate-continue" , "arguments":
1591#          { "state": "pre-switchover" } }
1592#     <- { "return": {} }
1593##
1594{ 'command': 'migrate-continue', 'data': {'state': 'MigrationStatus'} }
1595
1596##
1597# @MigrationAddressType:
1598#
1599# The migration stream transport mechanisms.
1600#
1601# @socket: Migrate via socket.
1602#
1603# @exec: Direct the migration stream to another process.
1604#
1605# @rdma: Migrate via RDMA.
1606#
1607# @file: Direct the migration stream to a file.
1608#
1609# Since: 8.2
1610##
1611{ 'enum': 'MigrationAddressType',
1612  'data': [ 'socket', 'exec', 'rdma', 'file' ] }
1613
1614##
1615# @FileMigrationArgs:
1616#
1617# @filename: The file to receive the migration stream
1618#
1619# @offset: The file offset where the migration stream will start
1620#
1621# Since: 8.2
1622##
1623{ 'struct': 'FileMigrationArgs',
1624  'data': { 'filename': 'str',
1625            'offset': 'uint64' } }
1626
1627##
1628# @MigrationExecCommand:
1629#
1630# @args: command (list head) and arguments to execute.
1631#
1632# Since: 8.2
1633##
1634{ 'struct': 'MigrationExecCommand',
1635  'data': {'args': [ 'str' ] } }
1636
1637##
1638# @MigrationAddress:
1639#
1640# Migration endpoint configuration.
1641#
1642# @transport: The migration stream transport mechanism
1643#
1644# Since: 8.2
1645##
1646{ 'union': 'MigrationAddress',
1647  'base': { 'transport' : 'MigrationAddressType'},
1648  'discriminator': 'transport',
1649  'data': {
1650    'socket': 'SocketAddress',
1651    'exec': 'MigrationExecCommand',
1652    'rdma': 'InetSocketAddress',
1653    'file': 'FileMigrationArgs' } }
1654
1655##
1656# @MigrationChannelType:
1657#
1658# The migration channel-type request options.
1659#
1660# @main: Main outbound migration channel.
1661# @cpr: Checkpoint and restart state channel.
1662#
1663# Since: 8.1
1664##
1665{ 'enum': 'MigrationChannelType',
1666  'data': [ 'main', 'cpr' ] }
1667
1668##
1669# @MigrationChannel:
1670#
1671# Migration stream channel parameters.
1672#
1673# @channel-type: Channel type for transferring packet information.
1674#
1675# @addr: Migration endpoint configuration on destination interface.
1676#
1677# Since: 8.1
1678##
1679{ 'struct': 'MigrationChannel',
1680  'data': {
1681      'channel-type': 'MigrationChannelType',
1682      'addr': 'MigrationAddress' } }
1683
1684##
1685# @migrate:
1686#
1687# Migrates the current running guest to another Virtual Machine.
1688#
1689# @uri: the Uniform Resource Identifier of the destination VM
1690#
1691# @channels: list of migration stream channels with each stream in the
1692#     list connected to a destination interface endpoint.
1693#
1694# @detach: this argument exists only for compatibility reasons and is
1695#     ignored by QEMU
1696#
1697# @resume: resume one paused migration, default "off".  (since 3.0)
1698#
1699# Features:
1700#
1701# @deprecated: Argument @detach is deprecated.
1702#
1703# Since: 0.14
1704#
1705# .. admonition:: Notes
1706#
1707#     1. The 'query-migrate' command should be used to check
1708#        migration's progress and final result (this information is
1709#        provided by the 'status' member).
1710#
1711#     2. The uri argument should have the Uniform Resource Identifier
1712#        of default destination VM.  This connection will be bound to
1713#        default network.
1714#
1715#     3. For now, number of migration streams is restricted to one,
1716#        i.e. number of items in 'channels' list is just 1.
1717#
1718#     4. The 'uri' and 'channels' arguments are mutually exclusive;
1719#        exactly one of the two should be present.
1720#
1721# .. qmp-example::
1722#
1723#     -> { "execute": "migrate", "arguments": { "uri": "tcp:0:4446" } }
1724#     <- { "return": {} }
1725#
1726#     -> { "execute": "migrate",
1727#          "arguments": {
1728#              "channels": [ { "channel-type": "main",
1729#                              "addr": { "transport": "socket",
1730#                                        "type": "inet",
1731#                                        "host": "10.12.34.9",
1732#                                        "port": "1050" } } ] } }
1733#     <- { "return": {} }
1734#
1735#     -> { "execute": "migrate",
1736#          "arguments": {
1737#              "channels": [ { "channel-type": "main",
1738#                              "addr": { "transport": "exec",
1739#                                        "args": [ "/bin/nc", "-p", "6000",
1740#                                                  "/some/sock" ] } } ] } }
1741#     <- { "return": {} }
1742#
1743#     -> { "execute": "migrate",
1744#          "arguments": {
1745#              "channels": [ { "channel-type": "main",
1746#                              "addr": { "transport": "rdma",
1747#                                        "host": "10.12.34.9",
1748#                                        "port": "1050" } } ] } }
1749#     <- { "return": {} }
1750#
1751#     -> { "execute": "migrate",
1752#          "arguments": {
1753#              "channels": [ { "channel-type": "main",
1754#                              "addr": { "transport": "file",
1755#                                        "filename": "/tmp/migfile",
1756#                                        "offset": "0x1000" } } ] } }
1757#     <- { "return": {} }
1758##
1759{ 'command': 'migrate',
1760  'data': {'*uri': 'str',
1761           '*channels': [ 'MigrationChannel' ],
1762           '*detach': { 'type': 'bool', 'features': [ 'deprecated' ] },
1763           '*resume': 'bool' } }
1764
1765##
1766# @migrate-incoming:
1767#
1768# Start an incoming migration.  QEMU must have been started with
1769# -incoming defer.
1770#
1771# @uri: The Uniform Resource Identifier identifying the source or
1772#     address to listen on
1773#
1774# @channels: list of migration stream channels with each stream in the
1775#     list connected to a destination interface endpoint.
1776#
1777# @exit-on-error: Exit on incoming migration failure.  Default true.
1778#     When set to false, the failure triggers a :qapi:event:`MIGRATION`
1779#     event, and error details could be retrieved with `query-migrate`.
1780#     (since 9.1)
1781#
1782# Since: 2.3
1783#
1784# .. admonition:: Notes
1785#
1786#     1. It's a bad idea to use a string for the uri, but it needs to
1787#        stay compatible with -incoming and the format of the uri is
1788#        already exposed above libvirt.
1789#
1790#     2. QEMU must be started with -incoming defer to allow
1791#        `migrate-incoming` to be used.
1792#
1793#     3. The uri format is the same as for -incoming
1794#
1795#     4. For now, number of migration streams is restricted to one,
1796#        i.e. number of items in 'channels' list is just 1.
1797#
1798#     5. The 'uri' and 'channels' arguments are mutually exclusive;
1799#        exactly one of the two should be present.
1800#
1801# .. qmp-example::
1802#
1803#     -> { "execute": "migrate-incoming",
1804#          "arguments": { "uri": "tcp:0:4446" } }
1805#     <- { "return": {} }
1806#
1807#     -> { "execute": "migrate-incoming",
1808#          "arguments": {
1809#              "channels": [ { "channel-type": "main",
1810#                              "addr": { "transport": "socket",
1811#                                        "type": "inet",
1812#                                        "host": "10.12.34.9",
1813#                                        "port": "1050" } } ] } }
1814#     <- { "return": {} }
1815#
1816#     -> { "execute": "migrate-incoming",
1817#          "arguments": {
1818#              "channels": [ { "channel-type": "main",
1819#                              "addr": { "transport": "exec",
1820#                                        "args": [ "/bin/nc", "-p", "6000",
1821#                                                  "/some/sock" ] } } ] } }
1822#     <- { "return": {} }
1823#
1824#     -> { "execute": "migrate-incoming",
1825#          "arguments": {
1826#              "channels": [ { "channel-type": "main",
1827#                              "addr": { "transport": "rdma",
1828#                                        "host": "10.12.34.9",
1829#                                        "port": "1050" } } ] } }
1830#     <- { "return": {} }
1831##
1832{ 'command': 'migrate-incoming',
1833             'data': {'*uri': 'str',
1834                      '*channels': [ 'MigrationChannel' ],
1835                      '*exit-on-error': 'bool' } }
1836
1837##
1838# @xen-save-devices-state:
1839#
1840# Save the state of all devices to file.  The RAM and the block
1841# devices of the VM are not saved by this command.
1842#
1843# @filename: the file to save the state of the devices to as binary
1844#     data.  See `xen-save-devices-state`.txt for a description of the
1845#     binary format.
1846#
1847# @live: Optional argument to ask QEMU to treat this command as part
1848#     of a live migration.  Default to true.  (since 2.11)
1849#
1850# Since: 1.1
1851#
1852# .. qmp-example::
1853#
1854#     -> { "execute": "xen-save-devices-state",
1855#          "arguments": { "filename": "/tmp/save" } }
1856#     <- { "return": {} }
1857##
1858{ 'command': 'xen-save-devices-state',
1859  'data': {'filename': 'str', '*live':'bool' } }
1860
1861##
1862# @xen-set-global-dirty-log:
1863#
1864# Enable or disable the global dirty log mode.
1865#
1866# @enable: true to enable, false to disable.
1867#
1868# Since: 1.3
1869#
1870# .. qmp-example::
1871#
1872#     -> { "execute": "xen-set-global-dirty-log",
1873#          "arguments": { "enable": true } }
1874#     <- { "return": {} }
1875##
1876{ 'command': 'xen-set-global-dirty-log', 'data': { 'enable': 'bool' } }
1877
1878##
1879# @xen-load-devices-state:
1880#
1881# Load the state of all devices from file.  The RAM and the block
1882# devices of the VM are not loaded by this command.
1883#
1884# @filename: the file to load the state of the devices from as binary
1885#     data.  See `xen-save-devices-state`.txt for a description of the
1886#     binary format.
1887#
1888# Since: 2.7
1889#
1890# .. qmp-example::
1891#
1892#     -> { "execute": "xen-load-devices-state",
1893#          "arguments": { "filename": "/tmp/resume" } }
1894#     <- { "return": {} }
1895##
1896{ 'command': 'xen-load-devices-state', 'data': {'filename': 'str'} }
1897
1898##
1899# @xen-set-replication:
1900#
1901# Enable or disable replication.
1902#
1903# @enable: true to enable, false to disable.
1904#
1905# @primary: true for primary or false for secondary.
1906#
1907# @failover: true to do failover, false to stop.  Cannot be specified
1908#     if 'enable' is true.  Default value is false.
1909#
1910# .. qmp-example::
1911#
1912#     -> { "execute": "xen-set-replication",
1913#          "arguments": {"enable": true, "primary": false} }
1914#     <- { "return": {} }
1915#
1916# Since: 2.9
1917##
1918{ 'command': 'xen-set-replication',
1919  'data': { 'enable': 'bool', 'primary': 'bool', '*failover': 'bool' },
1920  'if': 'CONFIG_REPLICATION' }
1921
1922##
1923# @ReplicationStatus:
1924#
1925# The result format for `query-xen-replication-status`.
1926#
1927# @error: true if an error happened, false if replication is normal.
1928#
1929# @desc: the human readable error description string, when @error is
1930#     'true'.
1931#
1932# Since: 2.9
1933##
1934{ 'struct': 'ReplicationStatus',
1935  'data': { 'error': 'bool', '*desc': 'str' },
1936  'if': 'CONFIG_REPLICATION' }
1937
1938##
1939# @query-xen-replication-status:
1940#
1941# Query replication status while the vm is running.
1942#
1943# TODO: This line is a hack to separate the example from the body
1944#
1945# .. qmp-example::
1946#
1947#     -> { "execute": "query-xen-replication-status" }
1948#     <- { "return": { "error": false } }
1949#
1950# Since: 2.9
1951##
1952{ 'command': 'query-xen-replication-status',
1953  'returns': 'ReplicationStatus',
1954  'if': 'CONFIG_REPLICATION' }
1955
1956##
1957# @xen-colo-do-checkpoint:
1958#
1959# Xen uses this command to notify replication to trigger a checkpoint.
1960#
1961# .. qmp-example::
1962#
1963#     -> { "execute": "xen-colo-do-checkpoint" }
1964#     <- { "return": {} }
1965#
1966# Since: 2.9
1967##
1968{ 'command': 'xen-colo-do-checkpoint',
1969  'if': 'CONFIG_REPLICATION' }
1970
1971##
1972# @COLOStatus:
1973#
1974# The result format for `query-colo-status`.
1975#
1976# @mode: COLO running mode.  If COLO is running, this field will
1977#     return 'primary' or 'secondary'.
1978#
1979# @last-mode: COLO last running mode.  If COLO is running, this field
1980#     will return same like mode field, after failover we can use this
1981#     field to get last colo mode.  (since 4.0)
1982#
1983# @reason: describes the reason for the COLO exit.
1984#
1985# Since: 3.1
1986##
1987{ 'struct': 'COLOStatus',
1988  'data': { 'mode': 'COLOMode', 'last-mode': 'COLOMode',
1989            'reason': 'COLOExitReason' },
1990  'if': 'CONFIG_REPLICATION' }
1991
1992##
1993# @query-colo-status:
1994#
1995# Query COLO status while the vm is running.
1996#
1997# TODO: This line is a hack to separate the example from the body
1998#
1999# .. qmp-example::
2000#
2001#     -> { "execute": "query-colo-status" }
2002#     <- { "return": { "mode": "primary", "last-mode": "none", "reason": "request" } }
2003#
2004# Since: 3.1
2005##
2006{ 'command': 'query-colo-status',
2007  'returns': 'COLOStatus',
2008  'if': 'CONFIG_REPLICATION' }
2009
2010##
2011# @migrate-recover:
2012#
2013# Provide a recovery migration stream URI.
2014#
2015# @uri: the URI to be used for the recovery of migration stream.
2016#
2017# .. qmp-example::
2018#
2019#     -> { "execute": "migrate-recover",
2020#          "arguments": { "uri": "tcp:192.168.1.200:12345" } }
2021#     <- { "return": {} }
2022#
2023# Since: 3.0
2024##
2025{ 'command': 'migrate-recover',
2026  'data': { 'uri': 'str' },
2027  'allow-oob': true }
2028
2029##
2030# @migrate-pause:
2031#
2032# Pause a migration.  Currently it only supports postcopy.
2033#
2034# .. qmp-example::
2035#
2036#     -> { "execute": "migrate-pause" }
2037#     <- { "return": {} }
2038#
2039# Since: 3.0
2040##
2041{ 'command': 'migrate-pause', 'allow-oob': true }
2042
2043##
2044# @UNPLUG_PRIMARY:
2045#
2046# Emitted from source side of a migration when migration state is
2047# WAIT_UNPLUG.  Device was unplugged by guest operating system.
2048# Device resources in QEMU are kept on standby to be able to re-plug
2049# it in case of migration failure.
2050#
2051# @device-id: QEMU device id of the unplugged device
2052#
2053# Since: 4.2
2054#
2055# .. qmp-example::
2056#
2057#     <- { "event": "UNPLUG_PRIMARY",
2058#          "data": { "device-id": "hostdev0" },
2059#          "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
2060##
2061{ 'event': 'UNPLUG_PRIMARY',
2062  'data': { 'device-id': 'str' } }
2063
2064##
2065# @DirtyRateVcpu:
2066#
2067# Dirty rate of vcpu.
2068#
2069# @id: vcpu index.
2070#
2071# @dirty-rate: dirty rate.
2072#
2073# Since: 6.2
2074##
2075{ 'struct': 'DirtyRateVcpu',
2076  'data': { 'id': 'int', 'dirty-rate': 'int64' } }
2077
2078##
2079# @DirtyRateStatus:
2080#
2081# Dirty page rate measurement status.
2082#
2083# @unstarted: measuring thread has not been started yet
2084#
2085# @measuring: measuring thread is running
2086#
2087# @measured: dirty page rate is measured and the results are available
2088#
2089# Since: 5.2
2090##
2091{ 'enum': 'DirtyRateStatus',
2092  'data': [ 'unstarted', 'measuring', 'measured'] }
2093
2094##
2095# @DirtyRateMeasureMode:
2096#
2097# Method used to measure dirty page rate.  Differences between
2098# available methods are explained in `calc-dirty-rate`.
2099#
2100# @page-sampling: use page sampling
2101#
2102# @dirty-ring: use dirty ring
2103#
2104# @dirty-bitmap: use dirty bitmap
2105#
2106# Since: 6.2
2107##
2108{ 'enum': 'DirtyRateMeasureMode',
2109  'data': ['page-sampling', 'dirty-ring', 'dirty-bitmap'] }
2110
2111##
2112# @TimeUnit:
2113#
2114# Specifies unit in which time-related value is specified.
2115#
2116# @second: value is in seconds
2117#
2118# @millisecond: value is in milliseconds
2119#
2120# Since: 8.2
2121##
2122{ 'enum': 'TimeUnit',
2123  'data': ['second', 'millisecond'] }
2124
2125##
2126# @DirtyRateInfo:
2127#
2128# Information about measured dirty page rate.
2129#
2130# @dirty-rate: an estimate of the dirty page rate of the VM in units
2131#     of MiB/s.  Value is present only when @status is 'measured'.
2132#
2133# @status: current status of dirty page rate measurements
2134#
2135# @start-time: start time in units of second for calculation
2136#
2137# @calc-time: time period for which dirty page rate was measured,
2138#     expressed and rounded down to @calc-time-unit.
2139#
2140# @calc-time-unit: time unit of @calc-time  (Since 8.2)
2141#
2142# @sample-pages: number of sampled pages per GiB of guest memory.
2143#     Valid only in page-sampling mode (Since 6.1)
2144#
2145# @mode: mode that was used to measure dirty page rate (Since 6.2)
2146#
2147# @vcpu-dirty-rate: dirty rate for each vCPU if dirty-ring mode was
2148#     specified (Since 6.2)
2149#
2150# Since: 5.2
2151##
2152{ 'struct': 'DirtyRateInfo',
2153  'data': {'*dirty-rate': 'int64',
2154           'status': 'DirtyRateStatus',
2155           'start-time': 'int64',
2156           'calc-time': 'int64',
2157           'calc-time-unit': 'TimeUnit',
2158           'sample-pages': 'uint64',
2159           'mode': 'DirtyRateMeasureMode',
2160           '*vcpu-dirty-rate': [ 'DirtyRateVcpu' ] } }
2161
2162##
2163# @calc-dirty-rate:
2164#
2165# Start measuring dirty page rate of the VM.  Results can be retrieved
2166# with `query-dirty-rate` after measurements are completed.
2167#
2168# Dirty page rate is the number of pages changed in a given time
2169# period expressed in MiB/s.  The following methods of calculation are
2170# available:
2171#
2172# 1. In page sampling mode, a random subset of pages are selected and
2173#    hashed twice: once at the beginning of measurement time period,
2174#    and once again at the end.  If two hashes for some page are
2175#    different, the page is counted as changed.  Since this method
2176#    relies on sampling and hashing, calculated dirty page rate is
2177#    only an estimate of its true value.  Increasing @sample-pages
2178#    improves estimation quality at the cost of higher computational
2179#    overhead.
2180#
2181# 2. Dirty bitmap mode captures writes to memory (for example by
2182#    temporarily revoking write access to all pages) and counting page
2183#    faults.  Information about modified pages is collected into a
2184#    bitmap, where each bit corresponds to one guest page.  This mode
2185#    requires that KVM accelerator property "dirty-ring-size" is *not*
2186#    set.
2187#
2188# 3. Dirty ring mode is similar to dirty bitmap mode, but the
2189#    information about modified pages is collected into ring buffer.
2190#    This mode tracks page modification per each vCPU separately.  It
2191#    requires that KVM accelerator property "dirty-ring-size" is set.
2192#
2193# @calc-time: time period for which dirty page rate is calculated.  By
2194#     default it is specified in seconds, but the unit can be set
2195#     explicitly with @calc-time-unit.  Note that larger @calc-time
2196#     values will typically result in smaller dirty page rates because
2197#     page dirtying is a one-time event.  Once some page is counted as
2198#     dirty during @calc-time period, further writes to this page will
2199#     not increase dirty page rate anymore.
2200#
2201# @calc-time-unit: time unit in which @calc-time is specified.  By
2202#     default it is seconds.  (Since 8.2)
2203#
2204# @sample-pages: number of sampled pages per each GiB of guest memory.
2205#     Default value is 512.  For 4KiB guest pages this corresponds to
2206#     sampling ratio of 0.2%.  This argument is used only in page
2207#     sampling mode.  (Since 6.1)
2208#
2209# @mode: mechanism for tracking dirty pages.  Default value is
2210#     'page-sampling'.  Others are 'dirty-bitmap' and 'dirty-ring'.
2211#     (Since 6.1)
2212#
2213# Since: 5.2
2214#
2215# .. qmp-example::
2216#
2217#     -> {"execute": "calc-dirty-rate", "arguments": {"calc-time": 1,
2218#                                                     "sample-pages": 512} }
2219#     <- { "return": {} }
2220#
2221# .. qmp-example::
2222#    :annotated:
2223#
2224#    Measure dirty rate using dirty bitmap for 500 milliseconds::
2225#
2226#     -> {"execute": "calc-dirty-rate", "arguments": {"calc-time": 500,
2227#         "calc-time-unit": "millisecond", "mode": "dirty-bitmap"} }
2228#
2229#     <- { "return": {} }
2230##
2231{ 'command': 'calc-dirty-rate', 'data': {'calc-time': 'int64',
2232                                         '*calc-time-unit': 'TimeUnit',
2233                                         '*sample-pages': 'int',
2234                                         '*mode': 'DirtyRateMeasureMode'} }
2235
2236##
2237# @query-dirty-rate:
2238#
2239# Query results of the most recent invocation of `calc-dirty-rate`.
2240#
2241# @calc-time-unit: time unit in which to report calculation time.
2242#     By default it is reported in seconds.  (Since 8.2)
2243#
2244# Since: 5.2
2245#
2246# .. qmp-example::
2247#    :title: Measurement is in progress
2248#
2249#     <- {"status": "measuring", "sample-pages": 512,
2250#         "mode": "page-sampling", "start-time": 1693900454, "calc-time": 10,
2251#         "calc-time-unit": "second"}
2252#
2253# .. qmp-example::
2254#    :title: Measurement has been completed
2255#
2256#     <- {"status": "measured", "sample-pages": 512, "dirty-rate": 108,
2257#         "mode": "page-sampling", "start-time": 1693900454, "calc-time": 10,
2258#         "calc-time-unit": "second"}
2259##
2260{ 'command': 'query-dirty-rate', 'data': {'*calc-time-unit': 'TimeUnit' },
2261                                 'returns': 'DirtyRateInfo' }
2262
2263##
2264# @DirtyLimitInfo:
2265#
2266# Dirty page rate limit information of a virtual CPU.
2267#
2268# @cpu-index: index of a virtual CPU.
2269#
2270# @limit-rate: upper limit of dirty page rate (MB/s) for a virtual
2271#     CPU, 0 means unlimited.
2272#
2273# @current-rate: current dirty page rate (MB/s) for a virtual CPU.
2274#
2275# Since: 7.1
2276##
2277{ 'struct': 'DirtyLimitInfo',
2278  'data': { 'cpu-index': 'int',
2279            'limit-rate': 'uint64',
2280            'current-rate': 'uint64' } }
2281
2282##
2283# @set-vcpu-dirty-limit:
2284#
2285# Set the upper limit of dirty page rate for virtual CPUs.
2286#
2287# Requires KVM with accelerator property "dirty-ring-size" set.  A
2288# virtual CPU's dirty page rate is a measure of its memory load.  To
2289# observe dirty page rates, use `calc-dirty-rate`.
2290#
2291# @cpu-index: index of a virtual CPU, default is all.
2292#
2293# @dirty-rate: upper limit of dirty page rate (MB/s) for virtual CPUs.
2294#
2295# Since: 7.1
2296#
2297# .. qmp-example::
2298#
2299#     -> {"execute": "set-vcpu-dirty-limit"}
2300#         "arguments": { "dirty-rate": 200,
2301#                        "cpu-index": 1 } }
2302#     <- { "return": {} }
2303##
2304{ 'command': 'set-vcpu-dirty-limit',
2305  'data': { '*cpu-index': 'int',
2306            'dirty-rate': 'uint64' } }
2307
2308##
2309# @cancel-vcpu-dirty-limit:
2310#
2311# Cancel the upper limit of dirty page rate for virtual CPUs.
2312#
2313# Cancel the dirty page limit for the vCPU which has been set with
2314# `set-vcpu-dirty-limit` command.  Note that this command requires
2315# support from dirty ring, same as the `set-vcpu-dirty-limit`.
2316#
2317# @cpu-index: index of a virtual CPU, default is all.
2318#
2319# Since: 7.1
2320#
2321# .. qmp-example::
2322#
2323#     -> {"execute": "cancel-vcpu-dirty-limit"},
2324#         "arguments": { "cpu-index": 1 } }
2325#     <- { "return": {} }
2326##
2327{ 'command': 'cancel-vcpu-dirty-limit',
2328  'data': { '*cpu-index': 'int'} }
2329
2330##
2331# @query-vcpu-dirty-limit:
2332#
2333# Return information about virtual CPU dirty page rate limits, if
2334# any.
2335#
2336# Since: 7.1
2337#
2338# .. qmp-example::
2339#
2340#     -> {"execute": "query-vcpu-dirty-limit"}
2341#     <- {"return": [
2342#            { "limit-rate": 60, "current-rate": 3, "cpu-index": 0},
2343#            { "limit-rate": 60, "current-rate": 3, "cpu-index": 1}]}
2344##
2345{ 'command': 'query-vcpu-dirty-limit',
2346  'returns': [ 'DirtyLimitInfo' ] }
2347
2348##
2349# @MigrationThreadInfo:
2350#
2351# Information about migrationthreads
2352#
2353# @name: the name of migration thread
2354#
2355# @thread-id: ID of the underlying host thread
2356#
2357# Since: 7.2
2358##
2359{ 'struct': 'MigrationThreadInfo',
2360  'data': {'name': 'str',
2361           'thread-id': 'int'} }
2362
2363##
2364# @query-migrationthreads:
2365#
2366# Return information of migration threads
2367#
2368# Features:
2369#
2370# @deprecated: This command is deprecated with no replacement yet.
2371#
2372# Since: 7.2
2373##
2374{ 'command': 'query-migrationthreads',
2375  'returns': ['MigrationThreadInfo'],
2376  'features': ['deprecated'] }
2377
2378##
2379# @snapshot-save:
2380#
2381# Save a VM snapshot
2382#
2383# @job-id: identifier for the newly created job
2384#
2385# @tag: name of the snapshot to create
2386#
2387# @vmstate: block device node name to save vmstate to
2388#
2389# @devices: list of block device node names to save a snapshot to
2390#
2391# Applications should not assume that the snapshot save is complete
2392# when this command returns.  The job commands / events must be used
2393# to determine completion and to fetch details of any errors that
2394# arise.
2395#
2396# Note that execution of the guest CPUs may be stopped during the time
2397# it takes to save the snapshot.  A future version of QEMU may ensure
2398# CPUs are executing continuously.
2399#
2400# It is strongly recommended that @devices contain all writable block
2401# device nodes if a consistent snapshot is required.
2402#
2403# If @tag already exists, an error will be reported
2404#
2405# .. qmp-example::
2406#
2407#     -> { "execute": "snapshot-save",
2408#          "arguments": {
2409#             "job-id": "snapsave0",
2410#             "tag": "my-snap",
2411#             "vmstate": "disk0",
2412#             "devices": ["disk0", "disk1"]
2413#          }
2414#        }
2415#     <- { "return": { } }
2416#     <- {"event": "JOB_STATUS_CHANGE",
2417#         "timestamp": {"seconds": 1432121972, "microseconds": 744001},
2418#         "data": {"status": "created", "id": "snapsave0"}}
2419#     <- {"event": "JOB_STATUS_CHANGE",
2420#         "timestamp": {"seconds": 1432122172, "microseconds": 744001},
2421#         "data": {"status": "running", "id": "snapsave0"}}
2422#     <- {"event": "STOP",
2423#         "timestamp": {"seconds": 1432122372, "microseconds": 744001} }
2424#     <- {"event": "RESUME",
2425#         "timestamp": {"seconds": 1432122572, "microseconds": 744001} }
2426#     <- {"event": "JOB_STATUS_CHANGE",
2427#         "timestamp": {"seconds": 1432122772, "microseconds": 744001},
2428#         "data": {"status": "waiting", "id": "snapsave0"}}
2429#     <- {"event": "JOB_STATUS_CHANGE",
2430#         "timestamp": {"seconds": 1432122972, "microseconds": 744001},
2431#         "data": {"status": "pending", "id": "snapsave0"}}
2432#     <- {"event": "JOB_STATUS_CHANGE",
2433#         "timestamp": {"seconds": 1432123172, "microseconds": 744001},
2434#         "data": {"status": "concluded", "id": "snapsave0"}}
2435#     -> {"execute": "query-jobs"}
2436#     <- {"return": [{"current-progress": 1,
2437#                     "status": "concluded",
2438#                     "total-progress": 1,
2439#                     "type": "snapshot-save",
2440#                     "id": "snapsave0"}]}
2441#
2442# Since: 6.0
2443##
2444{ 'command': 'snapshot-save',
2445  'data': { 'job-id': 'str',
2446            'tag': 'str',
2447            'vmstate': 'str',
2448            'devices': ['str'] } }
2449
2450##
2451# @snapshot-load:
2452#
2453# Load a VM snapshot
2454#
2455# @job-id: identifier for the newly created job
2456#
2457# @tag: name of the snapshot to load.
2458#
2459# @vmstate: block device node name to load vmstate from
2460#
2461# @devices: list of block device node names to load a snapshot from
2462#
2463# Applications should not assume that the snapshot load is complete
2464# when this command returns.  The job commands / events must be used
2465# to determine completion and to fetch details of any errors that
2466# arise.
2467#
2468# Note that execution of the guest CPUs will be stopped during the
2469# time it takes to load the snapshot.
2470#
2471# It is strongly recommended that @devices contain all writable block
2472# device nodes that can have changed since the original `snapshot-save`
2473# command execution.
2474#
2475# .. qmp-example::
2476#
2477#     -> { "execute": "snapshot-load",
2478#          "arguments": {
2479#             "job-id": "snapload0",
2480#             "tag": "my-snap",
2481#             "vmstate": "disk0",
2482#             "devices": ["disk0", "disk1"]
2483#          }
2484#        }
2485#     <- { "return": { } }
2486#     <- {"event": "JOB_STATUS_CHANGE",
2487#         "timestamp": {"seconds": 1472124172, "microseconds": 744001},
2488#         "data": {"status": "created", "id": "snapload0"}}
2489#     <- {"event": "JOB_STATUS_CHANGE",
2490#         "timestamp": {"seconds": 1472125172, "microseconds": 744001},
2491#         "data": {"status": "running", "id": "snapload0"}}
2492#     <- {"event": "STOP",
2493#         "timestamp": {"seconds": 1472125472, "microseconds": 744001} }
2494#     <- {"event": "RESUME",
2495#         "timestamp": {"seconds": 1472125872, "microseconds": 744001} }
2496#     <- {"event": "JOB_STATUS_CHANGE",
2497#         "timestamp": {"seconds": 1472126172, "microseconds": 744001},
2498#         "data": {"status": "waiting", "id": "snapload0"}}
2499#     <- {"event": "JOB_STATUS_CHANGE",
2500#         "timestamp": {"seconds": 1472127172, "microseconds": 744001},
2501#         "data": {"status": "pending", "id": "snapload0"}}
2502#     <- {"event": "JOB_STATUS_CHANGE",
2503#         "timestamp": {"seconds": 1472128172, "microseconds": 744001},
2504#         "data": {"status": "concluded", "id": "snapload0"}}
2505#     -> {"execute": "query-jobs"}
2506#     <- {"return": [{"current-progress": 1,
2507#                     "status": "concluded",
2508#                     "total-progress": 1,
2509#                     "type": "snapshot-load",
2510#                     "id": "snapload0"}]}
2511#
2512# Since: 6.0
2513##
2514{ 'command': 'snapshot-load',
2515  'data': { 'job-id': 'str',
2516            'tag': 'str',
2517            'vmstate': 'str',
2518            'devices': ['str'] } }
2519
2520##
2521# @snapshot-delete:
2522#
2523# Delete a VM snapshot
2524#
2525# @job-id: identifier for the newly created job
2526#
2527# @tag: name of the snapshot to delete.
2528#
2529# @devices: list of block device node names to delete a snapshot from
2530#
2531# Applications should not assume that the snapshot delete is complete
2532# when this command returns.  The job commands / events must be used
2533# to determine completion and to fetch details of any errors that
2534# arise.
2535#
2536# .. qmp-example::
2537#
2538#     -> { "execute": "snapshot-delete",
2539#          "arguments": {
2540#             "job-id": "snapdelete0",
2541#             "tag": "my-snap",
2542#             "devices": ["disk0", "disk1"]
2543#          }
2544#        }
2545#     <- { "return": { } }
2546#     <- {"event": "JOB_STATUS_CHANGE",
2547#         "timestamp": {"seconds": 1442124172, "microseconds": 744001},
2548#         "data": {"status": "created", "id": "snapdelete0"}}
2549#     <- {"event": "JOB_STATUS_CHANGE",
2550#         "timestamp": {"seconds": 1442125172, "microseconds": 744001},
2551#         "data": {"status": "running", "id": "snapdelete0"}}
2552#     <- {"event": "JOB_STATUS_CHANGE",
2553#         "timestamp": {"seconds": 1442126172, "microseconds": 744001},
2554#         "data": {"status": "waiting", "id": "snapdelete0"}}
2555#     <- {"event": "JOB_STATUS_CHANGE",
2556#         "timestamp": {"seconds": 1442127172, "microseconds": 744001},
2557#         "data": {"status": "pending", "id": "snapdelete0"}}
2558#     <- {"event": "JOB_STATUS_CHANGE",
2559#         "timestamp": {"seconds": 1442128172, "microseconds": 744001},
2560#         "data": {"status": "concluded", "id": "snapdelete0"}}
2561#     -> {"execute": "query-jobs"}
2562#     <- {"return": [{"current-progress": 1,
2563#                     "status": "concluded",
2564#                     "total-progress": 1,
2565#                     "type": "snapshot-delete",
2566#                     "id": "snapdelete0"}]}
2567#
2568# Since: 6.0
2569##
2570{ 'command': 'snapshot-delete',
2571  'data': { 'job-id': 'str',
2572            'tag': 'str',
2573            'devices': ['str'] } }
2574