From: Daniel P. Berrangé Date: Tue, 5 Oct 2021 16:46:17 +0000 (+0100) Subject: qemu: inline the qemuBuildCpuFeature code X-Git-Tag: v7.9.0-rc1~61 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e28ce3885d15090e33855ce5ed2dfdd13469d317;p=thirdparty%2Flibvirt.git 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 Signed-off-by: Daniel P. Berrangé --- diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e63e60439a..a8a0791c3b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -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 qemuBuildCpuModelArgStr(virQEMUDriver *driver, const virDomainDef *def, @@ -6696,15 +6684,17 @@ qemuBuildCpuModelArgStr(virQEMUDriver *driver, virBufferAsprintf(buf, ",vendor=%s", cpu->vendor_id); for (i = 0; i < cpu->nfeatures; i++) { + const char *featname = + virQEMUCapsCPUFeatureToQEMU(qemuCaps, cpu->features[i].name); switch ((virCPUFeaturePolicy) cpu->features[i].policy) { case VIR_CPU_FEATURE_FORCE: case VIR_CPU_FEATURE_REQUIRE: - qemuBuildCpuFeature(qemuCaps, buf, cpu->features[i].name, true); + virBufferAsprintf(buf, ",%s=on", featname); break; case VIR_CPU_FEATURE_DISABLE: case VIR_CPU_FEATURE_FORBID: - qemuBuildCpuFeature(qemuCaps, buf, cpu->features[i].name, false); + virBufferAsprintf(buf, ",%s=off", featname); break; case VIR_CPU_FEATURE_OPTIONAL: @@ -6761,8 +6751,8 @@ qemuBuildCpuCommandLine(virCommand *cmd, switch ((virDomainTimerNameType)timer->name) { case VIR_DOMAIN_TIMER_NAME_KVMCLOCK: if (timer->present != -1) { - qemuBuildCpuFeature(qemuCaps, &buf, "kvmclock", - !!timer->present); + virBufferAsprintf(&buf, ",kvmclock=%s", + timer->present ? "on" : "off"); } break; case VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK: @@ -6800,13 +6790,14 @@ qemuBuildCpuCommandLine(virCommand *cmd, } if (def->apic_eoi) { - qemuBuildCpuFeature(qemuCaps, &buf, "kvm_pv_eoi", - def->apic_eoi == VIR_TRISTATE_SWITCH_ON); + virBufferAsprintf(&buf, ",kvm-pv-eoi=%s", def->apic_eoi == + VIR_TRISTATE_SWITCH_ON ? "on" : "off"); } if (def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK]) { - qemuBuildCpuFeature(qemuCaps, &buf, VIR_CPU_x86_KVM_PV_UNHALT, - def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK] == VIR_TRISTATE_SWITCH_ON); + virBufferAsprintf(&buf, ",kvm-pv-unhalt=%s", + def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK] == + VIR_TRISTATE_SWITCH_ON ? "on" : "off"); } if (def->features[VIR_DOMAIN_FEATURE_HYPERV] == VIR_TRISTATE_SWITCH_ON) {