mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 20:45:18 +00:00
conf: Introduce virCPUDefFindFeature
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
4b87b3675f
commit
3276416904
@ -773,24 +773,22 @@ virCPUDefUpdateFeatureInternal(virCPUDefPtr def,
|
||||
int policy,
|
||||
bool update)
|
||||
{
|
||||
size_t i;
|
||||
virCPUFeatureDefPtr feat;
|
||||
|
||||
if (def->type == VIR_CPU_TYPE_HOST)
|
||||
policy = -1;
|
||||
|
||||
for (i = 0; i < def->nfeatures; i++) {
|
||||
if (STREQ(name, def->features[i].name)) {
|
||||
if (update) {
|
||||
def->features[i].policy = policy;
|
||||
return 0;
|
||||
}
|
||||
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("CPU feature '%s' specified more than once"),
|
||||
name);
|
||||
|
||||
return -1;
|
||||
if ((feat = virCPUDefFindFeature(def, name))) {
|
||||
if (update) {
|
||||
feat->policy = policy;
|
||||
return 0;
|
||||
}
|
||||
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("CPU feature '%s' specified more than once"),
|
||||
name);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (VIR_RESIZE_N(def->features, def->nfeatures_max,
|
||||
@ -822,6 +820,22 @@ virCPUDefAddFeature(virCPUDefPtr def,
|
||||
return virCPUDefUpdateFeatureInternal(def, name, policy, false);
|
||||
}
|
||||
|
||||
|
||||
virCPUFeatureDefPtr
|
||||
virCPUDefFindFeature(virCPUDefPtr def,
|
||||
const char *name)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < def->nfeatures; i++) {
|
||||
if (STREQ(name, def->features[i].name))
|
||||
return def->features + i;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
virCPUDefIsEqual(virCPUDefPtr src,
|
||||
virCPUDefPtr dst,
|
||||
|
@ -215,6 +215,10 @@ virCPUDefUpdateFeature(virCPUDefPtr cpu,
|
||||
const char *name,
|
||||
int policy);
|
||||
|
||||
virCPUFeatureDefPtr
|
||||
virCPUDefFindFeature(virCPUDefPtr def,
|
||||
const char *name);
|
||||
|
||||
virCPUDefPtr *
|
||||
virCPUDefListParse(const char **xmlCPUs,
|
||||
unsigned int ncpus,
|
||||
|
@ -75,6 +75,7 @@ virCPUDefCopy;
|
||||
virCPUDefCopyModel;
|
||||
virCPUDefCopyModelFilter;
|
||||
virCPUDefCopyWithoutModel;
|
||||
virCPUDefFindFeature;
|
||||
virCPUDefFormat;
|
||||
virCPUDefFormatBuf;
|
||||
virCPUDefFormatBufFull;
|
||||
|
Loading…
x
Reference in New Issue
Block a user