mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
cpu: Add virCPUDefUpdateFeature()
This new function updates or adds a feature to a existing cpu model definition. This function will be helpful to allow tuning of "host-model" features in later patches.
This commit is contained in:
parent
b42752870c
commit
13cdd389ed
@ -656,19 +656,28 @@ virCPUDefFormatBuf(virBufferPtr buf,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
int
|
virCPUDefUpdateFeatureInternal(virCPUDefPtr def,
|
||||||
virCPUDefAddFeature(virCPUDefPtr def,
|
const char *name,
|
||||||
const char *name,
|
int policy,
|
||||||
int policy)
|
bool update)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
if (def->type == VIR_CPU_TYPE_HOST)
|
||||||
|
policy = -1;
|
||||||
|
|
||||||
for (i = 0; i < def->nfeatures; i++) {
|
for (i = 0; i < def->nfeatures; i++) {
|
||||||
if (STREQ(name, def->features[i].name)) {
|
if (STREQ(name, def->features[i].name)) {
|
||||||
|
if (update) {
|
||||||
|
def->features[i].policy = policy;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("CPU feature `%s' specified more than once"),
|
_("CPU feature `%s' specified more than once"),
|
||||||
name);
|
name);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -677,9 +686,6 @@ virCPUDefAddFeature(virCPUDefPtr def,
|
|||||||
def->nfeatures, 1) < 0)
|
def->nfeatures, 1) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (def->type == VIR_CPU_TYPE_HOST)
|
|
||||||
policy = -1;
|
|
||||||
|
|
||||||
if (VIR_STRDUP(def->features[def->nfeatures].name, name) < 0)
|
if (VIR_STRDUP(def->features[def->nfeatures].name, name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -689,6 +695,22 @@ virCPUDefAddFeature(virCPUDefPtr def,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
virCPUDefUpdateFeature(virCPUDefPtr def,
|
||||||
|
const char *name,
|
||||||
|
int policy)
|
||||||
|
{
|
||||||
|
return virCPUDefUpdateFeatureInternal(def, name, policy, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
virCPUDefAddFeature(virCPUDefPtr def,
|
||||||
|
const char *name,
|
||||||
|
int policy)
|
||||||
|
{
|
||||||
|
return virCPUDefUpdateFeatureInternal(def, name, policy, false);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
virCPUDefIsEqual(virCPUDefPtr src,
|
virCPUDefIsEqual(virCPUDefPtr src,
|
||||||
virCPUDefPtr dst)
|
virCPUDefPtr dst)
|
||||||
|
@ -164,4 +164,9 @@ virCPUDefAddFeature(virCPUDefPtr cpu,
|
|||||||
const char *name,
|
const char *name,
|
||||||
int policy);
|
int policy);
|
||||||
|
|
||||||
|
int
|
||||||
|
virCPUDefUpdateFeature(virCPUDefPtr cpu,
|
||||||
|
const char *name,
|
||||||
|
int policy);
|
||||||
|
|
||||||
#endif /* __VIR_CPU_CONF_H__ */
|
#endif /* __VIR_CPU_CONF_H__ */
|
||||||
|
@ -70,6 +70,7 @@ virCPUDefFormatBuf;
|
|||||||
virCPUDefFree;
|
virCPUDefFree;
|
||||||
virCPUDefFreeModel;
|
virCPUDefFreeModel;
|
||||||
virCPUDefParseXML;
|
virCPUDefParseXML;
|
||||||
|
virCPUDefUpdateFeature;
|
||||||
virCPUModeTypeToString;
|
virCPUModeTypeToString;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user