snapshot: qemu: Fix segfault and vanishing snapshots when redefining
snapshot: qemu: Fix segfault and vanishing snapshots when redefining

When the disk alignment check done while redefining an existing snapshot
failed, the qemu driver attempted to free the existing snapshot. As in
the cleanup path the definition of the snapshot wasn't assigned, the
cleanup code dereferenced a NULL pointer.

This patch changes the behavior on error paths while redefining snapshot
in two ways:

1) On failure, modifications done on the snapshot definition object are
rolled back.

2) The previous definition of the data isn't freed until it's certain it
won't be needed any more.

This change avoids the segfault and additionally the snapshot doesn't
vanish if redefinition fails for some reason.

rlaager/libvirt,eskultety/libvirt,VenkatDatta/libvirt,taget/libvirt,elmarco/libvirt,crobinso/libvirt,crobinso/libvirt,eskultety/libvirt,VenkatDatta/libvirt,nertpinx/libvirt,iam-TJ/libvirt,shugaoye/libvirt,cbosdo/libvirt,fabianfreyer/libvirt,libvirt/libvirt,trainstack/libvirt,bjzhang/libvirt,andreabolognani/libvirt,datto/libvirt,taget/libvirt,fabianfreyer/libvirt,jardasgit/libvirt,olafhering/libvirt,siboulet/libvirt-openvz,cbosdo/libvirt,iam-TJ/libvirt,nertpinx/libvirt,shugaoye/libvirt,fabianfreyer/libvirt,crobinso/libvirt,iam-TJ/libvirt,trainstack/libvirt,cbosdo/libvirt,bjzhang/libvirt,trainstack/libvirt,zippy2/libvirt,shugaoye/libvirt,nertpinx/libvirt,elmarco/libvirt,iam-TJ/libvirt,zhlcindy/libvirt-1.1.4-maintain,jardasgit/libvirt,datto/libvirt,zhlcindy/libvirt-1.1.4-maintain,trainstack/libvirt,iam-TJ/libvirt,siboulet/libvirt-openvz,trainstack/libvirt,datto/libvirt,fabianfreyer/libvirt,elmarco/libvirt,olafhering/libvirt,eskultety/libvirt,rlaager/libvirt,zippy2/libvirt,taget/libvirt,siboulet/libvirt-openvz,agx/libvirt,VenkatDatta/libvirt,trainstack/libvirt,jardasgit/libvirt,fabianfreyer/libvirt,elmarco/libvirt,jfehlig/libvirt,VenkatDatta/libvirt,datto/libvirt,eskultety/libvirt,rlaager/libvirt,libvirt/libvirt,VenkatDatta/libvirt,taget/libvirt,bjzhang/libvirt,zhlcindy/libvirt-1.1.4-maintain,jardasgit/libvirt,bjzhang/libvirt,elmarco/libvirt,cbosdo/libvirt,zippy2/libvirt,olafhering/libvirt,iam-TJ/libvirt,jfehlig/libvirt,cbosdo/libvirt,jfehlig/libvirt,nertpinx/libvirt,libvirt/libvirt,agx/libvirt,eskultety/libvirt,shugaoye/libvirt,siboulet/libvirt-openvz,olafhering/libvirt,rlaager/libvirt,andreabolognani/libvirt,trainstack/libvirt,bjzhang/libvirt,siboulet/libvirt-openvz,zhlcindy/libvirt-1.1.4-maintain,jfehlig/libvirt,datto/libvirt,rlaager/libvirt,zhlcindy/libvirt-1.1.4-maintain,agx/libvirt,andreabolognani/libvirt,zippy2/libvirt,andreabolognani/libvirt,agx/libvirt,jardasgit/libvirt,crobinso/libvirt,nertpinx/libvirt,iam-TJ/libvirt,libvirt/libvirt,taget/libvirt,agx/libvirt,andreabolognani/libvirt,shugaoye/libvirt