mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
conf: Change return value of some CPU feature APIs
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@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
23c4794488
commit
8c1b07b088
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -3851,10 +3851,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user