]> git.ipfire.org Git - thirdparty/libvirt.git/commit
snapshot: Add accessor for reparenting snapshot children
authorEric Blake <eblake@redhat.com>
Thu, 21 Mar 2019 20:33:21 +0000 (15:33 -0500)
committerEric Blake <eblake@redhat.com>
Fri, 22 Mar 2019 06:18:25 +0000 (01:18 -0500)
commitced0898f86bf63876ce4a92a196c62d37c5b119c
treee792d36930eb339b948be39c5f34a757374ab440
parent4819f54bd3b2417847fe40ead03e3b1a6f5d334e
snapshot: Add accessor for reparenting snapshot children

Rather than allowing a leaky abstraction where multiple drivers have
to open-code operations that update the relations in a
virDomainSnapshotObjList, it is better to add accessor functions so
that updates to relations are maintained closer to the internals.
This patch starts the task with a single new function:
virDomainSnapshotMoveChildren(). The logic might not be immediately
obvious [okay, that's an understatement - the existing code uses black
magic ;-)], so here's an overview: The old code has an implicit for
loop around each call to qemuDomainSnapshotReparentChildren() by using
virDomainSnapshotForEachChild() (you'll need a wider context than
git's default of 3 lines to see that); the new code has a more visible
for loop. Then it helps if you realize that the code is making two
separate changes to each child object: STRDUP of the new parent name
prior to writing XML files (unchanged), and touching up the pointer to
the parent object (refactored); the end result is the same whether a
single pass made both changes (both in driver code), or whether it is
split into two passes making one change each (one in driver code, the
other in the new accessor).

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