提交 c145b660 编写于 作者: J Jiri Denemark

cpu_conf: Introduce virCPUDefFilterFeatures

This new internal API can be used for in place filtering of CPU features
in virCPUDef.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 955fd6e7
......@@ -908,6 +908,28 @@ virCPUDefFindFeature(virCPUDefPtr def,
}
int
virCPUDefFilterFeatures(virCPUDefPtr cpu,
virCPUDefFeatureFilter filter,
void *opaque)
{
size_t i = 0;
while (i < cpu->nfeatures) {
if (filter(cpu->features[i].name, opaque)) {
i++;
continue;
}
VIR_FREE(cpu->features[i].name);
if (VIR_DELETE_ELEMENT_INPLACE(cpu->features, i, cpu->nfeatures) < 0)
return -1;
}
return 0;
}
bool
virCPUDefIsEqual(virCPUDefPtr src,
virCPUDefPtr dst,
......
......@@ -219,6 +219,11 @@ virCPUFeatureDefPtr
virCPUDefFindFeature(virCPUDefPtr def,
const char *name);
int
virCPUDefFilterFeatures(virCPUDefPtr cpu,
virCPUDefFeatureFilter filter,
void *opaque);
virCPUDefPtr *
virCPUDefListParse(const char **xmlCPUs,
unsigned int ncpus,
......
......@@ -77,6 +77,7 @@ virCPUDefCopy;
virCPUDefCopyModel;
virCPUDefCopyModelFilter;
virCPUDefCopyWithoutModel;
virCPUDefFilterFeatures;
virCPUDefFindFeature;
virCPUDefFormat;
virCPUDefFormatBuf;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册