mirror of https://gitee.com/openkylin/libvirt.git
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
|
||||
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
|
||||
(*virCPUArchValidateFeatures)(virCPUDefPtr cpu);
|
||||
|
||||
typedef int
|
||||
(*virCPUArchDataAddFeature)(virCPUDataPtr cpuData,
|
||||
const char *name);
|
||||
|
||||
struct cpuArchDriver {
|
||||
const char *name;
|
||||
const virArch *arch;
|
||||
|
@ -139,6 +143,7 @@ struct cpuArchDriver {
|
|||
virCPUArchExpandFeatures expandFeatures;
|
||||
virCPUArchCopyMigratable copyMigratable;
|
||||
virCPUArchValidateFeatures validateFeatures;
|
||||
virCPUArchDataAddFeature dataAddFeature;
|
||||
};
|
||||
|
||||
|
||||
|
@ -256,6 +261,10 @@ virCPUValidateFeatures(virArch arch,
|
|||
virCPUDefPtr cpu)
|
||||
ATTRIBUTE_NONNULL(2);
|
||||
|
||||
int
|
||||
virCPUDataAddFeature(virCPUDataPtr cpuData,
|
||||
const char *name);
|
||||
|
||||
/* virCPUDataFormat and virCPUDataParse are implemented for unit tests only and
|
||||
* have no real-life usage
|
||||
*/
|
||||
|
|
|
@ -3326,7 +3326,7 @@ virCPUx86DataSetVendor(virCPUDataPtr cpuData,
|
|||
}
|
||||
|
||||
|
||||
int
|
||||
static int
|
||||
virCPUx86DataAddFeature(virCPUDataPtr cpuData,
|
||||
const char *name)
|
||||
{
|
||||
|
@ -3371,4 +3371,5 @@ struct cpuArchDriver cpuDriverX86 = {
|
|||
.expandFeatures = virCPUx86ExpandFeatures,
|
||||
.copyMigratable = virCPUx86CopyMigratable,
|
||||
.validateFeatures = virCPUx86ValidateFeatures,
|
||||
.dataAddFeature = virCPUx86DataAddFeature,
|
||||
};
|
||||
|
|
|
@ -40,6 +40,3 @@ uint32_t virCPUx86DataGetSignature(virCPUDataPtr cpuData,
|
|||
|
||||
int virCPUx86DataSetVendor(virCPUDataPtr cpuData,
|
||||
const char *vendor);
|
||||
|
||||
int virCPUx86DataAddFeature(virCPUDataPtr cpuData,
|
||||
const char *name);
|
||||
|
|
|
@ -1245,6 +1245,7 @@ virCPUCompare;
|
|||
virCPUCompareXML;
|
||||
virCPUConvertLegacy;
|
||||
virCPUCopyMigratable;
|
||||
virCPUDataAddFeature;
|
||||
virCPUDataCheckFeature;
|
||||
virCPUDataFormat;
|
||||
virCPUDataFree;
|
||||
|
@ -1263,7 +1264,6 @@ virCPUValidateFeatures;
|
|||
|
||||
# cpu/cpu_x86.h
|
||||
virCPUx86DataAdd;
|
||||
virCPUx86DataAddFeature;
|
||||
virCPUx86DataGetSignature;
|
||||
virCPUx86DataSetSignature;
|
||||
virCPUx86DataSetVendor;
|
||||
|
|
|
@ -3009,7 +3009,7 @@ virQEMUCapsGetCPUModelX86Data(virQEMUCapsPtr qemuCaps,
|
|||
(migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
|
||||
continue;
|
||||
|
||||
if (virCPUx86DataAddFeature(data, name) < 0)
|
||||
if (virCPUDataAddFeature(data, name) < 0)
|
||||
goto cleanup;
|
||||
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue