When constructing the command line for QEMU, some Hyper-V features were
hardcoded, probably due to the fact that they could not have been
automatically translated from the libvirt feature name to QEMU CPU
feature name.
Well now they can be, thanks to their additions to the
virQEMUCapsCPUFeaturesX86 translation table.
Translate all such features the same way when constructing the command
line. This way any future feature that is not translated will be caught
by tests (if a test is added for it) which was not the case when it was
just hardcoded. Hopefully this avoids at least some possible future
issues.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/qemu/qemu_command.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c7055ef196f0..a5ff7695c375 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6315,9 +6315,15 @@ qemuBuildCpuCommandLine(virCommand *cmd,
case VIR_DOMAIN_HYPERV_IPI:
case VIR_DOMAIN_HYPERV_EVMCS:
case VIR_DOMAIN_HYPERV_AVIC:
- if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON)
- virBufferAsprintf(&buf, ",hv-%s=on",
- virDomainHypervTypeToString(i));
+ case VIR_DOMAIN_HYPERV_EMSR_BITMAP:
+ case VIR_DOMAIN_HYPERV_XMM_INPUT:
+ if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON) {
+ const char *name = virDomainHypervTypeToString(i);
+ g_autofree char *full_name = g_strdup_printf("hv-%s",
name);
+ const char *qemu_name = virQEMUCapsCPUFeatureToQEMU(def->os.arch,
+ full_name);
+ virBufferAsprintf(&buf, ",%s=on", qemu_name);
+ }
if ((i == VIR_DOMAIN_HYPERV_STIMER) &&
(def->hyperv_stimer_direct == VIR_TRISTATE_SWITCH_ON))
virBufferAsprintf(&buf, ",%s=on",
VIR_CPU_x86_HV_STIMER_DIRECT);
@@ -6336,16 +6342,6 @@ qemuBuildCpuCommandLine(virCommand *cmd,
def->hyperv_vendor_id);
break;
- case VIR_DOMAIN_HYPERV_EMSR_BITMAP:
- if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON)
- virBufferAsprintf(&buf, ",%s=on",
"hv-emsr-bitmap");
- break;
-
- case VIR_DOMAIN_HYPERV_XMM_INPUT:
- if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON)
- virBufferAsprintf(&buf, ",%s=on",
"hv-xmm-input");
- break;
-
case VIR_DOMAIN_HYPERV_LAST:
break;
}
--
2.47.0