Skip to contentSkip to conversation

qemu-img: Require larger zero areas for sparse handling

PATCH New Kevin Wolf 1 participant 1 message Aug 29, 2011

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH v2 1/1 qemu-img: Require larger zero areas for sparse handling

By default, require 4k of consecutive zero bytes for qemu-img to make the output file sparse by not issuing a write request for the zeroed parts. Add an -S option to allow users to tune this setting.

This helps to avoid situations where a lot of zero sectors and data sectors are mixed and qemu-img tended to issue many tiny 512 byte writes.

---
 qemu-img-cmds.hx |    4 +-
 qemu-img.c       |   61 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 qemu-img.texi    |    7 +++++-
 3 files changed, 67 insertions(+), 5 deletions(-)
qemu-img-cmds.hx +2 -2
index 1299e83..4be00a5 100644
@@ -28,9 +28,9 @@ STEXI
 ETEXI
 
 DEF("convert", img_convert,
-    "convert [-c] [-p] [-f fmt] [-t cache] [-O output_fmt] [-o options] [-s snapshot_name] filename [filename2 [...]] output_filename")
+    "convert [-c] [-p] [-f fmt] [-t cache] [-O output_fmt] [-o options] [-s snapshot_name] [-S sparse_size] filename [filename2 [...]] output_filename")
 STEXI
-@item convert [-c] [-p] [-f @var{fmt}] [-O @var{output_fmt}] [-o @var{options}] [-s @var{snapshot_name}] @var{filename} [@var{filename2} [...]] @var{output_filename}
+@item convert [-c] [-p] [-f @var{fmt}] [-O @var{output_fmt}] [-o @var{options}] [-s @var{snapshot_name}] [-S @var{sparse_size}] @var{filename} [@var{filename2} [...]] @var{output_filename}
 ETEXI
 
 DEF("info", img_info,
qemu-img.c +59 -2

97 lines not on this page · raw message

qemu-img.texi +6 -1
index 495a1b6..70fa321 100644
@@ -40,6 +40,11 @@ indicates that target image must be compressed (qcow format only)
 with or without a command shows help and lists the supported formats
 @item -p
 display progress bar (convert and rebase commands only)
+@item -S @var{size}
+indicates the consecutive number of bytes that must contain only zeros
+for qemu-img to create a sparse image during conversion. This value is rounded
+down to the nearest 512 bytes. You may use the common size suffixes like
+@code{k} for kilobytes.
 @end table
 
 Parameters to snapshot subcommand:
@@ -86,7 +91,7 @@ it doesn't need to be specified separately in this case.
 
 Commit the changes recorded in @var{filename} in its base image.
 
-@item convert [-c] [-p] [-f @var{fmt}] [-O @var{output_fmt}] [-o @var{options}] [-s @var{snapshot_name}] @var{filename} [@var{filename2} [...]] @var{output_filename}
+@item convert [-c] [-p] [-f @var{fmt}] [-O @var{output_fmt}] [-o @var{options}] [-s @var{snapshot_name}] [-S @var{sparse_size}] @var{filename} [@var{filename2} [...]] @var{output_filename}
 
 Convert the disk image @var{filename} or a snapshot @var{snapshot_name} to disk image @var{output_filename}
 using format @var{output_fmt}. It can be optionally compressed (@code{-c}
Signature · 1 line
1.7.6