Skip to content

kvm: implement Hyper-V enlightenments correctly to allow running HyperV on KVM#11213

Closed
yadvr wants to merge 2 commits intoapache:4.20from
shapeblue:console-optimisations
Closed

kvm: implement Hyper-V enlightenments correctly to allow running HyperV on KVM#11213
yadvr wants to merge 2 commits intoapache:4.20from
shapeblue:console-optimisations

Conversation

@yadvr
Copy link
Copy Markdown
Member

@yadvr yadvr commented Jul 16, 2025

This implements Hyper-V enlightenments as per the RHEL docs: https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/10/html/configuring_and_managing_windows_virtual_machines/optimizing-windows-virtual-machines#enabling-hyper-v-enlightenments

This is enabled only when the guest OS is set to Windows PV.

This PR is followup of findings and improvements from #10650 (comment)

Tested on: ACS 4.20.1 with Ubuntu 22.04/KVM with Windows 10 ISO, installed Windows 10 VM

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI
  • test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

This implements Hyper-V enlightenments as per the RHEL docs:
https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/10/html/configuring_and_managing_windows_virtual_machines/optimizing-windows-virtual-machines#enabling-hyper-v-enlightenments

This is enabled only when the guest OS is set to Windows PV.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
@yadvr yadvr added this to the 4.20.2 milestone Jul 16, 2025
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Jul 16, 2025

Codecov Report

❌ Patch coverage is 54.83871% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.52%. Comparing base (c61a5eb) to head (f1510c6).
⚠️ Report is 92 commits behind head on 4.20.

Files with missing lines Patch % Lines
...ervisor/kvm/resource/LibvirtComputingResource.java 0.00% 12 Missing and 1 partial ⚠️
...om/cloud/hypervisor/kvm/resource/LibvirtVMDef.java 94.44% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.20   #11213      +/-   ##
============================================
+ Coverage     16.14%   16.52%   +0.38%     
- Complexity    13256    13613     +357     
============================================
  Files          5656     5657       +1     
  Lines        497893   511363   +13470     
  Branches      60374    66501    +6127     
============================================
+ Hits          80394    84519    +4125     
- Misses       408539   417608    +9069     
- Partials       8960     9236     +276     
Flag Coverage Δ
uitests 4.14% <ø> (+0.14%) ⬆️
unittests 17.40% <54.83%> (+0.40%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yadvr yadvr requested review from vishesh92 and weizhouapache July 16, 2025 06:49
Comment on lines 390 to +399
feaBuilder.append("<");
feaBuilder.append(e.getKey());

if(e.getKey().equals("spinlocks")) feaBuilder.append(" state='" + e.getValue() + "' retries='" + getRetries() + "'");
else feaBuilder.append(" state='" + e.getValue() + "'");
if (e.getKey().equals("spinlocks")) feaBuilder.append(" state='" + e.getValue() + "' retries='" + getRetries() + "'");
else if (e.getKey().equals("vendor_id")) feaBuilder.append(" state='" + e.getValue() + "' value='KVM Hv'");
else if (e.getKey().equals("stimer")) feaBuilder.append(" state='" + e.getValue() + "'><direct state='" + e.getValue() + "'/>");
else feaBuilder.append(" state='" + e.getValue() + "'");

feaBuilder.append("/>\n");
if (e.getKey().equals("stimer")) feaBuilder.append("</stimer>\n");
else feaBuilder.append("/>\n");
Copy link
Copy Markdown
Contributor

@DaanHoogland DaanHoogland Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this could be a bit cleaner as a switch statement:

              String key = e.getKey();
              feaBuilder.append("<");
              feaBuilder.append(key);

              switch (key) {
              case “spinlocks”:
                  feaBuilder.append(" state='" + e.getValue() + "' retries='" + getRetries() + "'/>\n”);
                  break;
              case “vendor_id”:
                  feaBuilder.append(" state='" + e.getValue() + "' value='KVM Hv'/>\n");
                  break;
              case “stimer”:
                  feaBuilder.append(" state='" + e.getValue() + "'><direct state='" + e.getValue() + "'/></stimer>\n");
                  break;
              default:
                  feaBuilder.append(" state='" + e.getValue() + "'/>\n”);
               }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree - in fact the whole class could use refactoring. For my purpose, unfortunately these changes made no visible impact on console performance #10650 (comment)

I won't have time to refactor this today or later, but you and others are welcome to collaborate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if these have no results we can merge them on recomendation of redhat, but further effort along this line seems mute to me.

@yadvr
Copy link
Copy Markdown
Member Author

yadvr commented Jul 16, 2025

@vishesh92 @weizhouapache this doesn't address the console performance like I originally thought, should I keep it open or close this? cc @DaanHoogland

@yadvr yadvr closed this Jul 16, 2025
@yadvr yadvr reopened this Jul 16, 2025
@yadvr
Copy link
Copy Markdown
Member Author

yadvr commented Jul 16, 2025

@blueorangutan package

hyv.setFeature("reenlightenment", true);
hyv.setFeature("stimer", true);
hyv.setFeature("ipi", true);
hyv.setFeature("evmcs", true);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the docs "This feature is exclusive to Intel processors.". So, this could potentially cause issues with non-intel processors.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hyperv on non-intel-like processors is maybe not so big an issue. We can

  1. surround with extra code,
  2. add docs
  3. never mind that possibility
  4. drop this PR
    I am leaning to the higher numbers, here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not about hyper-v, this is about hyper-v emulation on KVM itself. This PR isn't necessary given Vishesh's comments.

@sureshanaparti sureshanaparti changed the title kvm: implement Hyper-V enlightnements correctly kvm: implement Hyper-V enlightenments correctly Jul 23, 2025
@yadvr
Copy link
Copy Markdown
Member Author

yadvr commented Jul 24, 2025

Closing on @vishesh92 's remarks, also the original issue was console slowness which was fixed by other PR.

@yadvr yadvr closed this Jul 24, 2025
@yadvr yadvr deleted the console-optimisations branch July 24, 2025 11:58
@yadvr yadvr restored the console-optimisations branch August 12, 2025 06:46
@yadvr yadvr reopened this Aug 12, 2025
@yadvr yadvr changed the title kvm: implement Hyper-V enlightenments correctly kvm: implement Hyper-V enlightenments correctly to allow running HyperV on KVM Aug 12, 2025
@yadvr
Copy link
Copy Markdown
Member Author

yadvr commented Aug 12, 2025

Still doesn't work :(

@yadvr yadvr closed this Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants