mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-26 15:45:28 +00:00
snapshot: fix rollback failure in transaction mode
BZ:https://bugzilla.redhat.com/show_bug.cgi?id=843372 when qemu supports the 'transaction' monitor command, and libvirt's --reuse-ext flag was not specified, libvirt created a stub file with zero size in first place. After the failure of QEMU transaction command performing qcow2 snapshots on more than one drives, the stub file is left behind with non-empty by the QEMU transaction command. In order to unlink the file, the patch removes the file size checking. Steps to reproduce the issue: Steps: 1, Create a qemu instance with two drive images of qcow2 type (root user) /usr/libexec/qemu-kvm -m 1024 -smp 1 -name "rhel6u1" \ -drive file=/var/lib/libvirt/images/firstqcow2,if=none,id=drive-virtio-disk0,format=qcow2,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -drive file=/var/lib/libvirt/images/secondqcow2,if=none,id=drive-virtio-disk1,format=qcow2,cache=none \ -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x7,drive=drive-virtio-disk1,id=virtio-disk1 -qmp stdio 2, Initialize qemu qmp {"execute":"qmp_capabilities"} 3, Remove the second drive image file rm -f /var/lib/libvirt/images/secondqcow2 4, Run 'transaction' command with snapshot qemu commands in. {"execute":"transaction","arguments": {"actions": [{"type":"blockdev-snapshot-sync","data": {"device":"drive-virtio-disk0","snapshot-file":"/var/lib/libvirt/images/firstqcow2-snapshot.img","format":"qcow2"} }, {"type":"blockdev-snapshot-sync","data": {"device":"drive-virtio-disk1","snapshot-file":"/var/lib/libvirt/images/secondqcow2-snapshot.img","format":"qcow2"} }] }, "id":"libvirt-6"} 5, Got the error as follows: {"id": "libvirt-6", "error": {"class": "OpenFileFailed", "desc": "Could not open '/var/lib/libvirt/images/secondqcow2-snapshot.img'", "data": {"filename": "/var/lib/libvirt/images/secondqcow2-snapshot.img"} } } 6, List first newly-created snapshot file: -rw-r--r--. 1 root root 262144 Sep 13 11:43 firstqcow2-snapshot.img
This commit is contained in:
parent
1e2864c2cd
commit
ac89a611d4
@ -10833,7 +10833,7 @@ qemuDomainSnapshotUndoSingleDiskActive(struct qemud_driver *driver,
|
|||||||
if (virDomainLockDiskDetach(driver->lockManager, vm, disk) < 0)
|
if (virDomainLockDiskDetach(driver->lockManager, vm, disk) < 0)
|
||||||
VIR_WARN("Unable to release lock on %s", disk->src);
|
VIR_WARN("Unable to release lock on %s", disk->src);
|
||||||
if (need_unlink && stat(disk->src, &st) == 0 &&
|
if (need_unlink && stat(disk->src, &st) == 0 &&
|
||||||
st.st_size == 0 && S_ISREG(st.st_mode) && unlink(disk->src) < 0)
|
S_ISREG(st.st_mode) && unlink(disk->src) < 0)
|
||||||
VIR_WARN("Unable to remove just-created %s", disk->src);
|
VIR_WARN("Unable to remove just-created %s", disk->src);
|
||||||
|
|
||||||
/* Update vm in place to match changes. */
|
/* Update vm in place to match changes. */
|
||||||
|
Loading…
Reference in New Issue
Block a user