qemu: inline the qemuBuildCpuFeature code

With the previous refactorings, there's no real benefit from the
qemuBuildCpuFeature helper method. Only one of the callers really
needs the CPU feature name re-writing logic, the others can just
use the right name directly.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2021-10-05 17:46:17 +01:00
parent ff3e93a26b
commit e28ce3885d

View File

@ -6612,18 +6612,6 @@ qemuBuildGlobalControllerCommandLine(virCommand *cmd,
} }
static void
qemuBuildCpuFeature(virQEMUCaps *qemuCaps,
virBuffer *buf,
const char *name,
bool state)
{
name = virQEMUCapsCPUFeatureToQEMU(qemuCaps, name);
virBufferAsprintf(buf, ",%s=%s", name, state ? "on" : "off");
}
static int static int
qemuBuildCpuModelArgStr(virQEMUDriver *driver, qemuBuildCpuModelArgStr(virQEMUDriver *driver,
const virDomainDef *def, const virDomainDef *def,
@ -6696,15 +6684,17 @@ qemuBuildCpuModelArgStr(virQEMUDriver *driver,
virBufferAsprintf(buf, ",vendor=%s", cpu->vendor_id); virBufferAsprintf(buf, ",vendor=%s", cpu->vendor_id);
for (i = 0; i < cpu->nfeatures; i++) { for (i = 0; i < cpu->nfeatures; i++) {
const char *featname =
virQEMUCapsCPUFeatureToQEMU(qemuCaps, cpu->features[i].name);
switch ((virCPUFeaturePolicy) cpu->features[i].policy) { switch ((virCPUFeaturePolicy) cpu->features[i].policy) {
case VIR_CPU_FEATURE_FORCE: case VIR_CPU_FEATURE_FORCE:
case VIR_CPU_FEATURE_REQUIRE: case VIR_CPU_FEATURE_REQUIRE:
qemuBuildCpuFeature(qemuCaps, buf, cpu->features[i].name, true); virBufferAsprintf(buf, ",%s=on", featname);
break; break;
case VIR_CPU_FEATURE_DISABLE: case VIR_CPU_FEATURE_DISABLE:
case VIR_CPU_FEATURE_FORBID: case VIR_CPU_FEATURE_FORBID:
qemuBuildCpuFeature(qemuCaps, buf, cpu->features[i].name, false); virBufferAsprintf(buf, ",%s=off", featname);
break; break;
case VIR_CPU_FEATURE_OPTIONAL: case VIR_CPU_FEATURE_OPTIONAL:
@ -6761,8 +6751,8 @@ qemuBuildCpuCommandLine(virCommand *cmd,
switch ((virDomainTimerNameType)timer->name) { switch ((virDomainTimerNameType)timer->name) {
case VIR_DOMAIN_TIMER_NAME_KVMCLOCK: case VIR_DOMAIN_TIMER_NAME_KVMCLOCK:
if (timer->present != -1) { if (timer->present != -1) {
qemuBuildCpuFeature(qemuCaps, &buf, "kvmclock", virBufferAsprintf(&buf, ",kvmclock=%s",
!!timer->present); timer->present ? "on" : "off");
} }
break; break;
case VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK: case VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK:
@ -6800,13 +6790,14 @@ qemuBuildCpuCommandLine(virCommand *cmd,
} }
if (def->apic_eoi) { if (def->apic_eoi) {
qemuBuildCpuFeature(qemuCaps, &buf, "kvm_pv_eoi", virBufferAsprintf(&buf, ",kvm-pv-eoi=%s", def->apic_eoi ==
def->apic_eoi == VIR_TRISTATE_SWITCH_ON); VIR_TRISTATE_SWITCH_ON ? "on" : "off");
} }
if (def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK]) { if (def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK]) {
qemuBuildCpuFeature(qemuCaps, &buf, VIR_CPU_x86_KVM_PV_UNHALT, virBufferAsprintf(&buf, ",kvm-pv-unhalt=%s",
def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK] == VIR_TRISTATE_SWITCH_ON); def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK] ==
VIR_TRISTATE_SWITCH_ON ? "on" : "off");
} }
if (def->features[VIR_DOMAIN_FEATURE_HYPERV] == VIR_TRISTATE_SWITCH_ON) { if (def->features[VIR_DOMAIN_FEATURE_HYPERV] == VIR_TRISTATE_SWITCH_ON) {