mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +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,
|
int policy,
|
||||||
bool update)
|
bool update)
|
||||||
{
|
{
|
||||||
size_t i;
|
virCPUFeatureDefPtr feat;
|
||||||
|
|
||||||
if (def->type == VIR_CPU_TYPE_HOST)
|
if (def->type == VIR_CPU_TYPE_HOST)
|
||||||
policy = -1;
|
policy = -1;
|
||||||
|
|
||||||
for (i = 0; i < def->nfeatures; i++) {
|
if ((feat = virCPUDefFindFeature(def, name))) {
|
||||||
if (STREQ(name, def->features[i].name)) {
|
if (update) {
|
||||||
if (update) {
|
feat->policy = policy;
|
||||||
def->features[i].policy = policy;
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("CPU feature '%s' specified more than once"),
|
|
||||||
name);
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("CPU feature '%s' specified more than once"),
|
||||||
|
name);
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_RESIZE_N(def->features, def->nfeatures_max,
|
if (VIR_RESIZE_N(def->features, def->nfeatures_max,
|
||||||
@ -822,6 +820,22 @@ virCPUDefAddFeature(virCPUDefPtr def,
|
|||||||
return virCPUDefUpdateFeatureInternal(def, name, policy, false);
|
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
|
bool
|
||||||
virCPUDefIsEqual(virCPUDefPtr src,
|
virCPUDefIsEqual(virCPUDefPtr src,
|
||||||
virCPUDefPtr dst,
|
virCPUDefPtr dst,
|
||||||
|
@ -215,6 +215,10 @@ virCPUDefUpdateFeature(virCPUDefPtr cpu,
|
|||||||
const char *name,
|
const char *name,
|
||||||
int policy);
|
int policy);
|
||||||
|
|
||||||
|
virCPUFeatureDefPtr
|
||||||
|
virCPUDefFindFeature(virCPUDefPtr def,
|
||||||
|
const char *name);
|
||||||
|
|
||||||
virCPUDefPtr *
|
virCPUDefPtr *
|
||||||
virCPUDefListParse(const char **xmlCPUs,
|
virCPUDefListParse(const char **xmlCPUs,
|
||||||
unsigned int ncpus,
|
unsigned int ncpus,
|
||||||
|
@ -75,6 +75,7 @@ virCPUDefCopy;
|
|||||||
virCPUDefCopyModel;
|
virCPUDefCopyModel;
|
||||||
virCPUDefCopyModelFilter;
|
virCPUDefCopyModelFilter;
|
||||||
virCPUDefCopyWithoutModel;
|
virCPUDefCopyWithoutModel;
|
||||||
|
virCPUDefFindFeature;
|
||||||
virCPUDefFormat;
|
virCPUDefFormat;
|
||||||
virCPUDefFormatBuf;
|
virCPUDefFormatBuf;
|
||||||
virCPUDefFormatBufFull;
|
virCPUDefFormatBufFull;
|
||||||
|
Loading…
Reference in New Issue
Block a user