...
<cpu>
<mode name='host-passthrough' supported='yes'/>
- <mode name='host-model' supported='yes'/>
+ <mode name='host-model' supported='yes'>
+ <model fallback='allow'>Broadwell</model>
+ <vendor>Intel</vendor>
+ <feature policy='disable' name='aes'/>
+ <feature policy='require' name='vmx'/>
+ </mode>
<mode name='custom' supported='yes'>
<model usable='no'>Broadwell</model>
<model usable='yes'>Broadwell-noTSX</model>
<dd>No mode specific details are provided.</dd>
<dt><code>host-model</code></dt>
- <dd>No mode specific details are provided yet.</dd>
+ <dd>
+ If <code>host-model</code> is supported by the hypervisor, the
+ <code>mode</code> describes the guest CPU which will be used when
+ starting a domain with <code>host-model</code> CPU. The hypervisor
+ specifics (such as unsupported CPU models or features, machine type,
+ etc.) may be accounted for in this guest CPU specification and thus
+ the CPU can be different from the one shown in host capabilities XML.
+ This is indicated by the <code>fallback</code> attribute of the
+ <code>model</code> sub element: <code>allow</code> means not all
+ specifics were accounted for and thus the CPU a guest will see may
+ be different; <code>forbid</code> indicates that the CPU a guest will
+ see should match this CPU definition.
+ </dd>
<dt><code>custom</code></dt>
<dd>
<!-- A Relax NG schema for the libvirt domain capabilities XML format -->
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<include href='basictypes.rng'/>
+ <include href='cputypes.rng'/>
<start>
<ref name='domainCapabilities'/>
</start>
<value>host-model</value>
</attribute>
<ref name='supported'/>
+ <optional>
+ <ref name="cpuModel"/>
+ <optional>
+ <ref name="cpuVendor"/>
+ </optional>
+ <zeroOrMore>
+ <ref name="cpuFeature"/>
+ </zeroOrMore>
+ </optional>
</element>
</define>
virCPUModeTypeToString(VIR_CPU_MODE_HOST_PASSTHROUGH),
cpu->hostPassthrough ? "yes" : "no");
- virBufferAsprintf(buf, "<mode name='%s' supported='%s'/>\n",
- virCPUModeTypeToString(VIR_CPU_MODE_HOST_MODEL),
- cpu->hostModel ? "yes" : "no");
+ virBufferAsprintf(buf, "<mode name='%s' ",
+ virCPUModeTypeToString(VIR_CPU_MODE_HOST_MODEL));
+ if (cpu->hostModel) {
+ virBufferAddLit(buf, "supported='yes'>\n");
+ virBufferAdjustIndent(buf, 2);
+
+ virCPUDefFormatBuf(buf, cpu->hostModel, false);
+
+ virBufferAdjustIndent(buf, -2);
+ virBufferAddLit(buf, "</mode>\n");
+ } else {
+ virBufferAddLit(buf, "supported='no'/>\n");
+ }
virBufferAsprintf(buf, "<mode name='%s' ",
virCPUModeTypeToString(VIR_CPU_MODE_CUSTOM));
typedef virDomainCapsCPU *virDomainCapsCPUPtr;
struct _virDomainCapsCPU {
bool hostPassthrough;
- bool hostModel;
+ virCPUDefPtr hostModel;
virDomainCapsCPUModelsPtr custom;
};
virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch))
domCaps->cpu.hostPassthrough = true;
- if (qemuCaps->cpuDefinitions && caps->host.cpu)
- domCaps->cpu.hostModel = virQEMUCapsGuestIsNative(caps->host.arch,
- qemuCaps->arch);
+ domCaps->cpu.hostModel = virCPUDefCopy(qemuCaps->hostCPUModel);
if (qemuCaps->cpuDefinitions &&
cpuGetModels(domCaps->arch, &models) >= 0) {
</os>
<cpu>
<mode name='host-passthrough' supported='yes'/>
- <mode name='host-model' supported='yes'/>
+ <mode name='host-model' supported='yes'>
+ <model>host</model>
+ <vendor>CPU Vendorrr</vendor>
+ </mode>
<mode name='custom' supported='yes'>
<model usable='unknown'>Model1</model>
<model usable='no'>Model2</model>
</os>
<cpu>
<mode name='host-passthrough' supported='yes'/>
- <mode name='host-model' supported='yes'/>
+ <mode name='host-model' supported='yes'>
+ <model fallback='allow'>Broadwell</model>
+ </mode>
<mode name='custom' supported='yes'>
<model usable='unknown'>Opteron_G5</model>
<model usable='unknown'>Opteron_G4</model>
</os>
<cpu>
<mode name='host-passthrough' supported='yes'/>
- <mode name='host-model' supported='yes'/>
+ <mode name='host-model' supported='no'/>
<mode name='custom' supported='yes'>
<model usable='unknown'>pxa262</model>
<model usable='unknown'>pxa270-a0</model>
</os>
<cpu>
<mode name='host-passthrough' supported='yes'/>
- <mode name='host-model' supported='yes'/>
+ <mode name='host-model' supported='no'/>
<mode name='custom' supported='yes'>
<model usable='unknown'>pxa262</model>
<model usable='unknown'>pxa270-a0</model>
</os>
<cpu>
<mode name='host-passthrough' supported='yes'/>
- <mode name='host-model' supported='yes'/>
+ <mode name='host-model' supported='no'/>
<mode name='custom' supported='yes'>
<model usable='unknown'>pxa262</model>
<model usable='unknown'>pxa270-a0</model>
</os>
<cpu>
<mode name='host-passthrough' supported='yes'/>
- <mode name='host-model' supported='yes'/>
+ <mode name='host-model' supported='yes'>
+ <model fallback='allow'>POWER8</model>
+ </mode>
<mode name='custom' supported='yes'>
<model usable='unknown'>POWER8</model>
<model usable='unknown'>POWER7</model>
</os>
<cpu>
<mode name='host-passthrough' supported='yes'/>
- <mode name='host-model' supported='yes'/>
+ <mode name='host-model' supported='yes'>
+ <model fallback='allow'>Broadwell</model>
+ </mode>
<mode name='custom' supported='yes'>
<model usable='unknown'>Opteron_G5</model>
<model usable='unknown'>Opteron_G4</model>
virDomainCapsDeviceGraphicsPtr graphics = &domCaps->graphics;
virDomainCapsDeviceVideoPtr video = &domCaps->video;
virDomainCapsDeviceHostdevPtr hostdev = &domCaps->hostdev;
- domCaps->maxvcpus = 255;
+ virCPUDef host = {
+ VIR_CPU_TYPE_HOST, 0, 0,
+ VIR_ARCH_X86_64, (char *) "host",
+ NULL, 0, (char *) "CPU Vendorrr",
+ 0, 0, 0, 0, 0, NULL,
+ };
+ domCaps->maxvcpus = 255;
os->supported = true;
loader->supported = true;
return -1;
cpu->hostPassthrough = true;
- cpu->hostModel = true;
+ cpu->hostModel = virCPUDefCopy(&host);
if (!(cpu->custom = virDomainCapsCPUModelsNew(3)) ||
virDomainCapsCPUModelsAdd(cpu->custom, "Model1", -1,
VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0 ||