From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:58704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QF4md-0006Qw-NI for qemu-devel@nongnu.org; Wed, 27 Apr 2011 09:28:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QF4mR-0005cB-AG for qemu-devel@nongnu.org; Wed, 27 Apr 2011 09:27:59 -0400 Received: from mtagate3.uk.ibm.com ([194.196.100.163]:60158) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QF4mQ-0005bw-UK for qemu-devel@nongnu.org; Wed, 27 Apr 2011 09:27:47 -0400 Received: from d06nrmr1307.portsmouth.uk.ibm.com (d06nrmr1307.portsmouth.uk.ibm.com [9.149.38.129]) by mtagate3.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p3RDRk8v024349 for ; Wed, 27 Apr 2011 13:27:46 GMT Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by d06nrmr1307.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p3RDSnD61605874 for ; Wed, 27 Apr 2011 14:28:49 +0100 Received: from d06av04.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p3RDRj1d031835 for ; Wed, 27 Apr 2011 07:27:45 -0600 From: Stefan Hajnoczi Date: Wed, 27 Apr 2011 14:27:35 +0100 Message-Id: <1303910855-28999-9-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1303910855-28999-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1303910855-28999-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 8/8] qed: Add -o stream=on image creation option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Anthony Liguori , Stefan Hajnoczi 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 --- 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