提交 803497a8 编写于 作者: J Jiri Denemark

qemu: Introduce virQEMUCapsIsCPUModeSupported

Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
上级 21dead63
...@@ -2371,6 +2371,32 @@ virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps) ...@@ -2371,6 +2371,32 @@ virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps)
} }
bool
virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
virCapsPtr caps,
virDomainVirtType type,
virCPUMode mode)
{
switch (mode) {
case VIR_CPU_MODE_HOST_PASSTHROUGH:
return type == VIR_DOMAIN_VIRT_KVM &&
virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch);
case VIR_CPU_MODE_HOST_MODEL:
return !!qemuCaps->hostCPUModel;
case VIR_CPU_MODE_CUSTOM:
return qemuCaps->cpuDefinitions &&
qemuCaps->cpuDefinitions->nmodels > 0;
case VIR_CPU_MODE_LAST:
break;
}
return false;
}
int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps, int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
size_t *nmachines, size_t *nmachines,
virCapsGuestMachinePtr **machines) virCapsGuestMachinePtr **machines)
...@@ -4358,22 +4384,26 @@ virQEMUCapsFillDomainCPUCaps(virCapsPtr caps, ...@@ -4358,22 +4384,26 @@ virQEMUCapsFillDomainCPUCaps(virCapsPtr caps,
virQEMUCapsPtr qemuCaps, virQEMUCapsPtr qemuCaps,
virDomainCapsPtr domCaps) virDomainCapsPtr domCaps)
{ {
virDomainCapsCPUModelsPtr filtered = NULL; if (virQEMUCapsIsCPUModeSupported(qemuCaps, caps, domCaps->virttype,
char **models = NULL; VIR_CPU_MODE_HOST_PASSTHROUGH))
if (domCaps->virttype == VIR_DOMAIN_VIRT_KVM &&
virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch))
domCaps->cpu.hostPassthrough = true; domCaps->cpu.hostPassthrough = true;
domCaps->cpu.hostModel = virCPUDefCopy(qemuCaps->hostCPUModel); if (virQEMUCapsIsCPUModeSupported(qemuCaps, caps, domCaps->virttype,
VIR_CPU_MODE_HOST_MODEL))
domCaps->cpu.hostModel = virCPUDefCopy(qemuCaps->hostCPUModel);
if (virQEMUCapsIsCPUModeSupported(qemuCaps, caps, domCaps->virttype,
VIR_CPU_MODE_CUSTOM)) {
virDomainCapsCPUModelsPtr filtered = NULL;
char **models = NULL;
if (qemuCaps->cpuDefinitions && if (cpuGetModels(domCaps->arch, &models) >= 0) {
cpuGetModels(domCaps->arch, &models) >= 0) { filtered = virDomainCapsCPUModelsFilter(qemuCaps->cpuDefinitions,
filtered = virDomainCapsCPUModelsFilter(qemuCaps->cpuDefinitions, (const char **) models);
(const char **) models); virStringFreeList(models);
virStringFreeList(models); }
domCaps->cpu.custom = filtered;
} }
domCaps->cpu.custom = filtered;
return 0; return 0;
} }
......
...@@ -430,6 +430,10 @@ int virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps, ...@@ -430,6 +430,10 @@ int virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps,
char ***names, char ***names,
size_t *count); size_t *count);
virCPUDefPtr virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps); virCPUDefPtr virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps);
bool virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
virCapsPtr caps,
virDomainVirtType type,
virCPUMode mode);
const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps, const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
const char *name); const char *name);
int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps, int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册