[4672] New qemu-img convert -B option, by Marc Bevand.
Revision: 4672
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4672 Author: ths Date: 2008-06-05 21:53:49 +0000 (Thu, 05 Jun 2008)
Log Message:
-----------
New qemu-img convert -B option, by Marc Bevand.
Modified Paths:
--------------
trunk/block.c
trunk/block.h
trunk/qemu-img.c
trunk/qemu-img.texi
Modified: trunk/block.c
===================================================================
block.c +27 -0
@@ -884,6 +884,33 @@bdrv_flush (bs->backing_hd); } +/* +* Returns true iff the specified sector is present in the disk image. Drivers +* not implementing the functionality are assumed to not support backing files, +* hence all their sectors are reported as allocated. +* +* 'pnum' is set to the number of sectors (including and immediately following +* the specified sector) that are known to be in the same +* allocated/unallocated state. +* +* 'nb_sectors' is the max value 'pnum' should be set to. +*/ +int bdrv_is_allocated (BlockDriverState *bs,int64_t sector_num,int nb_sectors, +int *pnum) +{ +int64_t n; +if (!bs->drv->bdrv_is_allocated) { +if (sector_num >= bs->total_sectors) { + *pnum =0 ; +return 0 ; + } + n = bs->total_sectors - sector_num; + *pnum = (n < nb_sectors) ? (n) : (nb_sectors); +return 1 ; + } +return bs->drv->bdrv_is_allocated (bs, sector_num, nb_sectors, pnum); +} +#ifndef QEMU_IMG void bdrv_info (void ) {
Modified: trunk/block.h
===================================================================
block.h +2 -0
@@ -99,6 +99,8 @@/* Ensure contents are flushed to disk. */ void bdrv_flush (BlockDriverState *bs); +int bdrv_is_allocated (BlockDriverState *bs,int64_t sector_num,int nb_sectors, +int *pnum);#define BDRV_TYPE_HD 0#define BDRV_TYPE_CDROM 1
Modified: trunk/qemu-img.c
===================================================================
qemu-img.c +41 -6
115 lines not on this page · raw message
Modified: trunk/qemu-img.texi
===================================================================
qemu-img.texi +6 -2
@@ -10,7 +10,7 @@ @table @option @item create [-e] [-6] [-b @var{base_image}] [-f @var{fmt}] @var{filename} [@var{size}] @item commit [-f @var{fmt}] @var{filename} -@item convert [-c] [-e] [-6] [-f @var{fmt}] [-O @var{output_fmt}] @var{filename} [@var{filename2} [...]] @var{output_filename} +@item convert [-c] [-e] [-6] [-f @var{fmt}] [-O @var{output_fmt}] [-B @var{output_base_image}] @var{filename} [@var{filename2} [...]] @var{output_filename} @item info [-f @var{fmt}] @var{filename} @end table
@@ -21,7 +21,11 @@ @item base_image is the read-only disk image which is used as base for a copy on write image; the copy on write image only stores the modified data - +@item output_base_image +forces the output image to be created as a copy on write +image of the specified base image; @code{output_base_image} should have the same +content as the input's base image, however the path, image format, etc may +differ @item fmt is the disk image format. It is guessed automatically in most cases. The following formats are supported: