提交 af8e3992 编写于 作者: J Jiri Denemark

cpu_conf: Don't format empty model for host-model CPUs

Most likely for historical reasons our CPU def formatting code is
happily adding useless <model fallback='allow'/> for host-model CPUs. We
can just drop it.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 65fa7bba
...@@ -751,16 +751,12 @@ virCPUDefFormatBuf(virBufferPtr buf, ...@@ -751,16 +751,12 @@ virCPUDefFormatBuf(virBufferPtr buf,
{ {
size_t i; size_t i;
bool formatModel; bool formatModel;
bool formatFallback;
if (!def) if (!def)
return 0; return 0;
formatModel = (def->mode == VIR_CPU_MODE_CUSTOM || formatModel = (def->mode == VIR_CPU_MODE_CUSTOM ||
def->mode == VIR_CPU_MODE_HOST_MODEL); def->mode == VIR_CPU_MODE_HOST_MODEL);
formatFallback = (def->type == VIR_CPU_TYPE_GUEST &&
(def->mode == VIR_CPU_MODE_HOST_MODEL ||
(def->mode == VIR_CPU_MODE_CUSTOM && def->model)));
if (!def->model && def->mode == VIR_CPU_MODE_CUSTOM && def->nfeatures) { if (!def->model && def->mode == VIR_CPU_MODE_CUSTOM && def->nfeatures) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
...@@ -768,9 +764,10 @@ virCPUDefFormatBuf(virBufferPtr buf, ...@@ -768,9 +764,10 @@ virCPUDefFormatBuf(virBufferPtr buf,
return -1; return -1;
} }
if ((formatModel && def->model) || formatFallback) { if (formatModel && def->model) {
virBufferAddLit(buf, "<model"); virBufferAddLit(buf, "<model");
if (formatFallback) {
if (def->type == VIR_CPU_TYPE_GUEST) {
const char *fallback; const char *fallback;
fallback = virCPUFallbackTypeToString(def->fallback); fallback = virCPUFallbackTypeToString(def->fallback);
...@@ -784,11 +781,8 @@ virCPUDefFormatBuf(virBufferPtr buf, ...@@ -784,11 +781,8 @@ virCPUDefFormatBuf(virBufferPtr buf,
if (def->vendor_id) if (def->vendor_id)
virBufferEscapeString(buf, " vendor_id='%s'", def->vendor_id); virBufferEscapeString(buf, " vendor_id='%s'", def->vendor_id);
} }
if (formatModel && def->model) {
virBufferEscapeString(buf, ">%s</model>\n", def->model); virBufferEscapeString(buf, ">%s</model>\n", def->model);
} else {
virBufferAddLit(buf, "/>\n");
}
} }
if (formatModel && def->vendor) if (formatModel && def->vendor)
......
<cpu mode='host-model'> <cpu mode='host-model'/>
<model fallback='allow'/>
</cpu>
...@@ -8,9 +8,7 @@ ...@@ -8,9 +8,7 @@
<type arch='x86_64' machine='pc'>hvm</type> <type arch='x86_64' machine='pc'>hvm</type>
<boot dev='network'/> <boot dev='network'/>
</os> </os>
<cpu mode='host-model' check='partial'> <cpu mode='host-model' check='partial'/>
<model fallback='allow'/>
</cpu>
<clock offset='utc'/> <clock offset='utc'/>
<on_poweroff>destroy</on_poweroff> <on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot> <on_reboot>restart</on_reboot>
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
<boot dev='hd'/> <boot dev='hd'/>
</os> </os>
<cpu mode='host-model' check='partial'> <cpu mode='host-model' check='partial'>
<model fallback='allow'/>
<feature policy='require' name='abm'/> <feature policy='require' name='abm'/>
<feature policy='force' name='ds'/> <feature policy='force' name='ds'/>
<feature policy='disable' name='invtsc'/> <feature policy='disable' name='invtsc'/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册