mirror of https://gitee.com/openkylin/libvirt.git
testDomainSnapshotCreateXML: Extract snapshot redefinition code
The test driver code was copied from qemu but wasn't refactored recently. Split out the redefinition code similarly to what qemu driver did. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
bec2a922bd
commit
4584a451e6
|
@ -8739,6 +8739,33 @@ testDomainSnapshotAlignDisks(virDomainObj *vm,
|
|||
return virDomainSnapshotAlignDisks(def, NULL, align_location, true);
|
||||
}
|
||||
|
||||
|
||||
static virDomainSnapshotPtr
|
||||
testDomainSnapshotRedefine(virDomainObj *vm,
|
||||
virDomainPtr domain,
|
||||
virDomainSnapshotDef *snapdeftmp,
|
||||
virDomainMomentObj **snapout,
|
||||
virDomainXMLOption *xmlopt,
|
||||
unsigned int flags)
|
||||
{
|
||||
virDomainMomentObj *snap = NULL;
|
||||
g_autoptr(virDomainSnapshotDef) snapdef = virObjectRef(snapdeftmp);
|
||||
|
||||
if (virDomainSnapshotRedefinePrep(vm, &snapdef, &snap, xmlopt, flags) < 0)
|
||||
return NULL;
|
||||
|
||||
if (!snap) {
|
||||
if (!(snap = virDomainSnapshotAssignDef(vm->snapshots, snapdef)))
|
||||
return NULL;
|
||||
snapdef = NULL;
|
||||
}
|
||||
|
||||
*snapout = snap;
|
||||
|
||||
return virGetDomainSnapshot(domain, snap->def->name);
|
||||
}
|
||||
|
||||
|
||||
static virDomainSnapshotPtr
|
||||
testDomainSnapshotCreateXML(virDomainPtr domain,
|
||||
const char *xmlDesc,
|
||||
|
@ -8805,11 +8832,11 @@ testDomainSnapshotCreateXML(virDomainPtr domain,
|
|||
goto cleanup;
|
||||
|
||||
if (redefine) {
|
||||
if (virDomainSnapshotRedefinePrep(vm, &def, &snap,
|
||||
privconn->xmlopt,
|
||||
flags) < 0)
|
||||
snapshot = testDomainSnapshotRedefine(vm, domain, def, &snap,
|
||||
privconn->xmlopt, flags);
|
||||
goto cleanup;
|
||||
} else {
|
||||
}
|
||||
|
||||
if (!(def->parent.dom = virDomainDefCopy(vm->def,
|
||||
privconn->xmlopt,
|
||||
NULL,
|
||||
|
@ -8818,15 +8845,11 @@ testDomainSnapshotCreateXML(virDomainPtr domain,
|
|||
|
||||
if (testDomainSnapshotAlignDisks(vm, def, flags) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!snap) {
|
||||
if (!(snap = virDomainSnapshotAssignDef(vm->snapshots, def)))
|
||||
goto cleanup;
|
||||
def = NULL;
|
||||
}
|
||||
|
||||
if (!redefine) {
|
||||
snap->def->parent_name = g_strdup(virDomainSnapshotGetCurrentName(vm->snapshots));
|
||||
|
||||
if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_HALT) &&
|
||||
|
@ -8836,7 +8859,6 @@ testDomainSnapshotCreateXML(virDomainPtr domain,
|
|||
event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
|
||||
VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT);
|
||||
}
|
||||
}
|
||||
|
||||
snapshot = virGetDomainSnapshot(domain, snap->def->name);
|
||||
cleanup:
|
||||
|
|
Loading…
Reference in New Issue