mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 06:35:24 +00:00
qemu_snapshot: revert: move saving metadata to separate function
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
890a33306a
commit
815182a782
@ -1997,6 +1997,40 @@ qemuSnapshotRevertPrep(virDomainMomentObj *snap,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuSnapshotRevertWriteMetadata(virDomainObj *vm,
|
||||||
|
virDomainMomentObj *snap,
|
||||||
|
virQEMUDriver *driver,
|
||||||
|
virQEMUDriverConfig *cfg,
|
||||||
|
bool defined)
|
||||||
|
{
|
||||||
|
qemuSnapshotSetCurrent(vm, snap);
|
||||||
|
if (qemuDomainSnapshotWriteMetadata(vm, snap,
|
||||||
|
driver->xmlopt,
|
||||||
|
cfg->snapshotDir) < 0) {
|
||||||
|
virDomainSnapshotSetCurrent(vm->snapshots, NULL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defined && vm->persistent) {
|
||||||
|
int detail;
|
||||||
|
virObjectEvent *event = NULL;
|
||||||
|
virDomainDef *saveDef = vm->newDef ? vm->newDef : vm->def;
|
||||||
|
|
||||||
|
if (virDomainDefSave(saveDef, driver->xmlopt, cfg->configDir) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
detail = VIR_DOMAIN_EVENT_DEFINED_FROM_SNAPSHOT;
|
||||||
|
event = virDomainEventLifecycleNewFromObj(vm,
|
||||||
|
VIR_DOMAIN_EVENT_DEFINED,
|
||||||
|
detail);
|
||||||
|
virObjectEventStateQueue(driver->domainEventState, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* The domain is expected to be locked and inactive. */
|
/* The domain is expected to be locked and inactive. */
|
||||||
static int
|
static int
|
||||||
qemuSnapshotRevertInactive(virQEMUDriver *driver,
|
qemuSnapshotRevertInactive(virQEMUDriver *driver,
|
||||||
@ -2247,28 +2281,8 @@ qemuSnapshotRevert(virDomainObj *vm,
|
|||||||
endjob:
|
endjob:
|
||||||
qemuProcessEndJob(driver, vm);
|
qemuProcessEndJob(driver, vm);
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0)
|
||||||
qemuSnapshotSetCurrent(vm, snap);
|
ret = qemuSnapshotRevertWriteMetadata(vm, snap, driver, cfg, defined);
|
||||||
if (qemuDomainSnapshotWriteMetadata(vm, snap,
|
|
||||||
driver->xmlopt,
|
|
||||||
cfg->snapshotDir) < 0) {
|
|
||||||
virDomainSnapshotSetCurrent(vm->snapshots, NULL);
|
|
||||||
ret = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ret == 0 && defined && vm->persistent) {
|
|
||||||
virDomainDef *saveDef = vm->newDef ? vm->newDef : vm->def;
|
|
||||||
|
|
||||||
ret = virDomainDefSave(saveDef, driver->xmlopt, cfg->configDir);
|
|
||||||
|
|
||||||
if (ret == 0) {
|
|
||||||
detail = VIR_DOMAIN_EVENT_DEFINED_FROM_SNAPSHOT;
|
|
||||||
event = virDomainEventLifecycleNewFromObj(vm,
|
|
||||||
VIR_DOMAIN_EVENT_DEFINED,
|
|
||||||
detail);
|
|
||||||
virObjectEventStateQueue(driver->domainEventState, event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user