提交 048e5c64 编写于 作者: N Nikolay Shirokovskiy 提交者: Michal Privoznik

qemu: add VIR_DOMAIN_UNDEFINE_KEEP_NVRAM support

Signed-off-by: NNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
上级 bdf83c01
...@@ -7327,7 +7327,15 @@ qemuDomainUndefineFlags(virDomainPtr dom, ...@@ -7327,7 +7327,15 @@ qemuDomainUndefineFlags(virDomainPtr dom,
virCheckFlags(VIR_DOMAIN_UNDEFINE_MANAGED_SAVE | virCheckFlags(VIR_DOMAIN_UNDEFINE_MANAGED_SAVE |
VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA | VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA |
VIR_DOMAIN_UNDEFINE_NVRAM, -1); VIR_DOMAIN_UNDEFINE_NVRAM |
VIR_DOMAIN_UNDEFINE_KEEP_NVRAM, -1);
if ((flags & VIR_DOMAIN_UNDEFINE_NVRAM) &&
(flags & VIR_DOMAIN_UNDEFINE_KEEP_NVRAM)) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot both keep and delete nvram"));
return -1;
}
if (!(vm = qemuDomObjFromDomain(dom))) if (!(vm = qemuDomObjFromDomain(dom)))
return -1; return -1;
...@@ -7379,18 +7387,18 @@ qemuDomainUndefineFlags(virDomainPtr dom, ...@@ -7379,18 +7387,18 @@ qemuDomainUndefineFlags(virDomainPtr dom,
if (!virDomainObjIsActive(vm) && if (!virDomainObjIsActive(vm) &&
vm->def->os.loader && vm->def->os.loader->nvram && vm->def->os.loader && vm->def->os.loader->nvram &&
virFileExists(vm->def->os.loader->nvram)) { virFileExists(vm->def->os.loader->nvram)) {
if (!(flags & VIR_DOMAIN_UNDEFINE_NVRAM)) { if ((flags & VIR_DOMAIN_UNDEFINE_NVRAM)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot delete inactive domain with nvram"));
goto cleanup;
}
if (unlink(vm->def->os.loader->nvram) < 0) { if (unlink(vm->def->os.loader->nvram) < 0) {
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 cleanup;
} }
} else if (!(flags & VIR_DOMAIN_UNDEFINE_KEEP_NVRAM)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot delete inactive domain with nvram"));
goto cleanup;
}
} }
if (virDomainDeleteConfig(cfg->configDir, cfg->autostartDir, vm) < 0) if (virDomainDeleteConfig(cfg->configDir, cfg->autostartDir, vm) < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册