[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 8/8] qed: Add -o stream=on image creation option
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PATCH 8/8] qed: Add -o stream=on image creation option |
Date: |
Wed, 27 Apr 2011 14:27:35 +0100 |
Create an image that automatically streams its backing file like this:
qemu-img create -f qed -o
backing_file=master.raw,backing_fmt=raw,copy_on_read=on,stream=on stream.qed 60G
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block/qed.c | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/block/qed.c b/block/qed.c
index a61cee9..d65abe7 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -461,7 +461,7 @@ static int bdrv_qed_flush(BlockDriverState *bs)
static int qed_create(const char *filename, uint32_t cluster_size,
uint64_t image_size, uint32_t table_size,
const char *backing_file, const char *backing_fmt,
- bool copy_on_read)
+ bool copy_on_read, bool stream)
{
QEDHeader header = {
.magic = QED_MAGIC,
@@ -506,6 +506,9 @@ static int qed_create(const char *filename, uint32_t
cluster_size,
if (copy_on_read) {
header.compat_features |= QED_CF_COPY_ON_READ;
}
+ if (stream) {
+ header.compat_features |= QED_CF_STREAM;
+ }
}
qed_header_cpu_to_le(&header, &le_header);
@@ -540,6 +543,7 @@ static int bdrv_qed_create(const char *filename,
QEMUOptionParameter *options)
const char *backing_file = NULL;
const char *backing_fmt = NULL;
bool copy_on_read = false;
+ bool stream = false;
while (options && options->name) {
if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
@@ -560,6 +564,10 @@ static int bdrv_qed_create(const char *filename,
QEMUOptionParameter *options)
if (options->value.n) {
copy_on_read = true;
}
+ } else if (!strcmp(options->name, "stream")) {
+ if (options->value.n) {
+ stream = true;
+ }
}
options++;
}
@@ -585,9 +593,14 @@ static int bdrv_qed_create(const char *filename,
QEMUOptionParameter *options)
"QED only supports Copy-on-Read with a backing file\n");
return -EINVAL;
}
+ if (stream && !copy_on_read) {
+ fprintf(stderr,
+ "QED requires Copy-on-Read to be enabled for streaming\n");
+ return -EINVAL;
+ }
return qed_create(filename, cluster_size, image_size, table_size,
- backing_file, backing_fmt, copy_on_read);
+ backing_file, backing_fmt, copy_on_read, stream);
}
typedef struct {
@@ -1637,6 +1650,10 @@ static QEMUOptionParameter qed_create_options[] = {
.name = "copy_on_read",
.type = OPT_FLAG,
.help = "Copy blocks from base image on read"
+ }, {
+ .name = "stream",
+ .type = OPT_FLAG,
+ .help = "Start copying blocks from base image once opened"
},
{ /* end of list */ }
};
--
1.7.4.4
- [Qemu-devel] [PATCH 3/8] qed: add support for Copy-on-Read, (continued)
- [Qemu-devel] [PATCH 3/8] qed: add support for Copy-on-Read, Stefan Hajnoczi, 2011/04/27
- [Qemu-devel] [PATCH 7/8] qed: Add QED_CF_STREAM flag to auto-enable streaming, Stefan Hajnoczi, 2011/04/27
- [Qemu-devel] [PATCH 4/8] qed: intelligent streaming implementation, Stefan Hajnoczi, 2011/04/27
- [Qemu-devel] [PATCH 6/8] blockdev: Allow image files to auto-enable streaming, Stefan Hajnoczi, 2011/04/27
- [Qemu-devel] [PATCH 5/8] qed: detect zero writes and skip them when to an unalloc cluster, Stefan Hajnoczi, 2011/04/27
- [Qemu-devel] [PATCH 2/8] qmp: Add QMP support for stream commands, Stefan Hajnoczi, 2011/04/27
- [Qemu-devel] [PATCH 8/8] qed: Add -o stream=on image creation option,
Stefan Hajnoczi <=
- Re: [Qemu-devel] [RFC PATCH 0/8] QED image streaming, Stefan Hajnoczi, 2011/04/27