Commit Message

For leaf images with copy-on-read semantics, the stream command allows
the user to populate the image file by copying data from the backing
file while the guest is running. Once all blocks have been streamed,
the dependency on the original backing file is removed. Therefore,
stream commands can be used to implement post-copy live block migration
and rapid deployment.
The command synopsis is:
block_stream
------------
Copy data from a backing file into a block device.
The block streaming operation is performed in the background until the
entire backing file has been copied. This command returns immediately
once streaming has started. The status of ongoing block streaming
operations can be checked with query-block-jobs. The operation can be
stopped before it has completed using the block_job_cancel command.
If a base file is specified then sectors are not copied from that base
file and its backing chain. When streaming completes the image file
will have the base file as its backing file. This can be used to stream
a subset of the backing file chain instead of flattening the entire
image.
On successful completion the image file is updated to drop the backing
file.
Arguments:
- device: device name (json-string)
- base: common backing file (json-string, optional)
Errors:
DeviceInUse: streaming is already active on this device
DeviceNotFound: device name is invalid
NotSupported: image streaming is not supported by this device
Events:
On completion the BLOCK_JOB_COMPLETED event is raised with the following
fields:
- type: job type ("stream" for image streaming, json-string)
- device: device name (json-string)
- end: maximum progress value (json-int)
- position: current progress value (json-int)
- speed: rate limit, bytes per second (json-int)
- error: error message (json-string, only on error)
The completion event is raised both on success and on failure. On
success position is equal to end. On failure position and end can be
used to indicate at which point the operation failed.
On failure the error field contains a human-readable error message.
There are no semantics other than that streaming has failed and clients
should not try to interpret the error string.
Examples:
-> { "execute": "block_stream", "arguments": { "device": "virtio0" } }
<- { "return": {} }
Signed-off-by: Adam Litke <agl@us.ibm.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
blockdev.c | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
blockdev.h | 1 +
hmp-commands.hx | 14 ++++++
monitor.c | 3 +
monitor.h | 1 +
qerror.c | 8 +++
qerror.h | 6 +++
qmp-commands.hx | 64 ++++++++++++++++++++++++++
8 files changed, 230 insertions(+), 0 deletions(-)