On 11/27/2015 07:59 AM, Hannes Reinecke wrote: > Implement a 'block_disconnect' HMP command to simulate a device > communication / link failure. > > Signed-off-by: Hannes Reinecke <[email protected]> > ---
> +++ b/qapi/block-core.json
> @@ -754,6 +754,27 @@
> 'size': 'int' }}
>
> ##
> +# @block_disconnect
New QMP commands should favor '-' rather than '_'; this should be
'block-disconnect'.
> +#
> +# Simulate block device disconnect while a guest is running.
> +#
> +# Either @device or @node-name must be set but not both.
> +#
> +# @device: #optional the name of the device to get the image resized
Bad copy-and-paste? We aren't resizing anything here.
> +#
> +# @node-name: #optional graph node name to get the image resized (Since 2.0)
And again. And since the command is new, you don't need a '(Since 2.0)'.
> +#
> +# @disconnect: true for disconnecting the device
> +#
> +# Returns: nothing on success
> +# If @device is not a valid block device, DeviceNotFound
> +#
> +##
Missing a '# Since 2.6' line.
> +{ 'command': 'block_disconnect', 'data': { '*device': 'str',
> + '*node-name': 'str',
> + 'disconnect': 'bool' }}
Mutually-exclusive 'device' vs. 'node-name' is awkward. For new
commands, it is sufficient to just use 'node' (and accept both node
names for the direct node to disconnect, or a device name to detach the
BDS node plugged in to that device).
> +block_disconnect
> +----------------
> +
> +Simulate a block device disconnect while a guest is running.
> +
> +Arguments:
> +
> +- "device": the device's ID, must be unique (json-string)
> +- "node-name": the node name in the block driver state graph (json-string)
Awkward that you aren't mentioning the mutual exclusion above; and again
I think that a single parameter is better than two mutually exclusive ones.
> +- "disconnect": whether to simulate a device disconnect (json-bool)
Do I again call the command with 'disconnect':false to undo the
disconnect? That sounds like a double-negative. It might make more
sense to have:
{ 'command':'block-set-connection', 'data': { 'node':'str',
'connected':'bool' } }
where I pass 'connected':false to disconnect, and 'connected':true to
reconnect.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
