mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
cpu: Introduce virCPUDataAddFeature
This is a generic replacement for the former virCPUx86DataAddFeature, which worked on the generic virCPUDataPtr anyway. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
055f8f6bb9
commit
df73078c61
@ -1075,3 +1075,36 @@ virCPUValidateFeatures(virArch arch,
|
|||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virCPUDataAddFeature:
|
||||||
|
*
|
||||||
|
* @cpuData: CPU data
|
||||||
|
* @name: feature to be added to @cpuData
|
||||||
|
*
|
||||||
|
* Adds a feature called @name to @cpuData.
|
||||||
|
*
|
||||||
|
* Returns 0 on success, -1 on error.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
virCPUDataAddFeature(virCPUDataPtr cpuData,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
struct cpuArchDriver *driver;
|
||||||
|
|
||||||
|
VIR_DEBUG("arch=%s, cpuData=%p, name=%s",
|
||||||
|
virArchToString(cpuData->arch), cpuData, name);
|
||||||
|
|
||||||
|
if (!(driver = cpuGetSubDriver(cpuData->arch)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (!driver->dataAddFeature) {
|
||||||
|
virReportError(VIR_ERR_NO_SUPPORT,
|
||||||
|
_("cannot add guest CPU feature for %s architecture"),
|
||||||
|
virArchToString(cpuData->arch));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return driver->dataAddFeature(cpuData, name);
|
||||||
|
}
|
||||||
|
@ -117,6 +117,10 @@ typedef virCPUDefPtr
|
|||||||
typedef int
|
typedef int
|
||||||
(*virCPUArchValidateFeatures)(virCPUDefPtr cpu);
|
(*virCPUArchValidateFeatures)(virCPUDefPtr cpu);
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(*virCPUArchDataAddFeature)(virCPUDataPtr cpuData,
|
||||||
|
const char *name);
|
||||||
|
|
||||||
struct cpuArchDriver {
|
struct cpuArchDriver {
|
||||||
const char *name;
|
const char *name;
|
||||||
const virArch *arch;
|
const virArch *arch;
|
||||||
@ -139,6 +143,7 @@ struct cpuArchDriver {
|
|||||||
virCPUArchExpandFeatures expandFeatures;
|
virCPUArchExpandFeatures expandFeatures;
|
||||||
virCPUArchCopyMigratable copyMigratable;
|
virCPUArchCopyMigratable copyMigratable;
|
||||||
virCPUArchValidateFeatures validateFeatures;
|
virCPUArchValidateFeatures validateFeatures;
|
||||||
|
virCPUArchDataAddFeature dataAddFeature;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -256,6 +261,10 @@ virCPUValidateFeatures(virArch arch,
|
|||||||
virCPUDefPtr cpu)
|
virCPUDefPtr cpu)
|
||||||
ATTRIBUTE_NONNULL(2);
|
ATTRIBUTE_NONNULL(2);
|
||||||
|
|
||||||
|
int
|
||||||
|
virCPUDataAddFeature(virCPUDataPtr cpuData,
|
||||||
|
const char *name);
|
||||||
|
|
||||||
/* virCPUDataFormat and virCPUDataParse are implemented for unit tests only and
|
/* virCPUDataFormat and virCPUDataParse are implemented for unit tests only and
|
||||||
* have no real-life usage
|
* have no real-life usage
|
||||||
*/
|
*/
|
||||||
|
@ -3326,7 +3326,7 @@ virCPUx86DataSetVendor(virCPUDataPtr cpuData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
static int
|
||||||
virCPUx86DataAddFeature(virCPUDataPtr cpuData,
|
virCPUx86DataAddFeature(virCPUDataPtr cpuData,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
@ -3371,4 +3371,5 @@ struct cpuArchDriver cpuDriverX86 = {
|
|||||||
.expandFeatures = virCPUx86ExpandFeatures,
|
.expandFeatures = virCPUx86ExpandFeatures,
|
||||||
.copyMigratable = virCPUx86CopyMigratable,
|
.copyMigratable = virCPUx86CopyMigratable,
|
||||||
.validateFeatures = virCPUx86ValidateFeatures,
|
.validateFeatures = virCPUx86ValidateFeatures,
|
||||||
|
.dataAddFeature = virCPUx86DataAddFeature,
|
||||||
};
|
};
|
||||||
|
@ -40,6 +40,3 @@ uint32_t virCPUx86DataGetSignature(virCPUDataPtr cpuData,
|
|||||||
|
|
||||||
int virCPUx86DataSetVendor(virCPUDataPtr cpuData,
|
int virCPUx86DataSetVendor(virCPUDataPtr cpuData,
|
||||||
const char *vendor);
|
const char *vendor);
|
||||||
|
|
||||||
int virCPUx86DataAddFeature(virCPUDataPtr cpuData,
|
|
||||||
const char *name);
|
|
||||||
|
@ -1245,6 +1245,7 @@ virCPUCompare;
|
|||||||
virCPUCompareXML;
|
virCPUCompareXML;
|
||||||
virCPUConvertLegacy;
|
virCPUConvertLegacy;
|
||||||
virCPUCopyMigratable;
|
virCPUCopyMigratable;
|
||||||
|
virCPUDataAddFeature;
|
||||||
virCPUDataCheckFeature;
|
virCPUDataCheckFeature;
|
||||||
virCPUDataFormat;
|
virCPUDataFormat;
|
||||||
virCPUDataFree;
|
virCPUDataFree;
|
||||||
@ -1263,7 +1264,6 @@ virCPUValidateFeatures;
|
|||||||
|
|
||||||
# cpu/cpu_x86.h
|
# cpu/cpu_x86.h
|
||||||
virCPUx86DataAdd;
|
virCPUx86DataAdd;
|
||||||
virCPUx86DataAddFeature;
|
|
||||||
virCPUx86DataGetSignature;
|
virCPUx86DataGetSignature;
|
||||||
virCPUx86DataSetSignature;
|
virCPUx86DataSetSignature;
|
||||||
virCPUx86DataSetVendor;
|
virCPUx86DataSetVendor;
|
||||||
|
@ -3009,7 +3009,7 @@ virQEMUCapsGetCPUModelX86Data(virQEMUCapsPtr qemuCaps,
|
|||||||
(migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
|
(migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (virCPUx86DataAddFeature(data, name) < 0)
|
if (virCPUDataAddFeature(data, name) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user