Bug 834196 - Domain restore fails from a saved state in a file with xml option.
Domain restore fails from a saved state in a file with xml option.
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt (Show other bugs)
6.3
x86_64 Linux
medium Severity medium
: rc
: 6.3
Assigned To: Ján Tomko
Virtualization Bugs
: Reopened, Upstream, ZStream
Depends On:
Blocks: 1153323 1180147 1180521
  Show dependency treegraph
 
Reported: 2012-06-21 03:47 EDT by lei wang
Modified: 2015-07-22 01:45 EDT (History)
15 users (show)

See Also:
Fixed In Version: libvirt-0.10.2-48.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 955484 1180521 (view as bug list)
Environment:
Last Closed: 2015-07-22 01:45:51 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description lei wang 2012-06-21 03:47:32 EDT
Description of problem:
Error message shown when restore a domain from a saved state in a file with xml option.

Version-Release number of selected component (if applicable):
# rpm -qa |grep libvirt
libvirt-client-0.9.10-21.el6.x86_64
libvirt-python-0.9.10-21.el6.x86_64
libvirt-0.9.10-21.el6.x86_64


How reproducible:
100%

Steps to Reproduce:
1.Start a guest
# virsh start rhel6

2.# virsh dumpxml rhel6 > rhel6.xml

3.Copy the image of guest to /tmp/
# cp /var/lib/libvirt/images/rhel6.img /tmp/

4.Edit rhel6.xml to change /var/lib/libvirt/images/rhel6.img to /tmp/rhel6.img

5.Save the guest with --xml 
# virsh save rhel6 rhel6.save --xml rhel6.xml 

6. Check that xml embedded in binary rhel6.save did change
#vim rhel6.save  

7. Restore guest with --xml 
# virsh restore rhel6.save --xml rhel6.xml 
  
Actual results:
# virsh restore test.save --xml test.xml 
error: Failed to restore domain from test.save
error: unsupported configuration: Target device address type pci does not match source none


Expected results:
# virsh restore rhel6.save --xml rhel6.xml
Domain restored from rhel6.save

Additional info:
Tested with libvirt-0.9.10-9.el6.x86_64 and libvirt-0.9.10-21.el6.Compared with the two xml in save file.
In libvirt-0.9.10-9.el6.x86_64,it has usb content:
<controller type='usb' index='0'>
 <address type='pci' domain='0x0000' bus='0x00' slot='0x01'function='0x2'/>
</controller>
But in libvirt-0.9.10-21.el6,it doesn't have this xml.
Comment 2 Dave Allan 2012-06-21 09:53:48 EDT
Can you comment with the minimal steps to reproduce?  It sounds to me like there are a bunch of steps in the description that aren't necessary.
Comment 3 lei wang 2012-06-24 21:57:20 EDT
Update steps to reproduce:
# virsh start rhel6q
Domain rhel6q started

# virsh dumpxml rhel6q > rhel6q.xml
# vim rhel6q.xml 
==> Change disk path to /tmp/rhel6q.img
# virsh save rhel6q rhel6q.save --xml rhel6q.xml 

Domain rhel6q saved to rhel6q.save

# virsh restore rhel6q.save --xml rhel6q.xml
error: Failed to restore domain from rhel6q.save
error: unsupported configuration: Target controller type usb does not match source ide

Hi Dave, I remove some steps, it's minimal steps to reproduce.
Comment 4 Ján Tomko 2012-08-03 10:55:11 EDT
Upstream patch proposed:
https://www.redhat.com/archives/libvir-list/2012-August/msg00201.html
Comment 8 Ján Tomko 2013-06-13 11:33:02 EDT
Now fixed upstream:
commit 07966f6a8b5ccb5bb4c716b25deb8ba2e572cc67
Author:     Ján Tomko <jtomko@redhat.com>
AuthorDate: 2013-06-11 15:03:17 +0200
Commit:     Ján Tomko <jtomko@redhat.com>
CommitDate: 2013-06-13 16:58:30 +0200

    qemu: allow restore with non-migratable XML input
    
    Convert input XML to migratable before using it in
    qemuDomainSaveImageOpen.
    
    XML in the save image is migratable, i.e. doesn't contain implicit
    controllers. If these controllers were in a non-default order in the
    input XML, the ABI check would fail. Removing and re-adding these
    controllers fixes it.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=834196
                                                                                                                                         
git describe: v1.0.6-70-g07966f6
Comment 9 Ján Tomko 2013-06-14 04:21:44 EDT
Downstream patch posted:
http://post-office.corp.redhat.com/archives/rhvirt-patches/2013-June/msg00243.html
Comment 10 Jiri Denemark 2013-06-24 06:28:40 EDT
We decided not to rebase libvirt in RHEL 6.5 to avoid stability issues
we faced in 6.4. This bug has already been fixed upstream but it is
considered unsuitable for backporting to RHEL 6.5 because this bug is
not important enough to justify backporting non-trivial patches for it.

Thus I'm pushing this bug to RHEL 6.6 (and setting Upstream keyword to
indicate we have patches upstream) for now. If you don't agree with
this resolution, please, give us reasons which you think are strong
enough for us to reevaluate the decision not to backport patches for
this bug.
Comment 11 Peter Krempa 2013-09-16 08:56:04 EDT
Backporting of the patch fixing this issue causes failures when reverting external snapshots. See: https://bugzilla.redhat.com/show_bug.cgi?id=1008340
Comment 14 RHEL Product and Program Management 2014-04-04 17:01:03 EDT
Development Management has reviewed and declined this request.
You may appeal this decision by reopening this request.
Comment 17 zhenfeng wang 2015-01-07 02:09:03 EST
Hi Jan
The following steps were all my reproduce and verify steps, the verify steps have covered the 2 scratch builds. Please help check whethere they are enough or not to verify your scratch builds, thanks.

Reproduce steps:
1.Prepare a guest xml without usb controller
2.Define the guest, after we define the guest, we could see the usb controller 
added in the guest's xml automatically
#virsh define rhel67.xml
#virsh dumpxml rhel67 |grep usb
--
    <controller type='usb' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>

3.Start the guest, then dump the guest's xml to 2 local file, 1 is the definition guest's xml, one is the migrable guest's xml
#virsh start rhel67
# virsh dumpxml rhel67 >rhel67def.xml
# virsh dumpxml rhel67 --migratable >rhel67mig.xml

4.Save the guest by specifying the defination guest's xml we get in step 3
# virsh save rhel67 rhel67.save --xml rhel67def.xml 

Domain rhel67 saved to rhel67.save

5.Edit the save file, we couldn found the xml stored in the save file was the same with the migrable guest's xml, but different with the defination guest's xml
#vim rhel67.save

6.Restore the guest with the defination guest xml, the guest will fail to restart since the xml save in the save file wasn't compatible with the defination guest's xml

# virsh restore rhel67.save --xml rhel67def.xml 
error: Failed to restore domain from rhel67.save
error: unsupported configuration: Target device address type pci does not match source none

# virsh restore rhel67.save --xml rhel67mig.xml 
Domain restored from rhel67.save

7.Fresh start the guest, then do external mem snapshot with the guest
#virsh start rhel67
#virsh snapshot-create-as rhel67 sss1 --memspec file=/tmp/rhel67.sss1
Domain snapshot sss1 created

8.Edit the external mem snapshot file, we could found the guest's xml stored in the external mem snapshot file was the same with the defination guest'xml, but different with the migratable guest's xml
#vim /tmp/rhel67.sss1

9.Revert the snapshot with the snapshot-revert command directly, it will report the following error
# virsh snapshot-revert rhel67 sss1
error: revert requires force: Target device address type none does not match source pci

10.Destroy the guest, then revert the snapshot by using restoreFlags with migratable guest's xml, the guest couldn't be restored successfully, since the guest's xml stored in the external mem snapshot file wasn't compatible with the migrable guest's xml

# virsh restore /tmp/rhel67.sss1 --xml rhel67mig.xml 
error: Failed to restore domain from /tmp/rhel67.sss1
error: unsupported configuration: Target device address type none does not match source pci

11.Revert the snapshot by using restoreFlags with defination guest's xml, the guest could be restored successfully
# virsh restore /tmp/rhel67.sss1 --xml rhel67def.xml 
Domain restored from /tmp/rhel67.sss1


Verify this bug with the first scratch build
#rpm -qa|grep libvirt
libvirt-0.10.2-46.el6_6.2bz834196a.x86_64.rpm

steps were the same with the reproduce steps
1.The guest could be restored successfully with both the defination guest's xml and the migratable guest's xml
# virsh restore rhel67.save --xml rhel67def.xml 
Domain restored from rhel67.save

# virsh restore rhel67.save --xml rhel67mig.xml 
Domain restored from rhel67.save

2.Do external mem snapshot with the guest, edit the external mem snapshot file, found the guest's xml stored in the snapshot file was the same with the migratable guest's xml
# virsh snapshot-create-as rhel67 sss1 --memspec file=/tmp/rhel67.sss1
Domain snapshot sss1 created

#vim /tmp/rhel67.sss1

3.Revert the snapshot with the snapshot-revert command directly, it will report the following error , also the guest will be paused while fail to do snapshot-revert. Could also hit the issue in libvirt-47. Found 2 exsiting bugs  1101987,1179532 about this issue in both rhel6 and rhel7, and the bug 1101987 in rhel7 has been fixed
# virsh snapshot-revert rhel67 sss1
error: Requested operation is not valid: the snapshot 'sss1' does not exist, and was not loaded

# virsh list
 Id    Name                           State
----------------------------------------------------
 8     rhel67                         paused

4.Destroy the guest, then revert the snapshot by using restoreFlags with both migratable and defination guest' xml, all of them could be restored successfully

# virsh restore /tmp/rhel67.sss1 --xml rhel67def.xml 
Domain restored from /tmp/rhel67.sss1

--
# virsh restore /tmp/rhel67.sss1 --xml rhel67mig.xml 
Domain restored from /tmp/rhel67.sss1
Comment 18 zhenfeng wang 2015-01-07 02:10:21 EST
Verify this bug with the second scratch build
#rpm -qa|grep libvirt
libvirt-0.10.2-46.el6_6.2bz834196revert.x86_64.rpm

steps were the same with the reproduce steps
1.since this scratch build didn't include the patch which fix bug 834196, the issue in reproduce steps stay exsting
 # virsh restore rhel67.save --xml rhel67def.xml 
error: Failed to restore domain from rhel67.save
error: unsupported configuration: Target device address type pci does not match source none

# virsh restore rhel67.save --xml rhel67mig.xml 
Domain restored from rhel67.save

2.Do external mem snapshot with the guest, edit the external mem snapshot file, found the guest's xml stored in the snapshot file was still the same with the defination guest's xml
# virsh snapshot-create-as rhel67 sss1 --memspec file=/tmp/rhel67.sss1
Domain snapshot sss1 created

#vim /tmp/rhel67.sss1

3.Revert the snapshot with the snapshot-revert command directly, hit the same issue with first scratch build 
# virsh snapshot-revert rhel67 sss1
error: Requested operation is not valid: the snapshot 'sss1' does not exist, and was not loaded

# virsh list
 Id    Name                           State
----------------------------------------------------
 8     rhel67                         paused

4.Destroy the guest, then revert the snapshot by using restoreFlags with both migratable and defination guest' xml, get the same result with the reproduce steps, the following issue maybe depends on the the patch which fix bug 834196

# virsh restore /tmp/rhel67.sss1 --xml rhel67def.xml 
Domain restored from /tmp/rhel67.sss1

--
# virsh restore /tmp/rhel67.sss1 --xml rhel67mig.xml 
error: Failed to restore domain from /tmp/rhel67.sss1
error: unsupported configuration: Target device address type none does not match source pci
Comment 20 Ján Tomko 2015-01-09 03:33:32 EST
The verification steps look good to me.
Comment 23 Luyao Huang 2015-02-04 22:40:50 EST
I can reproduce this issue with libvirt-0.10.2-46.el6.x86_64:

1. # virsh dumpxml r6
    <controller type='usb' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='ccid' index='0'/>

2. # virsh start r6

3.# virsh dumpxml r6 > r6.xml
4.# virsh dumpxml r6 --migratable > r6mig.xml

5.edit r6.xml and r6mig.xml and change disk path to /tmp/r6.img
# vim r6mig.xml
# vim r6.xml

6.# virsh save r6 r6.save --xml r6.xml

Domain r6 saved to r6.save

7. check the r6.save if the disk path have been changed:

# vim r6.save

8. restore vm and will failed with r6.xml:

# virsh restore r6.save --xml r6.xml
error: Failed to restore domain from r6.save
error: unsupported configuration: Target controller type usb does not match source ccid

# virsh restore r6.save --xml r6mig.xml
Domain restored from r6.save

And verify this issue with  libvirt-0.10.2-48.el6:

1.# virsh dumpxml r6
    <controller type='usb' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='ccid' index='0'/>

2.
# virsh start r6
Domain r6 started

3.# virsh dumpxml r6 > r6.xml
4.# virsh dumpxml r6 --migratable > r6mig.xml

5.edit r6.xml and r6mig.xml and change disk path to /tmp/r6.img
# vim r6mig.xml
# vim r6.xml


6.# virsh save r6 r6.save --xml r6.xml

Domain r6 saved to r6.save

7. check the r6.save if the disk path have been changed:

# vim r6.save

8. restore vm and will success with r6.xml and r6mig.xml:

# virsh restore r6.save --xml r6.xml
Domain restored from r6.save

# virsh destroy r6
Domain r6 destroyed

# virsh restore r6.save --xml r6mig.xml
Domain restored from r6.save

9.do external snapshot:

# virsh snapshot-create-as r6 s1 --memspec file=/tmp/r6.s1
Domain snapshot s1 created

# virsh snapshot-revert r6 s1
error: unsupported configuration: revert to external snapshot not supported yet

# virsh restore /tmp/r6.s1 --xml r6.xml
Domain restored from /tmp/r6.s1
Comment 25 errata-xmlrpc 2015-07-22 01:45:51 EDT
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/RHBA-2015-1252.html

Note You need to log in before you can comment on or make changes to this bug.