Bug 1017227

Summary: cannot compress snapshot's external memory state
Product: Red Hat Enterprise Linux 7 Reporter: Arik <ahadas>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: acathrow, berrange, bili, dyuan, michal.skrivanek, shyu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-1.1.1-10.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1017224 Environment:
Last Closed: 2014-06-13 09:38:55 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Arik 2013-10-09 13:10:21 UTC
+++ This bug was initially created as a clone of Bug #1017224 +++

Description of problem:
While taking snapshot with external memory state we can't use compression.
It should be possible to compress the memory state volume in a similar way we do it fot hibernation (virDomainSave) volume.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. 
2.
3.

Actual results:


Expected results:


Additional info:

Comment 2 Peter Krempa 2013-10-14 14:13:57 UTC
Fixed upstream:

commit 7df5093f67f0560d0440807b4363746e032ad942
Author: Peter Krempa <pkrempa>
Date:   Wed Oct 9 18:05:43 2013 +0200

    qemu: snapshot: Add support for compressing external snapshot memory
    
    The regular save image code has the support to compress images using a
    specified algorithm. This was not implemented for external checkpoints
    although it shares most of the backend code.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1017227

Comment 5 EricLee 2013-10-25 07:33:43 UTC
Verifying this bug with libvirt-1.1.1-10.el7.x86_64:

steps:
Part I: For snapshot-create-as:
1. Check qemu.conf:
# cat /etc/libvirt/qemu.conf | grep snapshot_image_format -C10
#
# save_image_format is used when you use 'virsh save' or 'virsh managedsave'     ----->  this is added
# at scheduled saving, and it is an error if the specified save_image_format
# is not valid, or the requested compression program can't be found.
#
# dump_image_format is used when you use 'virsh dump' at emergency
# crashdump, and if the specified dump_image_format is not valid, or
# the requested compression program can't be found, this falls
# back to "raw" compression.
#
# snapshot_image_format specifies the compression algorithm of the memory save
# image when an external snapshot of a domain is taken. This does not apply
# on disk image format. It is an error if the specified format isn't valid,
# or the requested compression program can't be found.   -----> this is added
#
#save_image_format = "raw"
#dump_image_format = "raw"
#snapshot_image_format = "raw"                    -------> this is added.

# When a domain is configured to be auto-dumped when libvirtd receives a
# watchdog event from qemu guest, libvirtd will save dump files in directory
# specified by auto_dump_path. Default value is /var/lib/libvirt/qemu/dump
#
#auto_dump_path = "/var/lib/libvirt/qemu/dump"

# When a domain is configured to be auto-dumped, enabling this flag
# has the same effect as using the VIR_DUMP_BYPASS_CACHE flag with the
# virDomainCoreDump API.  That is, the system will avoid using the

2. Do snapshot with memory state using the default configuration:
# virsh dumpxml r63 | grep disk -A5
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/r63.img'/>
      <target dev='hda' bus='ide'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <controller type='usb' index='0'>
      <alias name='usb0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='ide' index='0'>

# time virsh snapshot-create-as r63 s1 --memspec file=/var/lib/libvirt/images/r63.s1,snapshot=external
Domain snapshot s1 created

real	0m3.777s
user	0m0.011s
sys	0m0.005s

3. Change the guest to the old configuration with the original disk, and modify "snapshot_image_format" to "xz" in qemu.conf, then do snapshot with memory state:
# systemctl restart libvirtd
# cat /etc/libvirt/qemu.conf | grep snapshot_image_format 
# snapshot_image_format specifies the compression algorithm of the memory save
snapshot_image_format = "xz"

# virsh dumpxml r63 | grep disk -A5
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/r63.img'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

# time virsh snapshot-create-as r63 s2 --memspec file=/var/lib/libvirt/images/r63.s2,snapshot=external
Domain snapshot s2 created

real	1m43.509s
user	0m0.011s
sys	0m0.010s

4. Do the same steps as step 3 after change the "snapshot_image_format" to "lzop":
# systemctl restart libvirtd
# cat /etc/libvirt/qemu.conf | grep snapshot_image_format
# snapshot_image_format specifies the compression algorithm of the memory save
snapshot_image_format = "lzop"

# virsh dumpxml r63 | grep disk -A5
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/r63.img'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

# time virsh snapshot-create-as r63 s3 --memspec file=/var/lib/libvirt/images/r63.s3,snapshot=external
Domain snapshot s3 created

real	0m2.102s
user	0m0.005s
sys	0m0.009s

5. Do the same steps as step 3 after change the "snapshot_image_format" to "xxx"(invalid format):
# systemctl restart libvirtd
# cat /etc/libvirt/qemu.conf | grep snapshot_image_format
# snapshot_image_format specifies the compression algorithm of the memory save
snapshot_image_format = "xxx"

# virsh dumpxml r63 | grep disk -A5
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/r63.img'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
  
# time virsh snapshot-create-as r63 s4 --memspec file=/var/lib/libvirt/images/r63.s4,snapshot=external
error: operation failed: Invalid snapshot image format specified in configuration file


real	0m0.058s
user	0m0.011s
sys	0m0.002s

Part II. For managedsave:
Do the same steps as part I:
1. for default configuration:
# cat /etc/libvirt/qemu.conf | grep save_image_format
# for save_image_format.  Note that this means you slow down the process of
# save_image_format is used when you use 'virsh save' or 'virsh managedsave'
# at scheduled saving, and it is an error if the specified save_image_format
#save_image_format = "raw"

# time virsh managedsave r63

Domain r63 state saved by libvirt


real	0m3.515s
user	0m0.011s
sys	0m0.007s

# mv /var/lib/libvirt/qemu/save/r63.save ./r63.save.raw

# ll r63.save.raw 
-rw-------. 1 root root 333056183 Oct 25 15:19 r63.save.raw

2. for save_image_format = "xz":
# time virsh managedsave r63

Domain r63 state saved by libvirt


real	1m45.054s
user	0m0.010s
sys	0m0.011s

3. for save_image_format = "lzop":
# time virsh managedsave r63

Domain r63 state saved by libvirt


real	0m2.079s
user	0m0.011s
sys	0m0.005s

4. for save_image_format = "xxx"(invalid format):
# time virsh managedsave r63
error: Failed to save domain r63 state
error: operation failed: Invalid save image format specified in configuration file


real	0m0.019s
user	0m0.008s
sys	0m0.004s

Works fine, setting VERIFIED.

Comment 6 EricLee 2013-10-25 10:35:23 UTC
(In reply to EricLee from comment #5)
> Verifying this bug with libvirt-1.1.1-10.el7.x86_64:
> 
> steps:
> Part I: For snapshot-create-as:
> 1. Check qemu.conf:
> # cat /etc/libvirt/qemu.conf | grep snapshot_image_format -C10
> #
> # save_image_format is used when you use 'virsh save' or 'virsh managedsave'
> ----->  this is added
> # at scheduled saving, and it is an error if the specified save_image_format
> # is not valid, or the requested compression program can't be found.
> #
> # dump_image_format is used when you use 'virsh dump' at emergency
> # crashdump, and if the specified dump_image_format is not valid, or
> # the requested compression program can't be found, this falls
> # back to "raw" compression.
> #
> # snapshot_image_format specifies the compression algorithm of the memory
> save
> # image when an external snapshot of a domain is taken. This does not apply
> # on disk image format. It is an error if the specified format isn't valid,
> # or the requested compression program can't be found.   -----> this is added
> #
> #save_image_format = "raw"
> #dump_image_format = "raw"
> #snapshot_image_format = "raw"                    -------> this is added.
> 
> # When a domain is configured to be auto-dumped when libvirtd receives a
> # watchdog event from qemu guest, libvirtd will save dump files in directory
> # specified by auto_dump_path. Default value is /var/lib/libvirt/qemu/dump
> #
> #auto_dump_path = "/var/lib/libvirt/qemu/dump"
> 
> # When a domain is configured to be auto-dumped, enabling this flag
> # has the same effect as using the VIR_DUMP_BYPASS_CACHE flag with the
> # virDomainCoreDump API.  That is, the system will avoid using the
> 
> 2. Do snapshot with memory state using the default configuration:
> # virsh dumpxml r63 | grep disk -A5
>     <disk type='file' device='disk'>
>       <driver name='qemu' type='raw'/>
>       <source file='/var/lib/libvirt/images/r63.img'/>
>       <target dev='hda' bus='ide'/>
>       <alias name='ide0-0-0'/>
>       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
>     </disk>
>     <controller type='usb' index='0'>
>       <alias name='usb0'/>
>       <address type='pci' domain='0x0000' bus='0x00' slot='0x01'
> function='0x2'/>
>     </controller>
>     <controller type='ide' index='0'>
> 
> # time virsh snapshot-create-as r63 s1 --memspec
> file=/var/lib/libvirt/images/r63.s1,snapshot=external
> Domain snapshot s1 created
> 
> real	0m3.777s
> user	0m0.011s
> sys	0m0.005s
> 
> 3. Change the guest to the old configuration with the original disk, and
> modify "snapshot_image_format" to "xz" in qemu.conf, then do snapshot with
> memory state:
> # systemctl restart libvirtd
> # cat /etc/libvirt/qemu.conf | grep snapshot_image_format 
> # snapshot_image_format specifies the compression algorithm of the memory
> save
> snapshot_image_format = "xz"
> 
> # virsh dumpxml r63 | grep disk -A5
>     <disk type='file' device='disk'>
>       <driver name='qemu' type='raw'/>
>       <source file='/var/lib/libvirt/images/r63.img'/>
>       <target dev='hda' bus='ide'/>
>       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
>     </disk>
> 
> # time virsh snapshot-create-as r63 s2 --memspec
> file=/var/lib/libvirt/images/r63.s2,snapshot=external
> Domain snapshot s2 created
> 
> real	1m43.509s
> user	0m0.011s
> sys	0m0.010s
> 
> 4. Do the same steps as step 3 after change the "snapshot_image_format" to
> "lzop":
> # systemctl restart libvirtd
> # cat /etc/libvirt/qemu.conf | grep snapshot_image_format
> # snapshot_image_format specifies the compression algorithm of the memory
> save
> snapshot_image_format = "lzop"
> 
> # virsh dumpxml r63 | grep disk -A5
>     <disk type='file' device='disk'>
>       <driver name='qemu' type='raw'/>
>       <source file='/var/lib/libvirt/images/r63.img'/>
>       <target dev='hda' bus='ide'/>
>       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
>     </disk>
> 
> # time virsh snapshot-create-as r63 s3 --memspec
> file=/var/lib/libvirt/images/r63.s3,snapshot=external
> Domain snapshot s3 created
> 
> real	0m2.102s
> user	0m0.005s
> sys	0m0.009s
> 
> 5. Do the same steps as step 3 after change the "snapshot_image_format" to
> "xxx"(invalid format):
> # systemctl restart libvirtd
> # cat /etc/libvirt/qemu.conf | grep snapshot_image_format
> # snapshot_image_format specifies the compression algorithm of the memory
> save
> snapshot_image_format = "xxx"
> 
> # virsh dumpxml r63 | grep disk -A5
>     <disk type='file' device='disk'>
>       <driver name='qemu' type='raw'/>
>       <source file='/var/lib/libvirt/images/r63.img'/>
>       <target dev='hda' bus='ide'/>
>       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
>     </disk>
>   
> # time virsh snapshot-create-as r63 s4 --memspec
> file=/var/lib/libvirt/images/r63.s4,snapshot=external
> error: operation failed: Invalid snapshot image format specified in
> configuration file
> 
> 
> real	0m0.058s
> user	0m0.011s
> sys	0m0.002s

# virsh snapshot-list r63
 Name                 Creation Time             State
------------------------------------------------------------
 s1                   2013-10-25 13:55:05 +0800 running
 s2                   2013-10-25 14:34:25 +0800 running
 s3                   2013-10-25 15:05:21 +0800 running

> 
> Part II. For managedsave:
> Do the same steps as part I:
> 1. for default configuration:
> # cat /etc/libvirt/qemu.conf | grep save_image_format
> # for save_image_format.  Note that this means you slow down the process of
> # save_image_format is used when you use 'virsh save' or 'virsh managedsave'
> # at scheduled saving, and it is an error if the specified save_image_format
> #save_image_format = "raw"
> 
> # time virsh managedsave r63
> 
> Domain r63 state saved by libvirt
> 
> 
> real	0m3.515s
> user	0m0.011s
> sys	0m0.007s
> 
> # mv /var/lib/libvirt/qemu/save/r63.save ./r63.save.raw
> 
> # ll r63.save.raw 
> -rw-------. 1 root root 333056183 Oct 25 15:19 r63.save.raw
> 
> 2. for save_image_format = "xz":
> # time virsh managedsave r63
> 
> Domain r63 state saved by libvirt
> 
> 
> real	1m45.054s
> user	0m0.010s
> sys	0m0.011s
> 
> 3. for save_image_format = "lzop":
> # time virsh managedsave r63
> 
> Domain r63 state saved by libvirt
> 
> 
> real	0m2.079s
> user	0m0.011s
> sys	0m0.005s
> 
> 4. for save_image_format = "xxx"(invalid format):
> # time virsh managedsave r63
> error: Failed to save domain r63 state
> error: operation failed: Invalid save image format specified in
> configuration file
> 
> 
> real	0m0.019s
> user	0m0.008s
> sys	0m0.004s

# ll r63.save.*
-rw-------. 1 root root 109589166 Oct 25 18:30 r63.save.lzop
-rw-------. 1 root root 333056183 Oct 25 15:19 r63.save.raw
-rw-------. 1 root root  51314096 Oct 25 15:22 r63.save.xz

# ll /var/lib/libvirt/images/r63.s*
-rw-------. 1 root root 1310720 Oct 25 13:58 /var/lib/libvirt/images/r63.s1 ---> raw
-rw-------. 1 root root 1048576 Oct 25 14:59 /var/lib/libvirt/images/r63.s2  ---> xz
-rw-------. 1 root root 2621440 Oct 25 15:07 /var/lib/libvirt/images/r63.s3  ---> lzop

> 
> Works fine, setting VERIFIED.

Comment 7 Ludek Smid 2014-06-13 09:38:55 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.