[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH][RFC] Add compare subcommand for qemu-img
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH][RFC] Add compare subcommand for qemu-img |
Date: |
Wed, 1 Aug 2012 13:22:37 +0100 |
On Wed, Aug 1, 2012 at 11:03 AM, Miroslav Rezanina <address@hidden> wrote:
> This patch adds compare subcommand that compares two images. Compare has
> following criteria:
> - only data part is compared
> - unallocated sectors are not read
> - in case of different image size, exceeding part of bigger disk has to be
> zeroed/unallocated to compare rest
> - qemu-img returns:
> - 0 if images are identical
> - 1 if images differ
> - 2 on error
Please add qemu-img compare documentation to qemu-img.texi.
> @@ -652,6 +654,223 @@ static int compare_sectors(const uint8_t *buf1, const
> uint8_t *buf2, int n,
>
> #define IO_BUF_SIZE (2 * 1024 * 1024)
>
> +/*
> + * Get number of sectors that can be stored in IO buffer.
> + */
> +
> +static int64_t sectors_to_process(int64_t total, int64_t from)
> +{
> + int64_t rv = total - from;
> +
> + if (rv > (IO_BUF_SIZE >> BDRV_SECTOR_BITS))
> + return IO_BUF_SIZE >> BDRV_SECTOR_BITS;
Please use git show | scripts/checkpatch.pl - to check coding style.
Stefan