[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 20/43] qemu-io: Implement write -c for compressed cl
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 20/43] qemu-io: Implement write -c for compressed clusters |
Date: |
Thu, 13 Dec 2012 16:10:27 +0100 |
This makes it easier to create images with both compressed and
uncompressed clusters for testing.
Signed-off-by: Kevin Wolf <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
qemu-io.c | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/qemu-io.c b/qemu-io.c
index 92cdb2a..b4b0898 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -265,6 +265,18 @@ static int do_co_write_zeroes(int64_t offset, int count,
int *total)
}
}
+static int do_write_compressed(char *buf, int64_t offset, int count, int
*total)
+{
+ int ret;
+
+ ret = bdrv_write_compressed(bs, offset >> 9, (uint8_t *)buf, count >> 9);
+ if (ret < 0) {
+ return ret;
+ }
+ *total = count;
+ return 1;
+}
+
static int do_load_vmstate(char *buf, int64_t offset, int count, int *total)
{
*total = bdrv_load_vmstate(bs, (uint8_t *)buf, offset, count);
@@ -687,6 +699,7 @@ static void write_help(void)
" Writes into a segment of the currently open file, using a buffer\n"
" filled with a set pattern (0xcdcdcdcd).\n"
" -b, -- write to the VM state rather than the virtual disk\n"
+" -c, -- write compressed data with bdrv_write_compressed\n"
" -p, -- use bdrv_pwrite to write the file\n"
" -P, -- use different pattern to fill file\n"
" -C, -- report statistics in a machine parsable format\n"
@@ -703,7 +716,7 @@ static const cmdinfo_t write_cmd = {
.cfunc = write_f,
.argmin = 2,
.argmax = -1,
- .args = "[-bCpqz] [-P pattern ] off len",
+ .args = "[-bcCpqz] [-P pattern ] off len",
.oneline = "writes a number of bytes at a specified offset",
.help = write_help,
};
@@ -712,6 +725,7 @@ static int write_f(int argc, char **argv)
{
struct timeval t1, t2;
int Cflag = 0, pflag = 0, qflag = 0, bflag = 0, Pflag = 0, zflag = 0;
+ int cflag = 0;
int c, cnt;
char *buf = NULL;
int64_t offset;
@@ -720,11 +734,14 @@ static int write_f(int argc, char **argv)
int total = 0;
int pattern = 0xcd;
- while ((c = getopt(argc, argv, "bCpP:qz")) != EOF) {
+ while ((c = getopt(argc, argv, "bcCpP:qz")) != EOF) {
switch (c) {
case 'b':
bflag = 1;
break;
+ case 'c':
+ cflag = 1;
+ break;
case 'C':
Cflag = 1;
break;
@@ -801,6 +818,8 @@ static int write_f(int argc, char **argv)
cnt = do_save_vmstate(buf, offset, count, &total);
} else if (zflag) {
cnt = do_co_write_zeroes(offset, count, &total);
+ } else if (cflag) {
+ cnt = do_write_compressed(buf, offset, count, &total);
} else {
cnt = do_write(buf, offset, count, &total);
}
--
1.7.6.5
- [Qemu-devel] [PATCH 17/43] qmp: qmp_drive_mirror(): pass Error object to bdrv_img_create(), (continued)
- [Qemu-devel] [PATCH 17/43] qmp: qmp_drive_mirror(): pass Error object to bdrv_img_create(), Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 11/43] Support default block interfaces per QEMUMachine, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 22/43] Fix error code checking for SetFilePointer() call, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 35/43] atapi: reset cdrom tray statuses on ide_reset, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 27/43] use qemu_opts_create_nofail, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 43/43] qcow2: Factor out handle_dependencies(), Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 30/43] blkdebug: Factor out remove_rule(), Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 41/43] qcow2: Enable dirty flag in qcow2_alloc_cluster_link_l2, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 39/43] qcow2: Drop l2meta.cluster_offset, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 31/43] blkdebug: Implement suspend/resume of AIO requests, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 20/43] qemu-io: Implement write -c for compressed clusters,
Kevin Wolf <=
- [Qemu-devel] [PATCH 26/43] introduce qemu_opts_create_nofail function, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 29/43] blkdebug: Allow usage without config file, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 15/43] qemu-img: img_create(): drop unneeded goto and ret variable, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 21/43] rbd: Fix race between aio completition and aio cancel, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 19/43] tests: Add tests for fdsets, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 24/43] qemu-option: qemu_opts_validate(): fix duplicated code, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 42/43] qcow2: Execute run_dependent_requests() without lock, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 38/43] qcow2: Allocate l2meta dynamically, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 40/43] qcow2: Allocate l2meta only for cluster allocations, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 36/43] qcow2: Round QCowL2Meta.offset down to cluster boundary, Kevin Wolf, 2012/12/13