Whenever there is a guest CPU configured in domain XML, we will call
some CPU driver APIs to validate the CPU definition and check its
compatibility with the hypervisor. Thus domains with guest CPU
specification can only be started if the guest architecture is supported
by the CPU driver. But we would add a default CPU to any domain as long
as QEMU reports it causing failures to start any domain on affected
architectures.
https://bugzilla.redhat.com/show_bug.cgi?id=
1805755
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
return driver->dataAddFeature(cpuData, name);
}
+
+
+/**
+ * virCPUArchIsSupported:
+ *
+ * @arch: CPU architecture
+ *
+ * Returns true if the architecture is supported by any CPU driver.
+ */
+bool
+virCPUArchIsSupported(virArch arch)
+{
+ size_t i;
+ size_t j;
+
+ for (i = 0; i < G_N_ELEMENTS(drivers); i++) {
+ for (j = 0; j < drivers[i]->narch; j++) {
+ if (arch == drivers[i]->arch[j])
+ return true;
+ }
+ }
+
+ return false;
+}
virCPUDataAddFeature(virCPUDataPtr cpuData,
const char *name);
+bool
+virCPUArchIsSupported(virArch arch);
+
/* virCPUDataFormat and virCPUDataParse are implemented for unit tests only and
* have no real-life usage
*/
# cpu/cpu.h
cpuDecode;
cpuEncode;
+virCPUArchIsSupported;
virCPUBaseline;
virCPUCheckFeature;
virCPUCompare;
def->cpu->model))
return 0;
+ if (!virCPUArchIsSupported(def->os.arch))
+ return 0;
+
/* Default CPU model info from QEMU is usable for TCG only except for
* x86, s390, and ppc64. */
if (!ARCH_IS_X86(def->os.arch) &&