[PATCH 0/2] Hyper-V feature fixes

I wrote so many good commit messages today, leave me alone. Martin Kletzander (2): qemu: Add more translations to virQEMUCapsCPUFeatureTranslationTable qemu: Do not hardcode Hyper-V feature names on command line src/qemu/qemu_capabilities.c | 3 +++ src/qemu/qemu_command.c | 22 +++++++++------------- 2 files changed, 12 insertions(+), 13 deletions(-) -- 2.47.0

Hyper-V enlightenment features can have hyphenated names which libvirt exposes under Hyper-V features with underscored names. When libvirt checks that all requested features were enabled by QEMU (on x86 architectures) it first queries for all those that QEMU knows and compiles them in a map while using the virQEMUCapsCPUFeaturesX86 for translations. Some features (well, all Hyper-V features with underscores) were not present in the translation table and were incorrectly reported as not enabled, consequently failing the start of any such domain. Add all hyphenated/underscored Hyper-V feature names into the aforementioned translation table. That way domains with these features enabled can be started when QEMU and the kernel support them. Resolves: https://issues.redhat.com/browse/RHEL-7122 Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/qemu/qemu_capabilities.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 7d0cb2caaa4a..e1e28e5cd1aa 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3583,6 +3583,9 @@ virQEMUCapsCPUFeatureTranslationTable virQEMUCapsCPUFeaturesX86[] = { {"perfctr_nb", "perfctr-nb"}, {"tsc_adjust", "tsc-adjust"}, {"vmx-invvpid-single-context-noglobals", "vmx-invept-single-context-noglobals"}, + {"hv-vendor_id", "hv-vendor-id"}, + {"hv-emsr_bitmap", "hv-emsr-bitmap"}, + {"hv-xmm_input", "hv-xmm-input"}, {NULL, NULL} }; -- 2.47.0

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@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

On Wed, Oct 16, 2024 at 16:02:08 +0200, Martin Kletzander wrote:
I wrote so many good commit messages today, leave me alone.
So can you share them with us? :-D
Martin Kletzander (2): qemu: Add more translations to virQEMUCapsCPUFeatureTranslationTable qemu: Do not hardcode Hyper-V feature names on command line
src/qemu/qemu_capabilities.c | 3 +++ src/qemu/qemu_command.c | 22 +++++++++------------- 2 files changed, 12 insertions(+), 13 deletions(-)
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>

On Wed, Oct 16, 2024 at 04:21:42PM +0200, Jiri Denemark wrote:
On Wed, Oct 16, 2024 at 16:02:08 +0200, Martin Kletzander wrote:
I wrote so many good commit messages today, leave me alone.
So can you share them with us? :-D
https://gitlab.com/libvirt/libvirt/-/commit/2b19f4b82d245d2c50e46ebf954280d5... https://gitlab.com/libvirt/libvirt/-/commit/26f249034d7238ef1fe5c7668b27b9cc... https://gitlab.com/libvirt/libvirt/-/commit/f2710260d42b426fc4b327fcb02adf4d... https://gitlab.com/libvirt/libvirt/-/commit/ca8c0862acee6f9d6fc7a73dd5ffdf4e... https://gitlab.com/libvirt/libvirt/-/commit/f7c89763b1a7a189f06fb61843bf2ba6... https://gitlab.com/MichalPrivoznik/virt-lint/-/commit/1eb76fd6d9fdee9e77254b... You are welcome ;)
Martin Kletzander (2): qemu: Add more translations to virQEMUCapsCPUFeatureTranslationTable qemu: Do not hardcode Hyper-V feature names on command line
src/qemu/qemu_capabilities.c | 3 +++ src/qemu/qemu_command.c | 22 +++++++++------------- 2 files changed, 12 insertions(+), 13 deletions(-)
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
participants (2)
-
Jiri Denemark
-
Martin Kletzander