
On 2/20/19 9:53 AM, Eric Blake wrote:
Continue the work of the previous patch in making it possible to copy the state of a transient domain with snapshots from one host to another, by allowing the destination to perform bulk redefines. Note that the destination still has to do separate calls for creating/defining the domain first, and then redefining the snapshots (that is, there is intentional asymmetry between dumping the list in virDomainGetXMLDesc() but redefining it via virDomainSnapshotCreateXML()), but this is better than the previous state of having to make multiple REDEFINE calls. The bulk flag requires no pre-existing snapshot metadata (as that makes life much easier if there is a failure encountered partway through the list processing - simply remove all other snapshot metadatas), and makes no guarantees on which snapshot (when there are multiple) will actually be returned.
Wire up the virsh snapshot-create command to support the new flag.
Actual driver implementations will be in later patches.
Signed-off-by: Eric Blake <eblake@redhat.com> --- include/libvirt/libvirt-domain-snapshot.h | 3 +++ src/libvirt-domain-snapshot.c | 21 ++++++++++++++++++--- tools/virsh-snapshot.c | 13 +++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-)
For convenience, I'll probably squash this in (while the API requires both REDEFINE and REDEFINE_LIST flags, the virsh tooling can imply one from the other): diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index f6efadde2d..a58731c46e 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -131,7 +131,7 @@ static const vshCmdOptDef opts_snapshot_create[] = { VIRSH_COMMON_OPT_CURRENT(N_("with redefine, set current snapshot")), {.name = "redefine-list", .type = VSH_OT_BOOL, - .help = N_("with redefine, bulk define a set of snapshots"), + .help = N_("bulk define a set of snapshots, implies --redefine"), }, {.name = "no-metadata", .type = VSH_OT_BOOL, @@ -189,7 +189,8 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "live")) flags |= VIR_DOMAIN_SNAPSHOT_CREATE_LIVE; if (vshCommandOptBool(cmd, "redefine-list")) - flags |= VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE_LIST; + flags |= VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE | + VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE_LIST; if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) goto cleanup; -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org