mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
conf: Add virCPUDefAddFeatureIfMissing
This new function adds a feature to a CPU definition only if it is not present there yet. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
This commit is contained in:
parent
f5782579aa
commit
d7756a67bb
@ -861,6 +861,7 @@ virCPUDefFormatBuf(virBufferPtr buf,
|
||||
typedef enum {
|
||||
VIR_CPU_ADD_FEATURE_MODE_EXCLUSIVE, /* Fail if feature exists */
|
||||
VIR_CPU_ADD_FEATURE_MODE_UPDATE, /* Add feature or update policy */
|
||||
VIR_CPU_ADD_FEATURE_MODE_NEW, /* Add feature if it does not exist */
|
||||
} virCPUDefAddFeatureMode;
|
||||
|
||||
static int
|
||||
@ -876,6 +877,9 @@ virCPUDefAddFeatureInternal(virCPUDefPtr def,
|
||||
|
||||
if ((feat = virCPUDefFindFeature(def, name))) {
|
||||
switch (mode) {
|
||||
case VIR_CPU_ADD_FEATURE_MODE_NEW:
|
||||
return 0;
|
||||
|
||||
case VIR_CPU_ADD_FEATURE_MODE_UPDATE:
|
||||
feat->policy = policy;
|
||||
return 0;
|
||||
@ -920,6 +924,16 @@ virCPUDefAddFeature(virCPUDefPtr def,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virCPUDefAddFeatureIfMissing(virCPUDefPtr def,
|
||||
const char *name,
|
||||
int policy)
|
||||
{
|
||||
return virCPUDefAddFeatureInternal(def, name, policy,
|
||||
VIR_CPU_ADD_FEATURE_MODE_NEW);
|
||||
}
|
||||
|
||||
|
||||
virCPUFeatureDefPtr
|
||||
virCPUDefFindFeature(virCPUDefPtr def,
|
||||
const char *name)
|
||||
|
@ -229,6 +229,11 @@ virCPUDefUpdateFeature(virCPUDefPtr cpu,
|
||||
const char *name,
|
||||
int policy);
|
||||
|
||||
int
|
||||
virCPUDefAddFeatureIfMissing(virCPUDefPtr def,
|
||||
const char *name,
|
||||
int policy);
|
||||
|
||||
virCPUFeatureDefPtr
|
||||
virCPUDefFindFeature(virCPUDefPtr def,
|
||||
const char *name);
|
||||
|
@ -96,6 +96,7 @@ virDomainCheckpointTypeToString;
|
||||
virCPUCacheModeTypeFromString;
|
||||
virCPUCacheModeTypeToString;
|
||||
virCPUDefAddFeature;
|
||||
virCPUDefAddFeatureIfMissing;
|
||||
virCPUDefCheckFeatures;
|
||||
virCPUDefCopy;
|
||||
virCPUDefCopyModel;
|
||||
|
Loading…
Reference in New Issue
Block a user