Image files that having streaming enabled will automatically begin streaming when opened.
Signed-off-by: Stefan Hajnoczi <stefa...@linux.vnet.ibm.com> --- block.c | 5 +++++ block.h | 1 + block_int.h | 1 + blockdev.c | 9 +++++++++ 4 files changed, 16 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 5e3476c..68a97a3 100644 --- a/block.c +++ b/block.c @@ -1584,6 +1584,11 @@ const char *bdrv_get_device_name(BlockDriverState *bs) return bs->device_name; } +int bdrv_stream_enabled(BlockDriverState *bs) +{ + return bs->stream; +} + int bdrv_flush(BlockDriverState *bs) { if (bs->open_flags & BDRV_O_NO_FLUSH) { diff --git a/block.h b/block.h index fad828a..3357c50 100644 --- a/block.h +++ b/block.h @@ -189,6 +189,7 @@ int bdrv_is_removable(BlockDriverState *bs); int bdrv_is_read_only(BlockDriverState *bs); int bdrv_is_sg(BlockDriverState *bs); int bdrv_enable_write_cache(BlockDriverState *bs); +int bdrv_stream_enabled(BlockDriverState *bs); int bdrv_is_inserted(BlockDriverState *bs); int bdrv_media_changed(BlockDriverState *bs); int bdrv_is_locked(BlockDriverState *bs); diff --git a/block_int.h b/block_int.h index 0c125d0..d0fe96c 100644 --- a/block_int.h +++ b/block_int.h @@ -155,6 +155,7 @@ struct BlockDriverState { int encrypted; /* if true, the media is encrypted */ int valid_key; /* if true, a valid encryption key has been set */ int sg; /* if true, the device is a /dev/sg* */ + int stream; /* if true, stream from the backing file */ /* event callback when inserting/removing */ void (*change_cb)(void *opaque, int reason); void *change_opaque; diff --git a/blockdev.c b/blockdev.c index 99c0726..5d6cb2b 100644 --- a/blockdev.c +++ b/blockdev.c @@ -678,6 +678,15 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) goto err; } + if (bdrv_stream_enabled(dinfo->bdrv)) { + const char *device_name = bdrv_get_device_name(dinfo->bdrv); + + if (!stream_start(device_name, 0, false, NULL, NULL)) { + fprintf(stderr, "qemu: warning: stream_start failed for '%s'\n", + device_name); + } + } + if (bdrv_key_required(dinfo->bdrv)) autostart = 0; return dinfo; -- 1.7.4.4