From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50166) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fDsL8-0006gr-3l for qemu-devel@nongnu.org; Wed, 02 May 2018 10:02:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fDsL4-0006GP-Dg for qemu-devel@nongnu.org; Wed, 02 May 2018 10:02:38 -0400 References: <1525268093-531-1-git-send-email-ivanren@tencent.com> From: Eric Blake Message-ID: Date: Wed, 2 May 2018 09:02:14 -0500 MIME-Version: 1.0 In-Reply-To: <1525268093-531-1-git-send-email-ivanren@tencent.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] qemu-img: return allocated size for block device with qcow2 format List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ivan Ren , qemu-devel@nongnu.org Cc: kwolf@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com On 05/02/2018 08:34 AM, Ivan Ren wrote: > qemu-img info with a block device which has a qcow2 format always > return 0 for disk size, and this can not reflect the qcow2 size > and the used space of the block device. This patch return the > allocated size of qcow2 as the disk size. How does this differ from what qemu can already give you at runtime via the wr_highest_offset property in BlockDeviceStats, and related to the write_threshold ('block-set-write-threshold command, BLOCK_WRITE_THRESHOLD event)? Is there any code we can reuse, rather than writing something from scratch? > > Signed-off-by: Ivan Ren > --- > block/qcow2-bitmap.c | 69 +++++++++++++++++ > block/qcow2.c | 212 +++++++++++++++++++++++++++++++++++++++++++++++++++ > block/qcow2.h | 42 ++++++++++ > 3 files changed, 323 insertions(+) > -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org