mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +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;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virCPUDefAddFeature(virCPUDefPtr def,
|
||||
const char *name,
|
||||
int policy)
|
||||
static int
|
||||
virCPUDefUpdateFeatureInternal(virCPUDefPtr def,
|
||||
const char *name,
|
||||
int policy,
|
||||
bool update)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -677,9 +686,6 @@ virCPUDefAddFeature(virCPUDefPtr def,
|
||||
def->nfeatures, 1) < 0)
|
||||
return -1;
|
||||
|
||||
if (def->type == VIR_CPU_TYPE_HOST)
|
||||
policy = -1;
|
||||
|
||||
if (VIR_STRDUP(def->features[def->nfeatures].name, name) < 0)
|
||||
return -1;
|
||||
|
||||
@ -689,6 +695,22 @@ virCPUDefAddFeature(virCPUDefPtr def,
|
||||
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
|
||||
virCPUDefIsEqual(virCPUDefPtr src,
|
||||
virCPUDefPtr dst)
|
||||
|
@ -164,4 +164,9 @@ virCPUDefAddFeature(virCPUDefPtr cpu,
|
||||
const char *name,
|
||||
int policy);
|
||||
|
||||
int
|
||||
virCPUDefUpdateFeature(virCPUDefPtr cpu,
|
||||
const char *name,
|
||||
int policy);
|
||||
|
||||
#endif /* __VIR_CPU_CONF_H__ */
|
||||
|
@ -70,6 +70,7 @@ virCPUDefFormatBuf;
|
||||
virCPUDefFree;
|
||||
virCPUDefFreeModel;
|
||||
virCPUDefParseXML;
|
||||
virCPUDefUpdateFeature;
|
||||
virCPUModeTypeToString;
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user