cannot undefine domain with nvram
参考:https://blog.csdn.net/tiantao2012/article/details/105440599
通过virsh 删除虚拟机时报错,提示cannot undefine domain with nvram,解决方法是加上--nvram
分析如下:
报错的函数如下:原来是因为加了VIR_DOMAIN_UNDEFINE_KEEP_NVRAM
qemuDomainUndefineFlags(virDomainPtr dom,
unsigned int flags)
{
} else if (!(flags & VIR_DOMAIN_UNDEFINE_KEEP_NVRAM)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot undefine domain with nvram"));
goto endjob;
}
}
那在哪里加的这个flag呢?从下面的函数中看,很可能是从配置文件汇总
static bool
cmdUndefine(vshControl *ctl, const vshCmd *cmd)
{
bool nvram = vshCommandOptBool(cmd, "nvram");
bool keep_nvram = vshCommandOptBool(cmd, "keep-nvram");
if (nvram)
flags |= VIR_DOMAIN_UNDEFINE_NVRAM;
}
通过dump 配置文件,发现真的在配置文件中有添加
[root@k8s-node2 ~]# virsh list
Id Name State
----------------------------------------------------
25 debian6.0 running
[root@k8s-node2 ~]# virsh dumpxml 25 | grep nvram
所以解决方案就是添加--nvram或者删除配置文件中的这行