block: Move common QMP commands to block-core QAPI module
block-core is for everything that isn't related to the system emulator. Internal snapshots, the NBD server and quorum events make sense in the tools, too, so move them to block-core. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20200224143008.13362-5-kwolf@redhat.com> Acked-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
12c929bca2
commit
b3cf1ec06a
@ -5447,3 +5447,286 @@
|
||||
'data' : { 'node-name': 'str',
|
||||
'iothread': 'StrOrNull',
|
||||
'*force': 'bool' } }
|
||||
|
||||
##
|
||||
# @nbd-server-start:
|
||||
#
|
||||
# Start an NBD server listening on the given host and port. Block
|
||||
# devices can then be exported using @nbd-server-add. The NBD
|
||||
# server will present them as named exports; for example, another
|
||||
# QEMU instance could refer to them as "nbd:HOST:PORT:exportname=NAME".
|
||||
#
|
||||
# @addr: Address on which to listen.
|
||||
# @tls-creds: ID of the TLS credentials object (since 2.6).
|
||||
# @tls-authz: ID of the QAuthZ authorization object used to validate
|
||||
# the client's x509 distinguished name. This object is
|
||||
# is only resolved at time of use, so can be deleted and
|
||||
# recreated on the fly while the NBD server is active.
|
||||
# If missing, it will default to denying access (since 4.0).
|
||||
#
|
||||
# Returns: error if the server is already running.
|
||||
#
|
||||
# Since: 1.3.0
|
||||
##
|
||||
{ 'command': 'nbd-server-start',
|
||||
'data': { 'addr': 'SocketAddressLegacy',
|
||||
'*tls-creds': 'str',
|
||||
'*tls-authz': 'str'} }
|
||||
|
||||
##
|
||||
# @nbd-server-add:
|
||||
#
|
||||
# Export a block node to QEMU's embedded NBD server.
|
||||
#
|
||||
# @device: The device name or node name of the node to be exported
|
||||
#
|
||||
# @name: Export name. If unspecified, the @device parameter is used as the
|
||||
# export name. (Since 2.12)
|
||||
#
|
||||
# @description: Free-form description of the export, up to 4096 bytes.
|
||||
# (Since 5.0)
|
||||
#
|
||||
# @writable: Whether clients should be able to write to the device via the
|
||||
# NBD connection (default false).
|
||||
#
|
||||
# @bitmap: Also export the dirty bitmap reachable from @device, so the
|
||||
# NBD client can use NBD_OPT_SET_META_CONTEXT with
|
||||
# "qemu:dirty-bitmap:NAME" to inspect the bitmap. (since 4.0)
|
||||
#
|
||||
# Returns: error if the server is not running, or export with the same name
|
||||
# already exists.
|
||||
#
|
||||
# Since: 1.3.0
|
||||
##
|
||||
{ 'command': 'nbd-server-add',
|
||||
'data': {'device': 'str', '*name': 'str', '*description': 'str',
|
||||
'*writable': 'bool', '*bitmap': 'str' } }
|
||||
|
||||
##
|
||||
# @NbdServerRemoveMode:
|
||||
#
|
||||
# Mode for removing an NBD export.
|
||||
#
|
||||
# @safe: Remove export if there are no existing connections, fail otherwise.
|
||||
#
|
||||
# @hard: Drop all connections immediately and remove export.
|
||||
#
|
||||
# Potential additional modes to be added in the future:
|
||||
#
|
||||
# hide: Just hide export from new clients, leave existing connections as is.
|
||||
# Remove export after all clients are disconnected.
|
||||
#
|
||||
# soft: Hide export from new clients, answer with ESHUTDOWN for all further
|
||||
# requests from existing clients.
|
||||
#
|
||||
# Since: 2.12
|
||||
##
|
||||
{'enum': 'NbdServerRemoveMode', 'data': ['safe', 'hard']}
|
||||
|
||||
##
|
||||
# @nbd-server-remove:
|
||||
#
|
||||
# Remove NBD export by name.
|
||||
#
|
||||
# @name: Export name.
|
||||
#
|
||||
# @mode: Mode of command operation. See @NbdServerRemoveMode description.
|
||||
# Default is 'safe'.
|
||||
#
|
||||
# Returns: error if
|
||||
# - the server is not running
|
||||
# - export is not found
|
||||
# - mode is 'safe' and there are existing connections
|
||||
#
|
||||
# Since: 2.12
|
||||
##
|
||||
{ 'command': 'nbd-server-remove',
|
||||
'data': {'name': 'str', '*mode': 'NbdServerRemoveMode'} }
|
||||
|
||||
##
|
||||
# @nbd-server-stop:
|
||||
#
|
||||
# Stop QEMU's embedded NBD server, and unregister all devices previously
|
||||
# added via @nbd-server-add.
|
||||
#
|
||||
# Since: 1.3.0
|
||||
##
|
||||
{ 'command': 'nbd-server-stop' }
|
||||
|
||||
##
|
||||
# @QuorumOpType:
|
||||
#
|
||||
# An enumeration of the quorum operation types
|
||||
#
|
||||
# @read: read operation
|
||||
#
|
||||
# @write: write operation
|
||||
#
|
||||
# @flush: flush operation
|
||||
#
|
||||
# Since: 2.6
|
||||
##
|
||||
{ 'enum': 'QuorumOpType',
|
||||
'data': [ 'read', 'write', 'flush' ] }
|
||||
|
||||
##
|
||||
# @QUORUM_FAILURE:
|
||||
#
|
||||
# Emitted by the Quorum block driver if it fails to establish a quorum
|
||||
#
|
||||
# @reference: device name if defined else node name
|
||||
#
|
||||
# @sector-num: number of the first sector of the failed read operation
|
||||
#
|
||||
# @sectors-count: failed read operation sector count
|
||||
#
|
||||
# Note: This event is rate-limited.
|
||||
#
|
||||
# Since: 2.0
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# <- { "event": "QUORUM_FAILURE",
|
||||
# "data": { "reference": "usr1", "sector-num": 345435, "sectors-count": 5 },
|
||||
# "timestamp": { "seconds": 1344522075, "microseconds": 745528 } }
|
||||
#
|
||||
##
|
||||
{ 'event': 'QUORUM_FAILURE',
|
||||
'data': { 'reference': 'str', 'sector-num': 'int', 'sectors-count': 'int' } }
|
||||
|
||||
##
|
||||
# @QUORUM_REPORT_BAD:
|
||||
#
|
||||
# Emitted to report a corruption of a Quorum file
|
||||
#
|
||||
# @type: quorum operation type (Since 2.6)
|
||||
#
|
||||
# @error: error message. Only present on failure. This field
|
||||
# contains a human-readable error message. There are no semantics other
|
||||
# than that the block layer reported an error and clients should not
|
||||
# try to interpret the error string.
|
||||
#
|
||||
# @node-name: the graph node name of the block driver state
|
||||
#
|
||||
# @sector-num: number of the first sector of the failed read operation
|
||||
#
|
||||
# @sectors-count: failed read operation sector count
|
||||
#
|
||||
# Note: This event is rate-limited.
|
||||
#
|
||||
# Since: 2.0
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# 1. Read operation
|
||||
#
|
||||
# { "event": "QUORUM_REPORT_BAD",
|
||||
# "data": { "node-name": "node0", "sector-num": 345435, "sectors-count": 5,
|
||||
# "type": "read" },
|
||||
# "timestamp": { "seconds": 1344522075, "microseconds": 745528 } }
|
||||
#
|
||||
# 2. Flush operation
|
||||
#
|
||||
# { "event": "QUORUM_REPORT_BAD",
|
||||
# "data": { "node-name": "node0", "sector-num": 0, "sectors-count": 2097120,
|
||||
# "type": "flush", "error": "Broken pipe" },
|
||||
# "timestamp": { "seconds": 1456406829, "microseconds": 291763 } }
|
||||
#
|
||||
##
|
||||
{ 'event': 'QUORUM_REPORT_BAD',
|
||||
'data': { 'type': 'QuorumOpType', '*error': 'str', 'node-name': 'str',
|
||||
'sector-num': 'int', 'sectors-count': 'int' } }
|
||||
|
||||
##
|
||||
# @BlockdevSnapshotInternal:
|
||||
#
|
||||
# @device: the device name or node-name of a root node to generate the snapshot
|
||||
# from
|
||||
#
|
||||
# @name: the name of the internal snapshot to be created
|
||||
#
|
||||
# Notes: In transaction, if @name is empty, or any snapshot matching @name
|
||||
# exists, the operation will fail. Only some image formats support it,
|
||||
# for example, qcow2, rbd, and sheepdog.
|
||||
#
|
||||
# Since: 1.7
|
||||
##
|
||||
{ 'struct': 'BlockdevSnapshotInternal',
|
||||
'data': { 'device': 'str', 'name': 'str' } }
|
||||
|
||||
##
|
||||
# @blockdev-snapshot-internal-sync:
|
||||
#
|
||||
# Synchronously take an internal snapshot of a block device, when the
|
||||
# format of the image used supports it. If the name is an empty
|
||||
# string, or a snapshot with name already exists, the operation will
|
||||
# fail.
|
||||
#
|
||||
# For the arguments, see the documentation of BlockdevSnapshotInternal.
|
||||
#
|
||||
# Returns: - nothing on success
|
||||
# - If @device is not a valid block device, GenericError
|
||||
# - If any snapshot matching @name exists, or @name is empty,
|
||||
# GenericError
|
||||
# - If the format of the image used does not support it,
|
||||
# BlockFormatFeatureNotSupported
|
||||
#
|
||||
# Since: 1.7
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# -> { "execute": "blockdev-snapshot-internal-sync",
|
||||
# "arguments": { "device": "ide-hd0",
|
||||
# "name": "snapshot0" }
|
||||
# }
|
||||
# <- { "return": {} }
|
||||
#
|
||||
##
|
||||
{ 'command': 'blockdev-snapshot-internal-sync',
|
||||
'data': 'BlockdevSnapshotInternal' }
|
||||
|
||||
##
|
||||
# @blockdev-snapshot-delete-internal-sync:
|
||||
#
|
||||
# Synchronously delete an internal snapshot of a block device, when the format
|
||||
# of the image used support it. The snapshot is identified by name or id or
|
||||
# both. One of the name or id is required. Return SnapshotInfo for the
|
||||
# successfully deleted snapshot.
|
||||
#
|
||||
# @device: the device name or node-name of a root node to delete the snapshot
|
||||
# from
|
||||
#
|
||||
# @id: optional the snapshot's ID to be deleted
|
||||
#
|
||||
# @name: optional the snapshot's name to be deleted
|
||||
#
|
||||
# Returns: - SnapshotInfo on success
|
||||
# - If @device is not a valid block device, GenericError
|
||||
# - If snapshot not found, GenericError
|
||||
# - If the format of the image used does not support it,
|
||||
# BlockFormatFeatureNotSupported
|
||||
# - If @id and @name are both not specified, GenericError
|
||||
#
|
||||
# Since: 1.7
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# -> { "execute": "blockdev-snapshot-delete-internal-sync",
|
||||
# "arguments": { "device": "ide-hd0",
|
||||
# "name": "snapshot0" }
|
||||
# }
|
||||
# <- { "return": {
|
||||
# "id": "1",
|
||||
# "name": "snapshot0",
|
||||
# "vm-state-size": 0,
|
||||
# "date-sec": 1000012,
|
||||
# "date-nsec": 10,
|
||||
# "vm-clock-sec": 100,
|
||||
# "vm-clock-nsec": 20
|
||||
# }
|
||||
# }
|
||||
#
|
||||
##
|
||||
{ 'command': 'blockdev-snapshot-delete-internal-sync',
|
||||
'data': { 'device': 'str', '*id': 'str', '*name': 'str'},
|
||||
'returns': 'SnapshotInfo' }
|
||||
|
284
qapi/block.json
284
qapi/block.json
@ -60,23 +60,6 @@
|
||||
{ 'enum': 'FloppyDriveType',
|
||||
'data': ['144', '288', '120', 'none', 'auto']}
|
||||
|
||||
##
|
||||
# @BlockdevSnapshotInternal:
|
||||
#
|
||||
# @device: the device name or node-name of a root node to generate the snapshot
|
||||
# from
|
||||
#
|
||||
# @name: the name of the internal snapshot to be created
|
||||
#
|
||||
# Notes: In transaction, if @name is empty, or any snapshot matching @name
|
||||
# exists, the operation will fail. Only some image formats support it,
|
||||
# for example, qcow2, rbd, and sheepdog.
|
||||
#
|
||||
# Since: 1.7
|
||||
##
|
||||
{ 'struct': 'BlockdevSnapshotInternal',
|
||||
'data': { 'device': 'str', 'name': 'str' } }
|
||||
|
||||
##
|
||||
# @PRManagerInfo:
|
||||
#
|
||||
@ -104,84 +87,6 @@
|
||||
{ 'command': 'query-pr-managers', 'returns': ['PRManagerInfo'],
|
||||
'allow-preconfig': true }
|
||||
|
||||
|
||||
##
|
||||
# @blockdev-snapshot-internal-sync:
|
||||
#
|
||||
# Synchronously take an internal snapshot of a block device, when the
|
||||
# format of the image used supports it. If the name is an empty
|
||||
# string, or a snapshot with name already exists, the operation will
|
||||
# fail.
|
||||
#
|
||||
# For the arguments, see the documentation of BlockdevSnapshotInternal.
|
||||
#
|
||||
# Returns: - nothing on success
|
||||
# - If @device is not a valid block device, GenericError
|
||||
# - If any snapshot matching @name exists, or @name is empty,
|
||||
# GenericError
|
||||
# - If the format of the image used does not support it,
|
||||
# BlockFormatFeatureNotSupported
|
||||
#
|
||||
# Since: 1.7
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# -> { "execute": "blockdev-snapshot-internal-sync",
|
||||
# "arguments": { "device": "ide-hd0",
|
||||
# "name": "snapshot0" }
|
||||
# }
|
||||
# <- { "return": {} }
|
||||
#
|
||||
##
|
||||
{ 'command': 'blockdev-snapshot-internal-sync',
|
||||
'data': 'BlockdevSnapshotInternal' }
|
||||
|
||||
##
|
||||
# @blockdev-snapshot-delete-internal-sync:
|
||||
#
|
||||
# Synchronously delete an internal snapshot of a block device, when the format
|
||||
# of the image used support it. The snapshot is identified by name or id or
|
||||
# both. One of the name or id is required. Return SnapshotInfo for the
|
||||
# successfully deleted snapshot.
|
||||
#
|
||||
# @device: the device name or node-name of a root node to delete the snapshot
|
||||
# from
|
||||
#
|
||||
# @id: optional the snapshot's ID to be deleted
|
||||
#
|
||||
# @name: optional the snapshot's name to be deleted
|
||||
#
|
||||
# Returns: - SnapshotInfo on success
|
||||
# - If @device is not a valid block device, GenericError
|
||||
# - If snapshot not found, GenericError
|
||||
# - If the format of the image used does not support it,
|
||||
# BlockFormatFeatureNotSupported
|
||||
# - If @id and @name are both not specified, GenericError
|
||||
#
|
||||
# Since: 1.7
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# -> { "execute": "blockdev-snapshot-delete-internal-sync",
|
||||
# "arguments": { "device": "ide-hd0",
|
||||
# "name": "snapshot0" }
|
||||
# }
|
||||
# <- { "return": {
|
||||
# "id": "1",
|
||||
# "name": "snapshot0",
|
||||
# "vm-state-size": 0,
|
||||
# "date-sec": 1000012,
|
||||
# "date-nsec": 10,
|
||||
# "vm-clock-sec": 100,
|
||||
# "vm-clock-nsec": 20
|
||||
# }
|
||||
# }
|
||||
#
|
||||
##
|
||||
{ 'command': 'blockdev-snapshot-delete-internal-sync',
|
||||
'data': { 'device': 'str', '*id': 'str', '*name': 'str'},
|
||||
'returns': 'SnapshotInfo' }
|
||||
|
||||
##
|
||||
# @eject:
|
||||
#
|
||||
@ -210,111 +115,6 @@
|
||||
'*id': 'str',
|
||||
'*force': 'bool' } }
|
||||
|
||||
##
|
||||
# @nbd-server-start:
|
||||
#
|
||||
# Start an NBD server listening on the given host and port. Block
|
||||
# devices can then be exported using @nbd-server-add. The NBD
|
||||
# server will present them as named exports; for example, another
|
||||
# QEMU instance could refer to them as "nbd:HOST:PORT:exportname=NAME".
|
||||
#
|
||||
# @addr: Address on which to listen.
|
||||
# @tls-creds: ID of the TLS credentials object (since 2.6).
|
||||
# @tls-authz: ID of the QAuthZ authorization object used to validate
|
||||
# the client's x509 distinguished name. This object is
|
||||
# is only resolved at time of use, so can be deleted and
|
||||
# recreated on the fly while the NBD server is active.
|
||||
# If missing, it will default to denying access (since 4.0).
|
||||
#
|
||||
# Returns: error if the server is already running.
|
||||
#
|
||||
# Since: 1.3.0
|
||||
##
|
||||
{ 'command': 'nbd-server-start',
|
||||
'data': { 'addr': 'SocketAddressLegacy',
|
||||
'*tls-creds': 'str',
|
||||
'*tls-authz': 'str'} }
|
||||
|
||||
##
|
||||
# @nbd-server-add:
|
||||
#
|
||||
# Export a block node to QEMU's embedded NBD server.
|
||||
#
|
||||
# @device: The device name or node name of the node to be exported
|
||||
#
|
||||
# @name: Export name. If unspecified, the @device parameter is used as the
|
||||
# export name. (Since 2.12)
|
||||
#
|
||||
# @description: Free-form description of the export, up to 4096 bytes.
|
||||
# (Since 5.0)
|
||||
#
|
||||
# @writable: Whether clients should be able to write to the device via the
|
||||
# NBD connection (default false).
|
||||
#
|
||||
# @bitmap: Also export the dirty bitmap reachable from @device, so the
|
||||
# NBD client can use NBD_OPT_SET_META_CONTEXT with
|
||||
# "qemu:dirty-bitmap:NAME" to inspect the bitmap. (since 4.0)
|
||||
#
|
||||
# Returns: error if the server is not running, or export with the same name
|
||||
# already exists.
|
||||
#
|
||||
# Since: 1.3.0
|
||||
##
|
||||
{ 'command': 'nbd-server-add',
|
||||
'data': {'device': 'str', '*name': 'str', '*description': 'str',
|
||||
'*writable': 'bool', '*bitmap': 'str' } }
|
||||
|
||||
##
|
||||
# @NbdServerRemoveMode:
|
||||
#
|
||||
# Mode for removing an NBD export.
|
||||
#
|
||||
# @safe: Remove export if there are no existing connections, fail otherwise.
|
||||
#
|
||||
# @hard: Drop all connections immediately and remove export.
|
||||
#
|
||||
# Potential additional modes to be added in the future:
|
||||
#
|
||||
# hide: Just hide export from new clients, leave existing connections as is.
|
||||
# Remove export after all clients are disconnected.
|
||||
#
|
||||
# soft: Hide export from new clients, answer with ESHUTDOWN for all further
|
||||
# requests from existing clients.
|
||||
#
|
||||
# Since: 2.12
|
||||
##
|
||||
{'enum': 'NbdServerRemoveMode', 'data': ['safe', 'hard']}
|
||||
|
||||
##
|
||||
# @nbd-server-remove:
|
||||
#
|
||||
# Remove NBD export by name.
|
||||
#
|
||||
# @name: Export name.
|
||||
#
|
||||
# @mode: Mode of command operation. See @NbdServerRemoveMode description.
|
||||
# Default is 'safe'.
|
||||
#
|
||||
# Returns: error if
|
||||
# - the server is not running
|
||||
# - export is not found
|
||||
# - mode is 'safe' and there are existing connections
|
||||
#
|
||||
# Since: 2.12
|
||||
##
|
||||
{ 'command': 'nbd-server-remove',
|
||||
'data': {'name': 'str', '*mode': 'NbdServerRemoveMode'} }
|
||||
|
||||
##
|
||||
# @nbd-server-stop:
|
||||
#
|
||||
# Stop QEMU's embedded NBD server, and unregister all devices previously
|
||||
# added via @nbd-server-add.
|
||||
#
|
||||
# Since: 1.3.0
|
||||
##
|
||||
{ 'command': 'nbd-server-stop' }
|
||||
|
||||
##
|
||||
# @DEVICE_TRAY_MOVED:
|
||||
#
|
||||
@ -367,87 +167,3 @@
|
||||
##
|
||||
{ 'event': 'PR_MANAGER_STATUS_CHANGED',
|
||||
'data': { 'id': 'str', 'connected': 'bool' } }
|
||||
|
||||
##
|
||||
# @QuorumOpType:
|
||||
#
|
||||
# An enumeration of the quorum operation types
|
||||
#
|
||||
# @read: read operation
|
||||
#
|
||||
# @write: write operation
|
||||
#
|
||||
# @flush: flush operation
|
||||
#
|
||||
# Since: 2.6
|
||||
##
|
||||
{ 'enum': 'QuorumOpType',
|
||||
'data': [ 'read', 'write', 'flush' ] }
|
||||
|
||||
##
|
||||
# @QUORUM_FAILURE:
|
||||
#
|
||||
# Emitted by the Quorum block driver if it fails to establish a quorum
|
||||
#
|
||||
# @reference: device name if defined else node name
|
||||
#
|
||||
# @sector-num: number of the first sector of the failed read operation
|
||||
#
|
||||
# @sectors-count: failed read operation sector count
|
||||
#
|
||||
# Note: This event is rate-limited.
|
||||
#
|
||||
# Since: 2.0
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# <- { "event": "QUORUM_FAILURE",
|
||||
# "data": { "reference": "usr1", "sector-num": 345435, "sectors-count": 5 },
|
||||
# "timestamp": { "seconds": 1344522075, "microseconds": 745528 } }
|
||||
#
|
||||
##
|
||||
{ 'event': 'QUORUM_FAILURE',
|
||||
'data': { 'reference': 'str', 'sector-num': 'int', 'sectors-count': 'int' } }
|
||||
|
||||
##
|
||||
# @QUORUM_REPORT_BAD:
|
||||
#
|
||||
# Emitted to report a corruption of a Quorum file
|
||||
#
|
||||
# @type: quorum operation type (Since 2.6)
|
||||
#
|
||||
# @error: error message. Only present on failure. This field
|
||||
# contains a human-readable error message. There are no semantics other
|
||||
# than that the block layer reported an error and clients should not
|
||||
# try to interpret the error string.
|
||||
#
|
||||
# @node-name: the graph node name of the block driver state
|
||||
#
|
||||
# @sector-num: number of the first sector of the failed read operation
|
||||
#
|
||||
# @sectors-count: failed read operation sector count
|
||||
#
|
||||
# Note: This event is rate-limited.
|
||||
#
|
||||
# Since: 2.0
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# 1. Read operation
|
||||
#
|
||||
# { "event": "QUORUM_REPORT_BAD",
|
||||
# "data": { "node-name": "node0", "sector-num": 345435, "sectors-count": 5,
|
||||
# "type": "read" },
|
||||
# "timestamp": { "seconds": 1344522075, "microseconds": 745528 } }
|
||||
#
|
||||
# 2. Flush operation
|
||||
#
|
||||
# { "event": "QUORUM_REPORT_BAD",
|
||||
# "data": { "node-name": "node0", "sector-num": 0, "sectors-count": 2097120,
|
||||
# "type": "flush", "error": "Broken pipe" },
|
||||
# "timestamp": { "seconds": 1456406829, "microseconds": 291763 } }
|
||||
#
|
||||
##
|
||||
{ 'event': 'QUORUM_REPORT_BAD',
|
||||
'data': { 'type': 'QuorumOpType', '*error': 'str', 'node-name': 'str',
|
||||
'sector-num': 'int', 'sectors-count': 'int' } }
|
||||
|
Loading…
Reference in New Issue
Block a user