...</pre>
<pre>
-<cpu mode='host-passthrough'>
+<cpu mode='host-passthrough' migratable='off'>
<cache mode='passthrough'/>
<feature policy='disable' name='lahf_lm'/>
...</pre>
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
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)
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;
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;
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 */