提交 4a8bd260 编写于 作者: M Michal Privoznik

qemuDomainUndefineFlags: Grab QEMU_JOB_MODIFY

This API is definitely modifying state of @vm. Therefore it
should grab a job.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 9115dcd8
...@@ -7325,10 +7325,13 @@ qemuDomainUndefineFlags(virDomainPtr dom, ...@@ -7325,10 +7325,13 @@ qemuDomainUndefineFlags(virDomainPtr dom,
if (virDomainUndefineFlagsEnsureACL(dom->conn, vm->def) < 0) if (virDomainUndefineFlagsEnsureACL(dom->conn, vm->def) < 0)
goto cleanup; goto cleanup;
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
if (!vm->persistent) { if (!vm->persistent) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot undefine transient domain")); "%s", _("cannot undefine transient domain"));
goto cleanup; goto endjob;
} }
if (!virDomainObjIsActive(vm) && if (!virDomainObjIsActive(vm) &&
...@@ -7338,15 +7341,15 @@ qemuDomainUndefineFlags(virDomainPtr dom, ...@@ -7338,15 +7341,15 @@ qemuDomainUndefineFlags(virDomainPtr dom,
_("cannot delete inactive domain with %d " _("cannot delete inactive domain with %d "
"snapshots"), "snapshots"),
nsnapshots); nsnapshots);
goto cleanup; goto endjob;
} }
if (qemuDomainSnapshotDiscardAllMetadata(driver, vm) < 0) if (qemuDomainSnapshotDiscardAllMetadata(driver, vm) < 0)
goto cleanup; goto endjob;
} }
name = qemuDomainManagedSavePath(driver, vm); name = qemuDomainManagedSavePath(driver, vm);
if (name == NULL) if (name == NULL)
goto cleanup; goto endjob;
if (virFileExists(name)) { if (virFileExists(name)) {
if (flags & VIR_DOMAIN_UNDEFINE_MANAGED_SAVE) { if (flags & VIR_DOMAIN_UNDEFINE_MANAGED_SAVE) {
...@@ -7354,13 +7357,13 @@ qemuDomainUndefineFlags(virDomainPtr dom, ...@@ -7354,13 +7357,13 @@ qemuDomainUndefineFlags(virDomainPtr dom,
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to remove domain managed " _("Failed to remove domain managed "
"save image")); "save image"));
goto cleanup; goto endjob;
} }
} else { } else {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("Refusing to undefine while domain managed " _("Refusing to undefine while domain managed "
"save image exists")); "save image exists"));
goto cleanup; goto endjob;
} }
} }
...@@ -7372,17 +7375,17 @@ qemuDomainUndefineFlags(virDomainPtr dom, ...@@ -7372,17 +7375,17 @@ qemuDomainUndefineFlags(virDomainPtr dom,
virReportSystemError(errno, virReportSystemError(errno,
_("failed to remove nvram: %s"), _("failed to remove nvram: %s"),
vm->def->os.loader->nvram); vm->def->os.loader->nvram);
goto cleanup; goto endjob;
} }
} else if (!(flags & VIR_DOMAIN_UNDEFINE_KEEP_NVRAM)) { } else if (!(flags & VIR_DOMAIN_UNDEFINE_KEEP_NVRAM)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot delete inactive domain with nvram")); _("cannot delete inactive domain with nvram"));
goto cleanup; goto endjob;
} }
} }
if (virDomainDeleteConfig(cfg->configDir, cfg->autostartDir, vm) < 0) if (virDomainDeleteConfig(cfg->configDir, cfg->autostartDir, vm) < 0)
goto cleanup; goto endjob;
event = virDomainEventLifecycleNewFromObj(vm, event = virDomainEventLifecycleNewFromObj(vm,
VIR_DOMAIN_EVENT_UNDEFINED, VIR_DOMAIN_EVENT_UNDEFINED,
...@@ -7396,9 +7399,11 @@ qemuDomainUndefineFlags(virDomainPtr dom, ...@@ -7396,9 +7399,11 @@ qemuDomainUndefineFlags(virDomainPtr dom,
*/ */
vm->persistent = 0; vm->persistent = 0;
if (!virDomainObjIsActive(vm)) if (!virDomainObjIsActive(vm))
qemuDomainRemoveInactiveJob(driver, vm); qemuDomainRemoveInactive(driver, vm);
ret = 0; ret = 0;
endjob:
qemuDomainObjEndJob(driver, vm);
cleanup: cleanup:
VIR_FREE(name); VIR_FREE(name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册