"host" CPU model is supported by a special host-passthrough CPU mode and
users is not allowed to specify this model directly with custom mode.
Thus we should not advertise "host" CPU model in domain capabilities.
This worked well on architectures for which libvirt provides a list of
supported CPU models in cpu_map.xml (since "host" is not in the list).
But we need to explicitly filter "host" model out for all other
architectures.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/conf/domain_capabilities.c | 6 +++++-
src/conf/domain_capabilities.h | 3 ++-
src/qemu/qemu_capabilities.c | 4 +++-
tests/domaincapsschemadata/qemu_2.6.0-gicv2-virt.aarch64.xml | 1 -
tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml | 1 -
5 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index beedd70..5a45068 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -176,7 +176,8 @@ virDomainCapsCPUModelsCopy(virDomainCapsCPUModelsPtr old)
virDomainCapsCPUModelsPtr
virDomainCapsCPUModelsFilter(virDomainCapsCPUModelsPtr old,
- const char **models)
+ const char **models,
+ const char **blacklist)
{
virDomainCapsCPUModelsPtr cpuModels;
size_t i;
@@ -188,6 +189,9 @@ virDomainCapsCPUModelsFilter(virDomainCapsCPUModelsPtr old,
if (models && !virStringArrayHasString(models, old->models[i].name))
continue;
+ if (blacklist && virStringArrayHasString(blacklist,
old->models[i].name))
+ continue;
+
if (virDomainCapsCPUModelsAdd(cpuModels,
old->models[i].name, -1,
old->models[i].usable) < 0)
diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h
index 13a65e3..82183c4 100644
--- a/src/conf/domain_capabilities.h
+++ b/src/conf/domain_capabilities.h
@@ -167,7 +167,8 @@ virDomainCapsPtr virDomainCapsNew(const char *path,
virDomainCapsCPUModelsPtr virDomainCapsCPUModelsNew(size_t nmodels);
virDomainCapsCPUModelsPtr virDomainCapsCPUModelsCopy(virDomainCapsCPUModelsPtr old);
virDomainCapsCPUModelsPtr virDomainCapsCPUModelsFilter(virDomainCapsCPUModelsPtr old,
- const char **models);
+ const char **models,
+ const char **blacklist);
int virDomainCapsCPUModelsAddSteal(virDomainCapsCPUModelsPtr cpuModels,
char **name,
virDomainCapsCPUUsable usable);
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 422e50c..54253cb 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4948,6 +4948,7 @@ virQEMUCapsFillDomainCPUCaps(virCapsPtr caps,
VIR_CPU_MODE_CUSTOM)) {
virDomainCapsCPUModelsPtr filtered = NULL;
char **models = NULL;
+ const char *blacklist[] = { "host", NULL };
if (virCPUGetModels(domCaps->arch, &models) >= 0) {
virDomainCapsCPUModelsPtr cpus;
@@ -4958,7 +4959,8 @@ virQEMUCapsFillDomainCPUCaps(virCapsPtr caps,
cpus = qemuCaps->tcgCPUModels;
filtered = virDomainCapsCPUModelsFilter(cpus,
- (const char **) models);
+ (const char **) models,
+ blacklist);
virStringFreeList(models);
}
domCaps->cpu.custom = filtered;
diff --git a/tests/domaincapsschemadata/qemu_2.6.0-gicv2-virt.aarch64.xml
b/tests/domaincapsschemadata/qemu_2.6.0-gicv2-virt.aarch64.xml
index 0b5a437..76aee83 100644
--- a/tests/domaincapsschemadata/qemu_2.6.0-gicv2-virt.aarch64.xml
+++ b/tests/domaincapsschemadata/qemu_2.6.0-gicv2-virt.aarch64.xml
@@ -38,7 +38,6 @@
<model usable='unknown'>sa1110</model>
<model usable='unknown'>arm1176</model>
<model usable='unknown'>cortex-a53</model>
- <model usable='unknown'>host</model>
<model usable='unknown'>sa1100</model>
<model usable='unknown'>pxa270-c5</model>
<model usable='unknown'>cortex-a9</model>
diff --git a/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml
b/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml
index 201f9e0..ca511f4 100644
--- a/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml
+++ b/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml
@@ -38,7 +38,6 @@
<model usable='unknown'>sa1110</model>
<model usable='unknown'>arm1176</model>
<model usable='unknown'>cortex-a53</model>
- <model usable='unknown'>host</model>
<model usable='unknown'>sa1100</model>
<model usable='unknown'>pxa270-c5</model>
<model usable='unknown'>cortex-a9</model>
--
2.10.2