mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
Show host model in domain capabilities
The domain capabilities XML is capable of showing whether each guest CPU mode is supported or not with a possibility to provide additional details. This patch enhances host-model capability to advertise the exact CPU model which will be used as a host-model: <cpu> ... <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> ... </cpu> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
10d0e6e9c8
commit
14319c81a0
@ -154,7 +154,12 @@
|
|||||||
...
|
...
|
||||||
<cpu>
|
<cpu>
|
||||||
<mode name='host-passthrough' supported='yes'/>
|
<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'>
|
<mode name='custom' supported='yes'>
|
||||||
<model usable='no'>Broadwell</model>
|
<model usable='no'>Broadwell</model>
|
||||||
<model usable='yes'>Broadwell-noTSX</model>
|
<model usable='yes'>Broadwell-noTSX</model>
|
||||||
@ -177,7 +182,19 @@
|
|||||||
<dd>No mode specific details are provided.</dd>
|
<dd>No mode specific details are provided.</dd>
|
||||||
|
|
||||||
<dt><code>host-model</code></dt>
|
<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>
|
<dt><code>custom</code></dt>
|
||||||
<dd>
|
<dd>
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<!-- A Relax NG schema for the libvirt domain capabilities XML format -->
|
<!-- 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">
|
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
||||||
<include href='basictypes.rng'/>
|
<include href='basictypes.rng'/>
|
||||||
|
<include href='cputypes.rng'/>
|
||||||
<start>
|
<start>
|
||||||
<ref name='domainCapabilities'/>
|
<ref name='domainCapabilities'/>
|
||||||
</start>
|
</start>
|
||||||
@ -94,6 +95,15 @@
|
|||||||
<value>host-model</value>
|
<value>host-model</value>
|
||||||
</attribute>
|
</attribute>
|
||||||
<ref name='supported'/>
|
<ref name='supported'/>
|
||||||
|
<optional>
|
||||||
|
<ref name="cpuModel"/>
|
||||||
|
<optional>
|
||||||
|
<ref name="cpuVendor"/>
|
||||||
|
</optional>
|
||||||
|
<zeroOrMore>
|
||||||
|
<ref name="cpuFeature"/>
|
||||||
|
</zeroOrMore>
|
||||||
|
</optional>
|
||||||
</element>
|
</element>
|
||||||
</define>
|
</define>
|
||||||
|
|
||||||
|
@ -402,9 +402,19 @@ virDomainCapsCPUFormat(virBufferPtr buf,
|
|||||||
virCPUModeTypeToString(VIR_CPU_MODE_HOST_PASSTHROUGH),
|
virCPUModeTypeToString(VIR_CPU_MODE_HOST_PASSTHROUGH),
|
||||||
cpu->hostPassthrough ? "yes" : "no");
|
cpu->hostPassthrough ? "yes" : "no");
|
||||||
|
|
||||||
virBufferAsprintf(buf, "<mode name='%s' supported='%s'/>\n",
|
virBufferAsprintf(buf, "<mode name='%s' ",
|
||||||
virCPUModeTypeToString(VIR_CPU_MODE_HOST_MODEL),
|
virCPUModeTypeToString(VIR_CPU_MODE_HOST_MODEL));
|
||||||
cpu->hostModel ? "yes" : "no");
|
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' ",
|
virBufferAsprintf(buf, "<mode name='%s' ",
|
||||||
virCPUModeTypeToString(VIR_CPU_MODE_CUSTOM));
|
virCPUModeTypeToString(VIR_CPU_MODE_CUSTOM));
|
||||||
|
@ -132,7 +132,7 @@ typedef struct _virDomainCapsCPU virDomainCapsCPU;
|
|||||||
typedef virDomainCapsCPU *virDomainCapsCPUPtr;
|
typedef virDomainCapsCPU *virDomainCapsCPUPtr;
|
||||||
struct _virDomainCapsCPU {
|
struct _virDomainCapsCPU {
|
||||||
bool hostPassthrough;
|
bool hostPassthrough;
|
||||||
bool hostModel;
|
virCPUDefPtr hostModel;
|
||||||
virDomainCapsCPUModelsPtr custom;
|
virDomainCapsCPUModelsPtr custom;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4358,9 +4358,7 @@ virQEMUCapsFillDomainCPUCaps(virCapsPtr caps,
|
|||||||
virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch))
|
virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch))
|
||||||
domCaps->cpu.hostPassthrough = true;
|
domCaps->cpu.hostPassthrough = true;
|
||||||
|
|
||||||
if (qemuCaps->cpuDefinitions && caps->host.cpu)
|
domCaps->cpu.hostModel = virCPUDefCopy(qemuCaps->hostCPUModel);
|
||||||
domCaps->cpu.hostModel = virQEMUCapsGuestIsNative(caps->host.arch,
|
|
||||||
qemuCaps->arch);
|
|
||||||
|
|
||||||
if (qemuCaps->cpuDefinitions &&
|
if (qemuCaps->cpuDefinitions &&
|
||||||
cpuGetModels(domCaps->arch, &models) >= 0) {
|
cpuGetModels(domCaps->arch, &models) >= 0) {
|
||||||
|
@ -21,7 +21,10 @@
|
|||||||
</os>
|
</os>
|
||||||
<cpu>
|
<cpu>
|
||||||
<mode name='host-passthrough' supported='yes'/>
|
<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'>
|
<mode name='custom' supported='yes'>
|
||||||
<model usable='unknown'>Model1</model>
|
<model usable='unknown'>Model1</model>
|
||||||
<model usable='no'>Model2</model>
|
<model usable='no'>Model2</model>
|
||||||
|
@ -20,7 +20,9 @@
|
|||||||
</os>
|
</os>
|
||||||
<cpu>
|
<cpu>
|
||||||
<mode name='host-passthrough' supported='yes'/>
|
<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'>
|
<mode name='custom' supported='yes'>
|
||||||
<model usable='unknown'>Opteron_G5</model>
|
<model usable='unknown'>Opteron_G5</model>
|
||||||
<model usable='unknown'>Opteron_G4</model>
|
<model usable='unknown'>Opteron_G4</model>
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
</os>
|
</os>
|
||||||
<cpu>
|
<cpu>
|
||||||
<mode name='host-passthrough' supported='yes'/>
|
<mode name='host-passthrough' supported='yes'/>
|
||||||
<mode name='host-model' supported='yes'/>
|
<mode name='host-model' supported='no'/>
|
||||||
<mode name='custom' supported='yes'>
|
<mode name='custom' supported='yes'>
|
||||||
<model usable='unknown'>pxa262</model>
|
<model usable='unknown'>pxa262</model>
|
||||||
<model usable='unknown'>pxa270-a0</model>
|
<model usable='unknown'>pxa270-a0</model>
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
</os>
|
</os>
|
||||||
<cpu>
|
<cpu>
|
||||||
<mode name='host-passthrough' supported='yes'/>
|
<mode name='host-passthrough' supported='yes'/>
|
||||||
<mode name='host-model' supported='yes'/>
|
<mode name='host-model' supported='no'/>
|
||||||
<mode name='custom' supported='yes'>
|
<mode name='custom' supported='yes'>
|
||||||
<model usable='unknown'>pxa262</model>
|
<model usable='unknown'>pxa262</model>
|
||||||
<model usable='unknown'>pxa270-a0</model>
|
<model usable='unknown'>pxa270-a0</model>
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
</os>
|
</os>
|
||||||
<cpu>
|
<cpu>
|
||||||
<mode name='host-passthrough' supported='yes'/>
|
<mode name='host-passthrough' supported='yes'/>
|
||||||
<mode name='host-model' supported='yes'/>
|
<mode name='host-model' supported='no'/>
|
||||||
<mode name='custom' supported='yes'>
|
<mode name='custom' supported='yes'>
|
||||||
<model usable='unknown'>pxa262</model>
|
<model usable='unknown'>pxa262</model>
|
||||||
<model usable='unknown'>pxa270-a0</model>
|
<model usable='unknown'>pxa270-a0</model>
|
||||||
|
@ -20,7 +20,9 @@
|
|||||||
</os>
|
</os>
|
||||||
<cpu>
|
<cpu>
|
||||||
<mode name='host-passthrough' supported='yes'/>
|
<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'>
|
<mode name='custom' supported='yes'>
|
||||||
<model usable='unknown'>POWER8</model>
|
<model usable='unknown'>POWER8</model>
|
||||||
<model usable='unknown'>POWER7</model>
|
<model usable='unknown'>POWER7</model>
|
||||||
|
@ -20,7 +20,9 @@
|
|||||||
</os>
|
</os>
|
||||||
<cpu>
|
<cpu>
|
||||||
<mode name='host-passthrough' supported='yes'/>
|
<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'>
|
<mode name='custom' supported='yes'>
|
||||||
<model usable='unknown'>Opteron_G5</model>
|
<model usable='unknown'>Opteron_G5</model>
|
||||||
<model usable='unknown'>Opteron_G4</model>
|
<model usable='unknown'>Opteron_G4</model>
|
||||||
|
@ -65,8 +65,14 @@ fillAllCaps(virDomainCapsPtr domCaps)
|
|||||||
virDomainCapsDeviceGraphicsPtr graphics = &domCaps->graphics;
|
virDomainCapsDeviceGraphicsPtr graphics = &domCaps->graphics;
|
||||||
virDomainCapsDeviceVideoPtr video = &domCaps->video;
|
virDomainCapsDeviceVideoPtr video = &domCaps->video;
|
||||||
virDomainCapsDeviceHostdevPtr hostdev = &domCaps->hostdev;
|
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;
|
os->supported = true;
|
||||||
|
|
||||||
loader->supported = true;
|
loader->supported = true;
|
||||||
@ -79,7 +85,7 @@ fillAllCaps(virDomainCapsPtr domCaps)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
cpu->hostPassthrough = true;
|
cpu->hostPassthrough = true;
|
||||||
cpu->hostModel = true;
|
cpu->hostModel = virCPUDefCopy(&host);
|
||||||
if (!(cpu->custom = virDomainCapsCPUModelsNew(3)) ||
|
if (!(cpu->custom = virDomainCapsCPUModelsNew(3)) ||
|
||||||
virDomainCapsCPUModelsAdd(cpu->custom, "Model1", -1,
|
virDomainCapsCPUModelsAdd(cpu->custom, "Model1", -1,
|
||||||
VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0 ||
|
VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0 ||
|
||||||
|
Loading…
x
Reference in New Issue
Block a user