Bug 1293899

Summary: Libvirt mishandle the internal snapshot with AHCI device
Product: Red Hat Enterprise Linux 7 Reporter: Yang Yang <yanyang>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.2CC: dyuan, hhan, mike, mzhan, oblaut, rbalakri, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.3.2-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 18:50:07 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 Yang Yang 2015-12-23 12:35:21 UTC
Description of problem:
Qemu-kvm-rhev does not support 'savevm' snapshot with AHCI device now. And it prompts meaningful error like this "State blocked by non-migratable device '0000:00:08.0/ich9_ahci'". However, libvirt mishandle the behaviour. Libvirt can create internal snapshot with AHCI device without any error. It makes no sense.

Version-Release number of selected component (if applicable):
libvirt-1.2.17-13.el7_2.2.x86_64
qemu-kvm-rhev-2.3.0-31.el7_2.5.x86_64

How reproducible:
100%

Steps to Reproduce:
1. prepare a running domain with following xml
<os>
    <type arch='x86_64' machine='pc-i440fx-rhel7.2.0'>hvm</type>
  </os>
<disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/rhel7.2.qcow2'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <boot order='1'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </disk>
<controller type='sata' index='0'>
      <alias name='sata0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </controller>

2. create an internal snapshot
# virsh snapshot-create-as vm1 internal1
Domain snapshot internal1 created
3.

Actual results:
Internal snapshot is created with AHCI device without any error

Expected results:
Should prompt error like this
error: Failed to create internal snapshot
error: internal error: unable to execute QEMU command 'migrate': State blocked by non-migratable device '0000:00:0a.0/ich9_ahci'


Additional info:
Tested with qemu-kvm-rhev, error out when savevm
1. Boot a guest with 'ahci' device
# /usr/libexec/qemu-kvm -name rhel7.2 \
-machine pc-i440fx-rhel7.2.0 \
-m 1024 \
-smp 4,sockets=1,cores=2,threads=2 \
-drive file=/home/rhel7.2.qcow2,if=none,id=drive-virtio-disk0,format=qcow2 \
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x9,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
-monitor stdio \
-vnc 0.0.0.0:2 \
-qmp tcp:0:5555,server,nowait \
-device ahci,id=sata0,bus=pci.0,addr=0x8 \
2. Create internal snapshot. Qemu will prompt 'State blocked' message which means creating fail.
(qemu) savevm sn1
State blocked by non-migratable device '0000:00:08.0/ich9_ahci'

3. Check internal snapshots, there is no one which can confirm creating fail in step2.
(qemu) info snapshots
There is no snapshot available.

Comment 1 Han Han 2015-12-30 06:41:35 UTC
Upstream has handled it:
Guest with the sata controller as following:
<controller type='sata' index='0'>
</controller>

# virsh snapshot-create-as n1 s1 
error: operation failed: Error -22 while writing VM

Comment 2 Peter Krempa 2016-01-15 14:02:42 UTC
Current upstream qemu actually does support migration with AHCI so you will not get this message. Older versions of qemu are broken though.

Comment 3 Peter Krempa 2016-01-25 06:40:01 UTC
Fixed upstream:

commit 4ac14cde9ae925515009400c2186d7eec5478b05
Author: Peter Krempa <pkrempa>
Date:   Fri Jan 15 13:01:30 2016 +0100

    qemu: snapshot: Correctly report qemu error on 'savevm'
    
    Since 'savevm' was not converted to QMP libvirt has to parse for error
    strings in the text monitor output. One of the unhandled errors is
    produced when qemu treats a device as unmigratable.
    
    As current qemu actually does support AHCI migration this bug is
    applicable only to older versions of qemu.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1293899

commit 0c1b0d83bb4c41123068a9efdb6daac0f326e707
Author: Peter Krempa <pkrempa>
Date:   Fri Jan 15 12:53:30 2016 +0100

    qemu: monitor: Refactor error handling for 'savevm'
    
    Unify few error conditions into a single error reporting case.

v1.3.1-38-g4ac14cd

Comment 5 Han Han 2016-03-25 05:44:19 UTC
Verify it on libvirt-1.3.2-1.el7.x86_64
Prepare an VM with following xml, and start the VM:
 <controller type='sata' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </controller>

For qemu doesn't support ahci migration: qemu-kvm-rhev-2.3.0-31.el7_2.10.x86_64
# virsh snapshot-create-as ahci internal                                                      
error: operation failed: Failed to take snapshot: State blocked by non-migratable device '0000:00:07.0/ich9_ahci'

# virsh migrate --live ahci qemu+ssh://lab.work.me/system --verbose --unsafe --p2p --tunnelled                    
error: internal error: unable to execute QEMU command 'migrate': State blocked by non-migratable device '0000:00:07.0/ich9_ahci'

For qemu supports ahci migration: qemu-kvm-rhev-2.5.0-3.el7.x86_64
# virsh migrate --live ahci qemu+ssh://lab.work.me/system --verbose --unsafe --p2p --tunnelled
Migration: [100 %]

# virsh snapshot-create-as ahci internal                                                      
Domain snapshot internal created

Comment 7 errata-xmlrpc 2016-11-03 18:50:07 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2016-2577.html