Description of problem: when I test snapshot, I create a parent snapshot and a chindren snapshot, when I first delete the parent snapshot and then delete the children snapshot, there will be an error: "Domain snapshot not found: no domain snapshot parent with matching name 'snapshot1'" Version-Release number of selected component (if applicable): libvirt-0.8.4-3.fc15.x86_64 kernel-2.6.35.6-45.fc14.x86_64 qemu-kvm-0.13.0-1.fc14.x86_64 How reproducible: 100% Steps to Reproduce: 1.#cat snapshot1.xml <domainsnapshot> <name>snapshot1</name> <description>Snapshot of OS install and updates</description> <state>running</state> <creationTime>1290186373</creationTime> <domain> <uuid>6d49ba8d-15d7-4456-923f-f83d7253982c</uuid> </domain> </domainsnapshot> #cat snapshot2.xml <domainsnapshot> <name>snapshot2</name> <description>Snapshot of OS install and updates</description> <state>running</state> <creationTime>1290186373</creationTime> <domain> <uuid>6d49ba1d-15d7-4456-923f-f83d7253982c</uuid> </domain> </domainsnapshot> 2.#virsh start vm-qcow2 3.#virsh snapshot-create vm-qcow2 snapshot.xml #virsh snapshot-current vm-qcow2 <domainsnapshot> <name>snapshot1</name> <description>Snapshot of OS install and updates</description> <state>running</state> <creationTime>1289294305</creationTime> <domain> <uuid>6d49ba8d-15d7-4456-923f-f83d7253982c</uuid> </domain> </domainsnapshot> 4.# virsh snapshot-create vm-qcow2 snapshot2.xml # virsh snapshot-current vm-qcow2 <domainsnapshot> <name>snapshot2</name> <description>Snapshot of OS install and updates</description> <state>running</state> <parent> <name>snapshot1</name> </parent> <creationTime>1289294492</creationTime> <domain> <uuid>6d49ba8d-15d7-4456-923f-f83d7253982c</uuid> </domain> </domainsnapshot> 5.# virsh snapshot-list vm-qcow2 Name Creation Time State --------------------------------------------------- snapshot1 2010-11-09 17:18:25 +0800 running snapshot2 2010-11-09 17:21:32 +0800 running 6.# virsh snapshot-delete qcow2 snapshot1 # virsh snapshot-delete qcow2 snapshot2 Actual results: error: Domain snapshot not found: no domain snapshot parent with matching name 'snapshot1' Expected results: delete successfully with no error Additional info: if I restart libvirtd before delete the snapshot2 which set the current snapshot of vm-qcow2 to none, then it can be deleted successfully on /var/log/messages Nov 9 18:28:51 dhcp-93-102 libvirtd: 18:28:51.146: error : qemuMonitorTextDeleteSnapshot:2559 : operation failed: Error -2 while deleting snapshot on 'drive-ide0-0-0'#015#012 Nov 9 18:28:51 dhcp-93-102 libvirtd: 18:28:51.148: error : qemuDomainSnapshotDiscard:12447 : Domain snapshot not found: no domain snapshot parent with matching name 'snapshot1'
HI, I make a patch for using libvirt-0.8.1. I have tried it. It is ok. --- libvirt-0.8.1/src/qemu/qemu_driver.c 2010-11-24 10:14:11.000000000 +0800 +++ libvirt-0.8.1.new/src/qemu/qemu_driver.c 2010-11-24 11:02:59.000000000 +0800 @@ -12733,13 +12733,11 @@ static int qemuDomainSnapshotDiscard(str parentsnap = virDomainSnapshotFindByName(&vm->snapshots, snap->def->parent); if (!parentsnap) { - qemuReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT, - _("no domain snapshot parent with matching name '%s'"), - snap->def->parent); - goto cleanup; + VIR_FREE(snap->def->parent); + snap->def->parent = NULL; } - /* Now we set the new current_snapshot for the domain */ + /* Now we set the new current_snapshot for the domain , may be parentsnap is null*/ vm->current_snapshot = parentsnap; } else
This package has changed ownership in the Fedora Package Database. Reassigning to the new owner of this component.
This should be fixed in 0.9.5, via this commit and a few others: commit cb231b4bee882213c77d360d2d8ff96851542b64 Author: Eric Blake <eblake> Date: Fri Aug 12 07:05:50 2011 -0600 snapshot: avoid crash when deleting qemu snapshots This one's nasty. Ever since we fixed virHashForEach to prevent nested hash iterations for safety reasons (commit fba550f6), virDomainSnapshotDelete with VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN has been broken for qemu: it deletes children, while leaving grandchildren intact but pointing to a no-longer-present parent. But even before then, the code would often appear to succeed to clean up grandchildren, but risked memory corruption if you have a large and deep hierarchy of snapshots. For acting on just children, a single virHashForEach is sufficient. But for acting on an entire subtree, it requires iteration; and since we declared recursion as invalid, we have to switch to a while loop. Doing this correctly requires quite a bit of overhaul, so I added a new helper function to isolate the algorithm from the actions, so that callers do not have to reinvent the iteration.