qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: wang.guang55@zte.com.cn
Cc: mreitz@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org,
	wang.yong155@zte.com.cn
Subject: Re: [Qemu-devel] about qemu-img info on block dev
Date: Tue, 7 Nov 2017 10:15:06 +0100	[thread overview]
Message-ID: <20171107091506.GA4706@localhost.localdomain> (raw)
In-Reply-To: <201711071518033155528@zte.com.cn>

Am 07.11.2017 um 08:18 hat wang.guang55@zte.com.cn geschrieben:
> hello
> 
> 
> if we create a qcow2 file on a block dev.
> 
> 
> we can,t get the right disk size by qemu-img info。
> 
> 
> 
> 
> 
> 
> [root@host-120-79 qemu]# ./qemu-img create -f qcow2 /dev/zs/lvol0 1G
> 
> Formatting '/dev/zs/lvol0', fmt=qcow2 size=1073741824 cluster_size=65536 lazy_refcounts=off refcount_bits=16
> 
> [root@host-120-79 qemu]# ./qemu-img info /dev/zs/lvol0 
> 
> image: /dev/zs/lvol0
> 
> file format: qcow2
> 
> virtual size: 1.0G (1073741824 bytes)
> 
> disk size: 0
> 
> cluster_size: 65536
> 
> Format specific information:
> 
>     compat: 1.1
> 
>     lazy refcounts: false
> 
>     refcount bits: 16
> 
>     corrupt: false
> 
> 
> 
> 
> 
> 
> Then we get disk size from L1 table and L2 table in qcow2_get_allocated_file_size.
> 
> 
> May be we can submit the patch to qemu master??

No, qcow2 is the wrong layer to do this. If anything,
raw_get_allocated_file_size() could be changed to return the full file
size for block devices. However, even this is not necessarily the right
number, the block device could actually be thin provisioned and the
kernel doesn't tell us how many blocks are actually allocated. So I
think 0 for "we don't know" is in fact the right answer.

Kevin

      reply	other threads:[~2017-11-07  9:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-07  7:18 [Qemu-devel] about qemu-img info on block dev wang.guang55
2017-11-07  9:15 ` Kevin Wolf [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171107091506.GA4706@localhost.localdomain \
    --to=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=wang.guang55@zte.com.cn \
    --cc=wang.yong155@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).