]> xenbits.xensource.com Git - libvirt.git/commit
snapshot: Track current snapshot in virDomainSnapshotObjList
authorEric Blake <eblake@redhat.com>
Thu, 21 Mar 2019 20:00:08 +0000 (15:00 -0500)
committerEric Blake <eblake@redhat.com>
Fri, 22 Mar 2019 06:15:20 +0000 (01:15 -0500)
commit4819f54bd3b2417847fe40ead03e3b1a6f5d334e
treedadeec9e116742ecfed8fa272923a2807771252d
parent40bc98ddaf3457778d586b3025cf5cd6029a344b
snapshot: Track current snapshot in virDomainSnapshotObjList

It is easier to track the current snapshot as part of the list of
snapshots. In particular, doing so lets us guarantee that the current
snapshot is cleared if that snapshot is removed from the list (rather
than depending on the caller to do so, and risking a use-after-free
problem, such as the one recently patched in 1db9d0efbf).  This
requires the addition of several new accessor functions, as well as a
useful return type for virDomainSnapshotObjListRemove().  A few error
handling sites that were previously setting vm->current_snapshot =
NULL can now be dropped, because the previous function call has now
done it already.  Also, qemuDomainRevertToSnapshot() was setting the
current vm twice, so keep only the one used on the success path.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/conf/domain_conf.h
src/conf/snapshot_conf.c
src/conf/virdomainsnapshotobjlist.c
src/conf/virdomainsnapshotobjlist.h
src/libvirt_private.syms
src/qemu/qemu_domain.c
src/qemu/qemu_driver.c
src/test/test_driver.c