Replace the 'update' bool parameter with an enum so that we can have more than two possible values. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- src/conf/cpu_conf.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 55a7925d8a..2367d36c32 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -857,11 +857,17 @@ virCPUDefFormatBuf(virBufferPtr buf, return 0; } + +typedef enum { + VIR_CPU_ADD_FEATURE_MODE_EXCLUSIVE, /* Fail if feature exists */ + VIR_CPU_ADD_FEATURE_MODE_UPDATE, /* Add feature or update policy */ +} virCPUDefAddFeatureMode; + static int virCPUDefAddFeatureInternal(virCPUDefPtr def, const char *name, int policy, - bool update) + virCPUDefAddFeatureMode mode) { virCPUFeatureDefPtr feat; @@ -869,16 +875,18 @@ virCPUDefAddFeatureInternal(virCPUDefPtr def, policy = -1; if ((feat = virCPUDefFindFeature(def, name))) { - if (update) { + switch (mode) { + case VIR_CPU_ADD_FEATURE_MODE_UPDATE: feat->policy = policy; return 0; - } - - virReportError(VIR_ERR_INTERNAL_ERROR, - _("CPU feature '%s' specified more than once"), - name); - return -1; + case VIR_CPU_ADD_FEATURE_MODE_EXCLUSIVE: + default: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("CPU feature '%s' specified more than once"), + name); + return -1; + } } if (VIR_RESIZE_N(def->features, def->nfeatures_max, @@ -898,7 +906,8 @@ virCPUDefUpdateFeature(virCPUDefPtr def, const char *name, int policy) { - return virCPUDefAddFeatureInternal(def, name, policy, true); + return virCPUDefAddFeatureInternal(def, name, policy, + VIR_CPU_ADD_FEATURE_MODE_UPDATE); } int @@ -906,7 +915,8 @@ virCPUDefAddFeature(virCPUDefPtr def, const char *name, int policy) { - return virCPUDefAddFeatureInternal(def, name, policy, false); + return virCPUDefAddFeatureInternal(def, name, policy, + VIR_CPU_ADD_FEATURE_MODE_EXCLUSIVE); } -- 2.29.2