qemu_snapshot: revert: refactor cleanup section

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Pavel Hrdina 2021-12-01 13:53:36 +01:00
parent 76af9ef656
commit 890a33306a
1 changed files with 12 additions and 8 deletions

View File

@ -2256,14 +2256,18 @@ qemuSnapshotRevert(virDomainObj *vm,
ret = -1;
}
}
if (ret == 0 && defined && vm->persistent &&
!(ret = virDomainDefSave(vm->newDef ? vm->newDef : vm->def,
driver->xmlopt, cfg->configDir))) {
detail = VIR_DOMAIN_EVENT_DEFINED_FROM_SNAPSHOT;
virObjectEventStateQueue(driver->domainEventState,
virDomainEventLifecycleNewFromObj(vm,
VIR_DOMAIN_EVENT_DEFINED,
detail));
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;