block: add support for partial streaming

Add support for streaming data from an intermediate section of the
image chain (see patch and documentation for details).

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Marcelo Tosatti 2012-01-18 14:40:53 +00:00 committed by Kevin Wolf
parent 019b8cbf76
commit c8c3080f4a
3 changed files with 96 additions and 9 deletions

View file

@ -973,6 +973,7 @@ void qmp_block_stream(const char *device, bool has_base,
const char *base, Error **errp)
{
BlockDriverState *bs;
BlockDriverState *base_bs = NULL;
int ret;
bs = bdrv_find(device);
@ -981,13 +982,15 @@ void qmp_block_stream(const char *device, bool has_base,
return;
}
/* Base device not supported */
if (base) {
error_set(errp, QERR_NOT_SUPPORTED);
return;
base_bs = bdrv_find_backing_image(bs, base);
if (base_bs == NULL) {
error_set(errp, QERR_BASE_NOT_FOUND, base);
return;
}
}
ret = stream_start(bs, NULL, block_stream_cb, bs);
ret = stream_start(bs, base_bs, base, block_stream_cb, bs);
if (ret < 0) {
switch (ret) {
case -EBUSY: