• E
    snapshot: Add accessor for reparenting snapshot children · ced0898f
    Eric Blake 提交于
    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: NEric Blake <eblake@redhat.com>
    Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
    ced0898f
test_driver.c 197.9 KB