[libvirt-users] how to get disk snapshot size

Kashyap Chamarthy kchamart at redhat.com
Mon Mar 16 09:51:21 UTC 2015


On Sun, Mar 15, 2015 at 10:28:30PM +0800, Yitao Jiang wrote:
> Hi,guys
> I wanna to get the disk snapshot size, but found nothing libvirt commands
> related,except qemu-img.
> I create two disk snapshots, but nothing return its' size

The below does not seem like snapshots. They're *internal* qcow2
snapshots (original and delta are on the same file).

A quick example of disk snapshots:

List the current active device:

  $ virsh domblklist cirrvm
  Target     Source
  ------------------------------------------------
  hda        /var/lib/libvirt/images/cirros-0.3.3-x86_64-disk.img

Create a 'disk-only' external snapshot:

  $ virsh snapshot-create-as --domain cirrvm snap1 \
        --diskspec vda,file=/export/vmimages/sn1.qcow2 \
        --disk-only --atomic 
  
List again the current active block device:

  $ virsh domblklist cirrvm
  Target     Source
  ------------------------------------------------
  hda        /export/vmimages/sn1.qcow2

Get info about the disks involved:

  $ qemu-img info --backing-chain /export/vmimages/sn1.qcow2
  image: /export/vmimages/sn1.qcow2
  file format: qcow2
  virtual size: 39M (41126400 bytes)
  disk size: 196K
  cluster_size: 65536
  backing file: /var/lib/libvirt/images/cirros-0.3.3-x86_64-disk.img
  backing file format: qcow2
  Format specific information:
      compat: 1.1
      lazy refcounts: false
  
  image: /var/lib/libvirt/images/cirros-0.3.3-x86_64-disk.img
  file format: qcow2
  virtual size: 39M (41126400 bytes)
  disk size: 14M
  cluster_size: 65536
  Format specific information:
      compat: 0.10

-- 
/kashyap

> [root at cskvm01 qcow2]# qemu-img info
>  /mnt/e6758700-af68-3c06-ade3-53f5f9b93507/e2cf6551-0d2c-4382-a86c-8ba633954ff2
> image:
> /mnt/e6758700-af68-3c06-ade3-53f5f9b93507/e2cf6551-0d2c-4382-a86c-8ba633954ff2
> file format: qcow2
> virtual size: 5.0G (5368709120 bytes)
> disk size: 1.0G
> cluster_size: 65536
> Snapshot list:
> ID        TAG                 VM SIZE                DATE       VM CLOCK
> 1         4fc42d73-8257-42bd-8807-81700fd3c689      0 2015-03-15 21:05:55
> 01:05:53.583
> 2         2fd6aeab-cb26-446d-b1c6-e8d70d33f651      0 2015-03-15 21:50:35
> 00:00:00.000
> 
> After wrote data to the disk, then create another snapshot
> [root at cskvm01 qcow2]# qemu-img info
>  /mnt/e6758700-af68-3c06-ade3-53f5f9b93507/e2cf6551-0d2c-4382-a86c-8ba633954ff2
> image:
> /mnt/e6758700-af68-3c06-ade3-53f5f9b93507/e2cf6551-0d2c-4382-a86c-8ba633954ff2
> file format: qcow2
> virtual size: 5.0G (5368709120 bytes)
> disk size: 3.9G
> cluster_size: 65536
> Snapshot list:
> ID        TAG                 VM SIZE                DATE       VM CLOCK
> 1         4fc42d73-8257-42bd-8807-81700fd3c689      0 2015-03-15 21:05:55
> 01:05:53.583
> 2         2fd6aeab-cb26-446d-b1c6-e8d70d33f651      0 2015-03-15 21:50:35
> 00:00:00.000
> 3         63815565-3a06-4366-a1b3-bfeb9c4a07b4      0 2015-03-15 22:22:43
> 00:00:00.000
> 
> VM SIZE column still show 0
> 
> Here is my environment
> qemu-img version 0.12.1, Copyright (c) 2004-2008 Fabrice Bellard
> libvirtd (libvirt) 0.10.2
> CentOS release 6.5 (Final) 2.6.32-431.el6.x86_64
> 




More information about the libvirt-users mailing list