提交 524f5f00 编写于 作者: J Jiri Denemark

conf: Introduce migratable attribute for the <cpu> element

The attribute is only allowed for host-passthrough CPUs and it can be
used to request only migratable or all supported features to be enabled
in the virtual CPU.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 f48bdbdf
......@@ -1490,7 +1490,7 @@
...</pre>
<pre>
&lt;cpu mode='host-passthrough'&gt;
&lt;cpu mode='host-passthrough' migratable='off'&gt;
&lt;cache mode='passthrough'/&gt;
&lt;feature policy='disable' name='lahf_lm'/&gt;
...</pre>
......@@ -1639,7 +1639,17 @@
using host-passthrough is dangerous if the source and destination hosts
are not identical in both hardware, QEMU version, microcode version
and configuration. If such a migration is attempted then the guest may
hang or crash upon resuming execution on the destination host.</dd>
hang or crash upon resuming execution on the destination host.
Depending on hypervisor version the virtual CPU may or may not
contain features which may block migration even to an identical host.
<span class="since">Since 6.5.0</span> optional
<code>migratable</code> attribute may be used to explicitly request
such features to be removed from (<code>on</code>) or kept in
(<code>off</code>) the virtual CPU. This attribute does not make
migration to another host safer: even with
<code>migratable='on'</code> migration will be dangerous unless both
hosts are identical as described above.
</dd>
</dl>
Both <code>host-model</code> and <code>host-passthrough</code> modes
......
......@@ -5469,6 +5469,11 @@
<optional>
<ref name="cpuCheck"/>
</optional>
<optional>
<attribute name="migratable">
<ref name="virOnOff"/>
</attribute>
</optional>
<interleave>
<optional>
<ref name="cpuModel"/>
......
......@@ -243,6 +243,7 @@ virCPUDefCopyWithoutModel(const virCPUDef *cpu)
copy->cores = cpu->cores;
copy->threads = cpu->threads;
copy->arch = cpu->arch;
copy->migratable = cpu->migratable;
if (cpu->cache) {
if (VIR_ALLOC(copy->cache) < 0)
......@@ -333,6 +334,7 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
g_autofree char *fallback = NULL;
g_autofree char *vendor_id = NULL;
g_autofree char *tscScaling = NULL;
g_autofree char *migratable = NULL;
virHostCPUTscInfoPtr tsc = NULL;
*cpu = NULL;
......@@ -386,6 +388,26 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
def->mode = VIR_CPU_MODE_CUSTOM;
}
if ((migratable = virXMLPropString(ctxt->node, "migratable"))) {
int val;
if (def->mode != VIR_CPU_MODE_HOST_PASSTHROUGH) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Attribute migratable is only allowed for "
"host-passthrough CPU"));
return -1;
}
if ((val = virTristateSwitchTypeFromString(migratable)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Invalid value in migratable attribute: '%s'"),
migratable);
return -1;
}
def->migratable = val;
}
if (def->type == VIR_CPU_TYPE_GUEST) {
g_autofree char *match = virXMLPropString(ctxt->node, "match");
g_autofree char *check = NULL;
......@@ -698,6 +720,11 @@ virCPUDefFormatBufFull(virBufferPtr buf,
virBufferAsprintf(&attributeBuf, " check='%s'",
virCPUCheckTypeToString(def->check));
}
if (def->mode == VIR_CPU_MODE_HOST_PASSTHROUGH && def->migratable) {
virBufferAsprintf(&attributeBuf, " migratable='%s'",
virTristateSwitchTypeToString(def->migratable));
}
}
/* Format children */
......
......@@ -141,6 +141,7 @@ struct _virCPUDef {
virCPUFeatureDefPtr features;
virCPUCacheDefPtr cache;
virHostCPUTscInfoPtr tsc;
virTristateSwitch migratable; /* for host-passthrough mode */
};
virCPUDefPtr virCPUDefNew(void);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册