}
+/**
+ * virCPUGetCheckMode:
+ * @arch: CPU architecture
+ * @cpu: CPU definition
+ * @compat: where to store compatible partial checking is required
+ *
+ * Gets the mode required for "partial" check of the CPU definition @cpu
+ * based on the CPU model used. On success @compat will be set to true if
+ * a compatible check needs to be done, false otherwise.
+ *
+ * Returns 0 on success, -1 otherwise.
+ */
+int
+virCPUGetCheckMode(virArch arch,
+ const virCPUDef *cpu,
+ bool *compat)
+{
+ struct cpuArchDriver *driver;
+
+ if (!(driver = cpuGetSubDriver(arch)))
+ return -1;
+
+ if (!driver->getCheckMode) {
+ *compat = true;
+ return 0;
+ }
+
+ return driver->getCheckMode(cpu->model, compat);
+}
+
+
/**
* virCPUArchIsSupported:
*
typedef virCPUData *
(*virCPUArchDataGetHost)(void);
+typedef int
+(*virCPUArchGetCheckMode)(const char *modelName,
+ bool *compat);
+
struct cpuArchDriver {
const char *name;
const virArch *arch;
virCPUArchDataAddFeature dataAddFeature;
virCPUArchDataIsIdentical dataIsIdentical;
virCPUArchDataGetHost dataGetHost;
+ virCPUArchGetCheckMode getCheckMode;
};
virCPUData*
virCPUDataGetHost(void);
+int
+virCPUGetCheckMode(virArch arch,
+ const virCPUDef *cpu,
+ bool *compat);
+
bool
virCPUArchIsSupported(virArch arch);
}
+/**
+ * virCPUx86GetCheckMode:
+ * @modelName: CPU model
+ * @compat: where to store compatible partial checking is required
+ *
+ * Gets the mode required for "partial" check of a CPU definition which uses
+ * the @modelName. On success @compat will be set to true if a compatible
+ * check needs to be done, false otherwise.
+ *
+ * Returns 0 on success, -1 otherwise.
+ */
+static int
+virCPUx86GetCheckMode(const char *modelName,
+ bool *compat)
+{
+ virCPUx86Map *map;
+ virCPUx86Model *model;
+
+ if (!(map = virCPUx86GetMap()))
+ return -1;
+
+ if (!(model = x86ModelFind(map, modelName))) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("unknown CPU model %1$s"), modelName);
+ return -1;
+ }
+
+ *compat = model->compatCheck;
+ return 0;
+}
+
+
struct cpuArchDriver cpuDriverX86 = {
.name = "x86",
.arch = archs,
(defined(__linux__) || defined(__FreeBSD__))
.dataGetHost = virCPUx86DataGetHost,
#endif
+ .getCheckMode = virCPUx86GetCheckMode,
};
virCPUDataParse;
virCPUDataParseNode;
virCPUExpandFeatures;
+virCPUGetCheckMode;
virCPUGetHost;
virCPUGetHostIsSupported;
virCPUGetModels;