}
+/**
+ * virCPUCheckFeature:
+ *
+ * @arch: CPU architecture
+ * @cpu: CPU definition
+ * @feature: feature to be checked for
+ *
+ * Checks whether @feature is supported by the CPU described by @cpu.
+ *
+ * Returns 1 if the feature is supported, 0 if it's not supported, or
+ * -1 on error.
+ */
+int
+virCPUCheckFeature(virArch arch,
+ const virCPUDef *cpu,
+ const char *feature)
+{
+ struct cpuArchDriver *driver;
+
+ VIR_DEBUG("arch=%s, cpu=%p, feature=%s",
+ virArchToString(arch), cpu, feature);
+
+ if (!(driver = cpuGetSubDriver(arch)))
+ return -1;
+
+ if (!driver->checkFeature) {
+ virReportError(VIR_ERR_NO_SUPPORT,
+ _("cannot check guest CPU feature for %s architecture"),
+ virArchToString(arch));
+ return -1;
+ }
+
+ return driver->checkFeature(cpu, feature);
+}
+
+
/**
* virCPUDataCheckFeature:
*
(*virCPUArchUpdate)(virCPUDefPtr guest,
const virCPUDef *host);
+typedef int
+(*virCPUArchCheckFeature)(const virCPUDef *cpu,
+ const char *feature);
+
typedef int
(*virCPUArchDataCheckFeature)(const virCPUData *data,
const char *feature);
cpuArchGuestData guestData;
cpuArchBaseline baseline;
virCPUArchUpdate update;
+ virCPUArchCheckFeature checkFeature;
virCPUArchDataCheckFeature dataCheckFeature;
cpuArchDataFormat dataFormat;
cpuArchDataParse dataParse;
const virCPUDef *host)
ATTRIBUTE_NONNULL(2);
+
+int
+virCPUCheckFeature(virArch arch,
+ const virCPUDef *cpu,
+ const char *feature)
+ ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
+
+
int
virCPUDataCheckFeature(const virCPUData *data,
const char *feature)
}
+static int
+virCPUx86CheckFeature(const virCPUDef *cpu,
+ const char *name)
+{
+ int ret = -1;
+ virCPUx86MapPtr map;
+ virCPUx86ModelPtr model = NULL;
+
+ if (!(map = virCPUx86GetMap()))
+ return -1;
+
+ if (!(model = x86ModelFromCPU(cpu, map, -1)))
+ goto cleanup;
+
+ ret = x86FeatureInData(name, &model->data, map);
+
+ cleanup:
+ x86ModelFree(model);
+ return ret;
+}
+
+
static int
virCPUx86DataCheckFeature(const virCPUData *data,
const char *name)
.guestData = x86GuestData,
.baseline = x86Baseline,
.update = virCPUx86Update,
+ .checkFeature = virCPUx86CheckFeature,
.dataCheckFeature = virCPUx86DataCheckFeature,
.dataFormat = x86CPUDataFormat,
.dataParse = x86CPUDataParse,
cpuGetModels;
cpuGuestData;
cpuNodeData;
+virCPUCheckFeature;
virCPUDataCheckFeature;
virCPUTranslate;
virCPUUpdate;
NULL, NULL, NULL, NULL) < 0)
goto cleanup;
- result = virCPUDataCheckFeature(hostData, data->name);
+ result = virCPUCheckFeature(host->arch, host, data->name);
+
+ if (data->result == result)
+ result = virCPUDataCheckFeature(hostData, data->name);
+
if (data->result == -1)
virResetLastError();