The virCPUDefAddFeatureInternal helper function only fails if it is called with VIR_CPU_ADD_FEATURE_MODE_EXCLUSIVE, which is only used in virCPUDefAddFeature. The other callers (virCPUDefUpdateFeature and virCPUDefAddFeatureIfMissing) will never get anything but 0 from virCPUDefAddFeatureInternal and their return type can be changed to void. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- src/conf/cpu_conf.c | 12 ++++---- src/conf/cpu_conf.h | 4 +-- src/cpu/cpu_s390.c | 7 ++--- src/cpu/cpu_x86.c | 58 +++++++++++++----------------------- src/qemu/qemu_capabilities.c | 5 ++-- src/qemu/qemu_domain.c | 3 +- 6 files changed, 34 insertions(+), 55 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 4dca7e57ec..dcc164d165 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -938,13 +938,13 @@ virCPUDefAddFeatureInternal(virCPUDef *def, return 0; } -int +void virCPUDefUpdateFeature(virCPUDef *def, const char *name, int policy) { - return virCPUDefAddFeatureInternal(def, name, policy, - VIR_CPU_ADD_FEATURE_MODE_UPDATE); + virCPUDefAddFeatureInternal(def, name, policy, + VIR_CPU_ADD_FEATURE_MODE_UPDATE); } int @@ -957,13 +957,13 @@ virCPUDefAddFeature(virCPUDef *def, } -int +void virCPUDefAddFeatureIfMissing(virCPUDef *def, const char *name, int policy) { - return virCPUDefAddFeatureInternal(def, name, policy, - VIR_CPU_ADD_FEATURE_MODE_NEW); + virCPUDefAddFeatureInternal(def, name, policy, + VIR_CPU_ADD_FEATURE_MODE_NEW); } diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index b10c23ee82..f71d942ce6 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -245,12 +245,12 @@ virCPUDefAddFeature(virCPUDef *cpu, const char *name, int policy); -int +void virCPUDefUpdateFeature(virCPUDef *cpu, const char *name, int policy); -int +void virCPUDefAddFeatureIfMissing(virCPUDef *def, const char *name, int policy); diff --git a/src/cpu/cpu_s390.c b/src/cpu/cpu_s390.c index ffb1a2cf7b..13695ee97a 100644 --- a/src/cpu/cpu_s390.c +++ b/src/cpu/cpu_s390.c @@ -72,10 +72,9 @@ virCPUs390Update(virCPUDef *guest, virCPUDefCopyModel(updated, host, true); for (i = 0; i < guest->nfeatures; i++) { - if (virCPUDefUpdateFeature(updated, - guest->features[i].name, - guest->features[i].policy) < 0) - return -1; + virCPUDefUpdateFeature(updated, + guest->features[i].name, + guest->features[i].policy); } virCPUDefStealModel(guest, updated, false); diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 0fad761809..8770f52d15 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -834,23 +834,19 @@ x86DataAddSignature(virCPUx86Data *data, * mentioned in @cpu to make sure these features will always be explicitly * listed in the CPU definition. */ -static int +static void virCPUx86DisableRemovedFeatures(virCPUDef *cpu, virCPUx86Model *model) { char **feat = model->removedFeatures; if (!feat) - return 0; + return; while (*feat) { - if (virCPUDefAddFeatureIfMissing(cpu, *feat, VIR_CPU_FEATURE_DISABLE) < 0) - return -1; - + virCPUDefAddFeatureIfMissing(cpu, *feat, VIR_CPU_FEATURE_DISABLE); feat++; } - - return 0; } @@ -901,10 +897,8 @@ x86DataToCPU(const virCPUx86Data *data, x86DataToCPUFeatures(cpu, VIR_CPU_FEATURE_DISABLE, &modelData, map)) return NULL; - if (cpuType == VIR_CPU_TYPE_GUEST) { - if (virCPUx86DisableRemovedFeatures(cpu, model) < 0) - return NULL; - } + if (cpuType == VIR_CPU_TYPE_GUEST) + virCPUx86DisableRemovedFeatures(cpu, model); cpu->type = cpuType; @@ -2914,7 +2908,7 @@ virCPUx86Baseline(virCPUDef **cpus, } -static int +static void x86UpdateHostModel(virCPUDef *guest, const virCPUDef *host) { @@ -2931,18 +2925,15 @@ x86UpdateHostModel(virCPUDef *guest, } for (i = 0; i < guest->nfeatures; i++) { - if (virCPUDefUpdateFeature(updated, - guest->features[i].name, - guest->features[i].policy) < 0) - return -1; + virCPUDefUpdateFeature(updated, + guest->features[i].name, + guest->features[i].policy); } virCPUDefStealModel(guest, updated, guest->mode == VIR_CPU_MODE_CUSTOM); guest->mode = VIR_CPU_MODE_CUSTOM; guest->match = VIR_CPU_MATCH_EXACT; - - return 0; } @@ -2984,8 +2975,7 @@ virCPUx86Update(virCPUDef *guest, if (guest->mode == VIR_CPU_MODE_HOST_MODEL || guest->match == VIR_CPU_MATCH_MINIMUM) { - if (x86UpdateHostModel(guest, host) < 0) - return -1; + x86UpdateHostModel(guest, host); } } @@ -2995,8 +2985,7 @@ virCPUx86Update(virCPUDef *guest, return -1; } - if (virCPUx86DisableRemovedFeatures(guest, guestModel) < 0) - return -1; + virCPUx86DisableRemovedFeatures(guest, guestModel); return 0; } @@ -3065,9 +3054,8 @@ virCPUx86UpdateLive(virCPUDef *cpu, if (cpu->check == VIR_CPU_CHECK_FULL && !g_strv_contains((const char **) model->addedFeatures, feature->name)) { virBufferAsprintf(&bufAdded, "%s,", feature->name); - } else if (virCPUDefUpdateFeature(cpu, feature->name, - VIR_CPU_FEATURE_REQUIRE) < 0) { - return -1; + } else { + virCPUDefUpdateFeature(cpu, feature->name, VIR_CPU_FEATURE_REQUIRE); } } @@ -3077,14 +3065,12 @@ virCPUx86UpdateLive(virCPUDef *cpu, VIR_DEBUG("Feature '%s' disabled by the hypervisor", feature->name); if (cpu->check == VIR_CPU_CHECK_FULL) virBufferAsprintf(&bufRemoved, "%s,", feature->name); - else if (virCPUDefUpdateFeature(cpu, feature->name, - VIR_CPU_FEATURE_DISABLE) < 0) - return -1; + else + virCPUDefUpdateFeature(cpu, feature->name, VIR_CPU_FEATURE_DISABLE); } } - if (virCPUx86DisableRemovedFeatures(cpu, model) < 0) - return -1; + virCPUx86DisableRemovedFeatures(cpu, model); virBufferTrim(&bufAdded, ","); virBufferTrim(&bufRemoved, ","); @@ -3186,8 +3172,7 @@ virCPUx86Translate(virCPUDef *cpu, for (i = 0; i < cpu->nfeatures; i++) { virCPUFeatureDef *f = cpu->features + i; - if (virCPUDefUpdateFeature(translated, f->name, f->policy) < 0) - return -1; + virCPUDefUpdateFeature(translated, f->name, f->policy); } virCPUDefStealModel(cpu, translated, true); @@ -3229,14 +3214,11 @@ virCPUx86ExpandFeatures(virCPUDef *cpu) f->policy != VIR_CPU_FEATURE_DISABLE) continue; - if (virCPUDefUpdateFeature(expanded, f->name, f->policy) < 0) - return -1; + virCPUDefUpdateFeature(expanded, f->name, f->policy); } - if (!host) { - if (virCPUx86DisableRemovedFeatures(expanded, model) < 0) - return -1; - } + if (!host) + virCPUx86DisableRemovedFeatures(expanded, model); virCPUDefFreeModel(cpu); diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 21f93c6774..3c16b8f560 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3846,10 +3846,9 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, goto error; for (i = 0; i < cpuExpanded->nfeatures; i++) { - if (cpuExpanded->features[i].policy == VIR_CPU_FEATURE_REQUIRE && + if (cpuExpanded->features[i].policy == VIR_CPU_FEATURE_REQUIRE) virCPUDefUpdateFeature(fullCPU, cpuExpanded->features[i].name, - VIR_CPU_FEATURE_REQUIRE) < 0) - goto error; + VIR_CPU_FEATURE_REQUIRE); } } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 3469f0d40c..e42b04865b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6699,8 +6699,7 @@ qemuDomainMakeCPUMigratable(virArch arch, * would think it was implicitly enabled on the source). New libvirt * will drop it from the XML before starting the domain on new QEMU. */ - if (virCPUDefUpdateFeature(cpu, "pconfig", VIR_CPU_FEATURE_DISABLE) < 0) - return -1; + virCPUDefUpdateFeature(cpu, "pconfig", VIR_CPU_FEATURE_DISABLE); } if (virCPUx86GetAddedFeatures(cpu->model, &data.added) < 0) -- 2.44.0 _______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx