block: add more commands to preconfig mode

Of the block device commands, those that are available outside system
emulators do not require a fully constructed machine by definition.
Allow running them before machine initialization has concluded.

Of the ones that are available inside system emulation, allow querying
the PR managers, and setting up accounting and throttling.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2020-11-03 04:37:20 -05:00
parent 39cd0c7f12
commit f55ba8018c
4 changed files with 110 additions and 48 deletions

View File

@ -78,6 +78,7 @@ ERST
.help = "resize a block image", .help = "resize a block image",
.cmd = hmp_block_resize, .cmd = hmp_block_resize,
.coroutine = true, .coroutine = true,
.flags = "p",
}, },
SRST SRST
@ -94,6 +95,7 @@ ERST
.params = "device [speed [base]]", .params = "device [speed [base]]",
.help = "copy data from a backing file into a block device", .help = "copy data from a backing file into a block device",
.cmd = hmp_block_stream, .cmd = hmp_block_stream,
.flags = "p",
}, },
SRST SRST
@ -107,6 +109,7 @@ ERST
.params = "device speed", .params = "device speed",
.help = "set maximum speed for a background block operation", .help = "set maximum speed for a background block operation",
.cmd = hmp_block_job_set_speed, .cmd = hmp_block_job_set_speed,
.flags = "p",
}, },
SRST SRST
@ -122,6 +125,7 @@ ERST
"\n\t\t\t if you want to abort the operation immediately" "\n\t\t\t if you want to abort the operation immediately"
"\n\t\t\t instead of keep running until data is in sync)", "\n\t\t\t instead of keep running until data is in sync)",
.cmd = hmp_block_job_cancel, .cmd = hmp_block_job_cancel,
.flags = "p",
}, },
SRST SRST
@ -135,6 +139,7 @@ ERST
.params = "device", .params = "device",
.help = "stop an active background block operation", .help = "stop an active background block operation",
.cmd = hmp_block_job_complete, .cmd = hmp_block_job_complete,
.flags = "p",
}, },
SRST SRST
@ -149,6 +154,7 @@ ERST
.params = "device", .params = "device",
.help = "pause an active background block operation", .help = "pause an active background block operation",
.cmd = hmp_block_job_pause, .cmd = hmp_block_job_pause,
.flags = "p",
}, },
SRST SRST
@ -162,6 +168,7 @@ ERST
.params = "device", .params = "device",
.help = "resume a paused background block operation", .help = "resume a paused background block operation",
.cmd = hmp_block_job_resume, .cmd = hmp_block_job_resume,
.flags = "p",
}, },
SRST SRST
@ -1406,6 +1413,7 @@ ERST
.params = "nbd_server_start [-a] [-w] host:port", .params = "nbd_server_start [-a] [-w] host:port",
.help = "serve block devices on the given host and port", .help = "serve block devices on the given host and port",
.cmd = hmp_nbd_server_start, .cmd = hmp_nbd_server_start,
.flags = "p",
}, },
SRST SRST
``nbd_server_start`` *host*:*port* ``nbd_server_start`` *host*:*port*
@ -1421,6 +1429,7 @@ ERST
.params = "nbd_server_add [-w] device [name]", .params = "nbd_server_add [-w] device [name]",
.help = "export a block device via NBD", .help = "export a block device via NBD",
.cmd = hmp_nbd_server_add, .cmd = hmp_nbd_server_add,
.flags = "p",
}, },
SRST SRST
``nbd_server_add`` *device* [ *name* ] ``nbd_server_add`` *device* [ *name* ]
@ -1436,6 +1445,7 @@ ERST
.params = "nbd_server_remove [-f] name", .params = "nbd_server_remove [-f] name",
.help = "remove an export previously exposed via NBD", .help = "remove an export previously exposed via NBD",
.cmd = hmp_nbd_server_remove, .cmd = hmp_nbd_server_remove,
.flags = "p",
}, },
SRST SRST
``nbd_server_remove [-f]`` *name* ``nbd_server_remove [-f]`` *name*
@ -1452,6 +1462,7 @@ ERST
.params = "nbd_server_stop", .params = "nbd_server_stop",
.help = "stop serving block devices using the NBD protocol", .help = "stop serving block devices using the NBD protocol",
.cmd = hmp_nbd_server_stop, .cmd = hmp_nbd_server_stop,
.flags = "p",
}, },
SRST SRST
``nbd_server_stop`` ``nbd_server_stop``
@ -1481,6 +1492,7 @@ ERST
.params = "getfd name", .params = "getfd name",
.help = "receive a file descriptor via SCM rights and assign it a name", .help = "receive a file descriptor via SCM rights and assign it a name",
.cmd = hmp_getfd, .cmd = hmp_getfd,
.flags = "p",
}, },
SRST SRST
@ -1496,6 +1508,7 @@ ERST
.params = "closefd name", .params = "closefd name",
.help = "close a file descriptor previously passed via SCM rights", .help = "close a file descriptor previously passed via SCM rights",
.cmd = hmp_closefd, .cmd = hmp_closefd,
.flags = "p",
}, },
SRST SRST
@ -1511,6 +1524,7 @@ ERST
.params = "device bps bps_rd bps_wr iops iops_rd iops_wr", .params = "device bps bps_rd bps_wr iops iops_rd iops_wr",
.help = "change I/O throttle limits for a block drive", .help = "change I/O throttle limits for a block drive",
.cmd = hmp_block_set_io_throttle, .cmd = hmp_block_set_io_throttle,
.flags = "p",
}, },
SRST SRST

View File

@ -737,7 +737,8 @@
# } # }
# #
## ##
{ 'command': 'query-block', 'returns': ['BlockInfo'] } { 'command': 'query-block', 'returns': ['BlockInfo'],
'allow-preconfig': true }
## ##
# @BlockDeviceTimedStats: # @BlockDeviceTimedStats:
@ -1113,7 +1114,8 @@
## ##
{ 'command': 'query-blockstats', { 'command': 'query-blockstats',
'data': { '*query-nodes': 'bool' }, 'data': { '*query-nodes': 'bool' },
'returns': ['BlockStats'] } 'returns': ['BlockStats'],
'allow-preconfig': true }
## ##
# @BlockdevOnError: # @BlockdevOnError:
@ -1262,7 +1264,8 @@
# #
# Since: 1.1 # Since: 1.1
## ##
{ 'command': 'query-block-jobs', 'returns': ['BlockJobInfo'] } { 'command': 'query-block-jobs', 'returns': ['BlockJobInfo'],
'allow-preconfig': true }
## ##
# @block_resize: # @block_resize:
@ -1293,7 +1296,8 @@
'data': { '*device': 'str', 'data': { '*device': 'str',
'*node-name': 'str', '*node-name': 'str',
'size': 'int' }, 'size': 'int' },
'coroutine': true } 'coroutine': true,
'allow-preconfig': true }
## ##
# @NewImageMode: # @NewImageMode:
@ -1509,7 +1513,8 @@
# #
## ##
{ 'command': 'blockdev-snapshot-sync', { 'command': 'blockdev-snapshot-sync',
'data': 'BlockdevSnapshotSync' } 'data': 'BlockdevSnapshotSync',
'allow-preconfig': true }
## ##
# @blockdev-snapshot: # @blockdev-snapshot:
@ -1550,7 +1555,8 @@
## ##
{ 'command': 'blockdev-snapshot', { 'command': 'blockdev-snapshot',
'data': 'BlockdevSnapshot', 'data': 'BlockdevSnapshot',
'features': [ 'allow-write-only-overlay' ] } 'features': [ 'allow-write-only-overlay' ],
'allow-preconfig': true }
## ##
# @change-backing-file: # @change-backing-file:
@ -1582,7 +1588,8 @@
## ##
{ 'command': 'change-backing-file', { 'command': 'change-backing-file',
'data': { 'device': 'str', 'image-node-name': 'str', 'data': { 'device': 'str', 'image-node-name': 'str',
'backing-file': 'str' } } 'backing-file': 'str' },
'allow-preconfig': true }
## ##
# @block-commit: # @block-commit:
@ -1692,7 +1699,8 @@
'*backing-file': 'str', '*speed': 'int', '*backing-file': 'str', '*speed': 'int',
'*on-error': 'BlockdevOnError', '*on-error': 'BlockdevOnError',
'*filter-node-name': 'str', '*filter-node-name': 'str',
'*auto-finalize': 'bool', '*auto-dismiss': 'bool' } } '*auto-finalize': 'bool', '*auto-dismiss': 'bool' },
'allow-preconfig': true }
## ##
# @drive-backup: # @drive-backup:
@ -1721,7 +1729,8 @@
# #
## ##
{ 'command': 'drive-backup', 'boxed': true, { 'command': 'drive-backup', 'boxed': true,
'data': 'DriveBackup', 'features': ['deprecated'] } 'data': 'DriveBackup', 'features': ['deprecated'],
'allow-preconfig': true }
## ##
# @blockdev-backup: # @blockdev-backup:
@ -1747,7 +1756,8 @@
# #
## ##
{ 'command': 'blockdev-backup', 'boxed': true, { 'command': 'blockdev-backup', 'boxed': true,
'data': 'BlockdevBackup' } 'data': 'BlockdevBackup',
'allow-preconfig': true }
## ##
# @query-named-block-nodes: # @query-named-block-nodes:
@ -1813,7 +1823,8 @@
## ##
{ 'command': 'query-named-block-nodes', { 'command': 'query-named-block-nodes',
'returns': [ 'BlockDeviceInfo' ], 'returns': [ 'BlockDeviceInfo' ],
'data': { '*flat': 'bool' } } 'data': { '*flat': 'bool' },
'allow-preconfig': true }
## ##
# @XDbgBlockGraphNodeType: # @XDbgBlockGraphNodeType:
@ -1922,7 +1933,8 @@
# Since: 4.0 # Since: 4.0
## ##
{ 'command': 'x-debug-query-block-graph', 'returns': 'XDbgBlockGraph', { 'command': 'x-debug-query-block-graph', 'returns': 'XDbgBlockGraph',
'features': [ 'unstable' ] } 'features': [ 'unstable' ],
'allow-preconfig': true }
## ##
# @drive-mirror: # @drive-mirror:
@ -1950,7 +1962,8 @@
# #
## ##
{ 'command': 'drive-mirror', 'boxed': true, { 'command': 'drive-mirror', 'boxed': true,
'data': 'DriveMirror' } 'data': 'DriveMirror',
'allow-preconfig': true }
## ##
# @DriveMirror: # @DriveMirror:
@ -2123,7 +2136,8 @@
# #
## ##
{ 'command': 'block-dirty-bitmap-add', { 'command': 'block-dirty-bitmap-add',
'data': 'BlockDirtyBitmapAdd' } 'data': 'BlockDirtyBitmapAdd',
'allow-preconfig': true }
## ##
# @block-dirty-bitmap-remove: # @block-dirty-bitmap-remove:
@ -2147,7 +2161,8 @@
# #
## ##
{ 'command': 'block-dirty-bitmap-remove', { 'command': 'block-dirty-bitmap-remove',
'data': 'BlockDirtyBitmap' } 'data': 'BlockDirtyBitmap',
'allow-preconfig': true }
## ##
# @block-dirty-bitmap-clear: # @block-dirty-bitmap-clear:
@ -2170,7 +2185,8 @@
# #
## ##
{ 'command': 'block-dirty-bitmap-clear', { 'command': 'block-dirty-bitmap-clear',
'data': 'BlockDirtyBitmap' } 'data': 'BlockDirtyBitmap',
'allow-preconfig': true }
## ##
# @block-dirty-bitmap-enable: # @block-dirty-bitmap-enable:
@ -2191,7 +2207,8 @@
# #
## ##
{ 'command': 'block-dirty-bitmap-enable', { 'command': 'block-dirty-bitmap-enable',
'data': 'BlockDirtyBitmap' } 'data': 'BlockDirtyBitmap',
'allow-preconfig': true }
## ##
# @block-dirty-bitmap-disable: # @block-dirty-bitmap-disable:
@ -2212,7 +2229,8 @@
# #
## ##
{ 'command': 'block-dirty-bitmap-disable', { 'command': 'block-dirty-bitmap-disable',
'data': 'BlockDirtyBitmap' } 'data': 'BlockDirtyBitmap',
'allow-preconfig': true }
## ##
# @block-dirty-bitmap-merge: # @block-dirty-bitmap-merge:
@ -2244,7 +2262,8 @@
# #
## ##
{ 'command': 'block-dirty-bitmap-merge', { 'command': 'block-dirty-bitmap-merge',
'data': 'BlockDirtyBitmapMerge' } 'data': 'BlockDirtyBitmapMerge',
'allow-preconfig': true }
## ##
# @BlockDirtyBitmapSha256: # @BlockDirtyBitmapSha256:
@ -2275,7 +2294,8 @@
## ##
{ 'command': 'x-debug-block-dirty-bitmap-sha256', { 'command': 'x-debug-block-dirty-bitmap-sha256',
'data': 'BlockDirtyBitmap', 'returns': 'BlockDirtyBitmapSha256', 'data': 'BlockDirtyBitmap', 'returns': 'BlockDirtyBitmapSha256',
'features': [ 'unstable' ] } 'features': [ 'unstable' ],
'allow-preconfig': true }
## ##
# @blockdev-mirror: # @blockdev-mirror:
@ -2361,7 +2381,8 @@
'*on-target-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError',
'*filter-node-name': 'str', '*filter-node-name': 'str',
'*copy-mode': 'MirrorCopyMode', '*copy-mode': 'MirrorCopyMode',
'*auto-finalize': 'bool', '*auto-dismiss': 'bool' } } '*auto-finalize': 'bool', '*auto-dismiss': 'bool' },
'allow-preconfig': true }
## ##
# @BlockIOThrottle: # @BlockIOThrottle:
@ -2663,7 +2684,8 @@
'*base-node': 'str', '*backing-file': 'str', '*bottom': 'str', '*base-node': 'str', '*backing-file': 'str', '*bottom': 'str',
'*speed': 'int', '*on-error': 'BlockdevOnError', '*speed': 'int', '*on-error': 'BlockdevOnError',
'*filter-node-name': 'str', '*filter-node-name': 'str',
'*auto-finalize': 'bool', '*auto-dismiss': 'bool' } } '*auto-finalize': 'bool', '*auto-dismiss': 'bool' },
'allow-preconfig': true }
## ##
# @block-job-set-speed: # @block-job-set-speed:
@ -2687,7 +2709,8 @@
# Since: 1.1 # Since: 1.1
## ##
{ 'command': 'block-job-set-speed', { 'command': 'block-job-set-speed',
'data': { 'device': 'str', 'speed': 'int' } } 'data': { 'device': 'str', 'speed': 'int' },
'allow-preconfig': true }
## ##
# @block-job-cancel: # @block-job-cancel:
@ -2726,7 +2749,8 @@
# #
# Since: 1.1 # Since: 1.1
## ##
{ 'command': 'block-job-cancel', 'data': { 'device': 'str', '*force': 'bool' } } { 'command': 'block-job-cancel', 'data': { 'device': 'str', '*force': 'bool' },
'allow-preconfig': true }
## ##
# @block-job-pause: # @block-job-pause:
@ -2750,7 +2774,8 @@
# #
# Since: 1.3 # Since: 1.3
## ##
{ 'command': 'block-job-pause', 'data': { 'device': 'str' } } { 'command': 'block-job-pause', 'data': { 'device': 'str' },
'allow-preconfig': true }
## ##
# @block-job-resume: # @block-job-resume:
@ -2772,7 +2797,8 @@
# #
# Since: 1.3 # Since: 1.3
## ##
{ 'command': 'block-job-resume', 'data': { 'device': 'str' } } { 'command': 'block-job-resume', 'data': { 'device': 'str' },
'allow-preconfig': true }
## ##
# @block-job-complete: # @block-job-complete:
@ -2800,7 +2826,8 @@
# #
# Since: 1.3 # Since: 1.3
## ##
{ 'command': 'block-job-complete', 'data': { 'device': 'str' } } { 'command': 'block-job-complete', 'data': { 'device': 'str' },
'allow-preconfig': true }
## ##
# @block-job-dismiss: # @block-job-dismiss:
@ -2820,7 +2847,8 @@
# #
# Since: 2.12 # Since: 2.12
## ##
{ 'command': 'block-job-dismiss', 'data': { 'id': 'str' } } { 'command': 'block-job-dismiss', 'data': { 'id': 'str' },
'allow-preconfig': true }
## ##
# @block-job-finalize: # @block-job-finalize:
@ -2838,7 +2866,8 @@
# #
# Since: 2.12 # Since: 2.12
## ##
{ 'command': 'block-job-finalize', 'data': { 'id': 'str' } } { 'command': 'block-job-finalize', 'data': { 'id': 'str' },
'allow-preconfig': true }
## ##
# @BlockdevDiscardOptions: # @BlockdevDiscardOptions:
@ -4354,7 +4383,8 @@
# <- { "return": {} } # <- { "return": {} }
# #
## ##
{ 'command': 'blockdev-add', 'data': 'BlockdevOptions', 'boxed': true } { 'command': 'blockdev-add', 'data': 'BlockdevOptions', 'boxed': true,
'allow-preconfig': true }
## ##
# @blockdev-reopen: # @blockdev-reopen:
@ -4398,7 +4428,8 @@
# Since: 6.1 # Since: 6.1
## ##
{ 'command': 'blockdev-reopen', { 'command': 'blockdev-reopen',
'data': { 'options': ['BlockdevOptions'] } } 'data': { 'options': ['BlockdevOptions'] },
'allow-preconfig': true }
## ##
# @blockdev-del: # @blockdev-del:
@ -4431,7 +4462,8 @@
# <- { "return": {} } # <- { "return": {} }
# #
## ##
{ 'command': 'blockdev-del', 'data': { 'node-name': 'str' } } { 'command': 'blockdev-del', 'data': { 'node-name': 'str' },
'allow-preconfig': true }
## ##
# @BlockdevCreateOptionsFile: # @BlockdevCreateOptionsFile:
@ -4872,7 +4904,8 @@
## ##
{ 'command': 'blockdev-create', { 'command': 'blockdev-create',
'data': { 'job-id': 'str', 'data': { 'job-id': 'str',
'options': 'BlockdevCreateOptions' } } 'options': 'BlockdevCreateOptions' },
'allow-preconfig': true }
## ##
# @BlockdevAmendOptionsLUKS: # @BlockdevAmendOptionsLUKS:
@ -4944,7 +4977,8 @@
'node-name': 'str', 'node-name': 'str',
'options': 'BlockdevAmendOptions', 'options': 'BlockdevAmendOptions',
'*force': 'bool' }, '*force': 'bool' },
'features': [ 'unstable' ] } 'features': [ 'unstable' ],
'allow-preconfig': true }
## ##
# @BlockErrorAction: # @BlockErrorAction:
@ -5294,7 +5328,8 @@
# #
## ##
{ 'command': 'block-set-write-threshold', { 'command': 'block-set-write-threshold',
'data': { 'node-name': 'str', 'write-threshold': 'uint64' } } 'data': { 'node-name': 'str', 'write-threshold': 'uint64' },
'allow-preconfig': true }
## ##
# @x-blockdev-change: # @x-blockdev-change:
@ -5355,7 +5390,8 @@
'data' : { 'parent': 'str', 'data' : { 'parent': 'str',
'*child': 'str', '*child': 'str',
'*node': 'str' }, '*node': 'str' },
'features': [ 'unstable' ] } 'features': [ 'unstable' ],
'allow-preconfig': true }
## ##
# @x-blockdev-set-iothread: # @x-blockdev-set-iothread:
@ -5397,7 +5433,8 @@
'data' : { 'node-name': 'str', 'data' : { 'node-name': 'str',
'iothread': 'StrOrNull', 'iothread': 'StrOrNull',
'*force': 'bool' }, '*force': 'bool' },
'features': [ 'unstable' ] } 'features': [ 'unstable' ],
'allow-preconfig': true }
## ##
# @QuorumOpType: # @QuorumOpType:
@ -5529,7 +5566,8 @@
# #
## ##
{ 'command': 'blockdev-snapshot-internal-sync', { 'command': 'blockdev-snapshot-internal-sync',
'data': 'BlockdevSnapshotInternal' } 'data': 'BlockdevSnapshotInternal',
'allow-preconfig': true }
## ##
# @blockdev-snapshot-delete-internal-sync: # @blockdev-snapshot-delete-internal-sync:
@ -5576,4 +5614,5 @@
## ##
{ 'command': 'blockdev-snapshot-delete-internal-sync', { 'command': 'blockdev-snapshot-delete-internal-sync',
'data': { 'device': 'str', '*id': 'str', '*name': 'str'}, 'data': { 'device': 'str', '*id': 'str', '*name': 'str'},
'returns': 'SnapshotInfo' } 'returns': 'SnapshotInfo',
'allow-preconfig': true }

View File

@ -65,7 +65,8 @@
'data': { 'addr': 'SocketAddressLegacy', 'data': { 'addr': 'SocketAddressLegacy',
'*tls-creds': 'str', '*tls-creds': 'str',
'*tls-authz': 'str', '*tls-authz': 'str',
'*max-connections': 'uint32' } } '*max-connections': 'uint32' },
'allow-preconfig': true }
## ##
# @BlockExportOptionsNbdBase: # @BlockExportOptionsNbdBase:
@ -215,7 +216,8 @@
# Since: 1.3 # Since: 1.3
## ##
{ 'command': 'nbd-server-add', { 'command': 'nbd-server-add',
'data': 'NbdServerAddOptions', 'boxed': true, 'features': ['deprecated'] } 'data': 'NbdServerAddOptions', 'boxed': true, 'features': ['deprecated'],
'allow-preconfig': true }
## ##
# @BlockExportRemoveMode: # @BlockExportRemoveMode:
@ -260,7 +262,8 @@
## ##
{ 'command': 'nbd-server-remove', { 'command': 'nbd-server-remove',
'data': {'name': 'str', '*mode': 'BlockExportRemoveMode'}, 'data': {'name': 'str', '*mode': 'BlockExportRemoveMode'},
'features': ['deprecated'] } 'features': ['deprecated'],
'allow-preconfig': true }
## ##
# @nbd-server-stop: # @nbd-server-stop:
@ -270,7 +273,8 @@
# #
# Since: 1.3 # Since: 1.3
## ##
{ 'command': 'nbd-server-stop' } { 'command': 'nbd-server-stop',
'allow-preconfig': true }
## ##
# @BlockExportType: # @BlockExportType:
@ -342,7 +346,8 @@
# Since: 5.2 # Since: 5.2
## ##
{ 'command': 'block-export-add', { 'command': 'block-export-add',
'data': 'BlockExportOptions', 'boxed': true } 'data': 'BlockExportOptions', 'boxed': true,
'allow-preconfig': true }
## ##
# @block-export-del: # @block-export-del:
@ -362,7 +367,8 @@
# Since: 5.2 # Since: 5.2
## ##
{ 'command': 'block-export-del', { 'command': 'block-export-del',
'data': { 'id': 'str', '*mode': 'BlockExportRemoveMode' } } 'data': { 'id': 'str', '*mode': 'BlockExportRemoveMode' },
'allow-preconfig': true }
## ##
# @BLOCK_EXPORT_DELETED: # @BLOCK_EXPORT_DELETED:
@ -406,4 +412,5 @@
# #
# Since: 5.2 # Since: 5.2
## ##
{ 'command': 'query-block-exports', 'returns': ['BlockExportInfo'] } { 'command': 'query-block-exports', 'returns': ['BlockExportInfo'],
'allow-preconfig': true }

View File

@ -496,7 +496,8 @@
# <- { "return": {} } # <- { "return": {} }
## ##
{ 'command': 'block_set_io_throttle', 'boxed': true, { 'command': 'block_set_io_throttle', 'boxed': true,
'data': 'BlockIOThrottle' } 'data': 'BlockIOThrottle',
'allow-preconfig': true }
## ##
# @block-latency-histogram-set: # @block-latency-histogram-set:
@ -572,4 +573,5 @@
'*boundaries': ['uint64'], '*boundaries': ['uint64'],
'*boundaries-read': ['uint64'], '*boundaries-read': ['uint64'],
'*boundaries-write': ['uint64'], '*boundaries-write': ['uint64'],
'*boundaries-flush': ['uint64'] } } '*boundaries-flush': ['uint64'] },
'allow-preconfig': true }