Skip to content

kvm: implement Hyper-V enlightenments correctly #11213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 4.20
Choose a base branch
from

Conversation

rohityadavcloud
Copy link
Member

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

@rohityadavcloud rohityadavcloud added this to the 4.20.2 milestone Jul 16, 2025
Signed-off-by: Rohit Yadav <[email protected]>
Copy link

codecov bot commented Jul 16, 2025

Codecov Report

Attention: Patch coverage is 48.38710% with 16 lines in your changes missing coverage. Please review.

Project coverage is 16.16%. Comparing base (c61a5eb) to head (f1510c6).
Report is 33 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 83.33% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.20   #11213      +/-   ##
============================================
+ Coverage     16.14%   16.16%   +0.01%     
- Complexity    13256    13284      +28     
============================================
  Files          5656     5656              
  Lines        497893   498438     +545     
  Branches      60374    60719     +345     
============================================
+ Hits          80394    80558     +164     
- Misses       408539   408934     +395     
+ Partials       8960     8946      -14     
Flag Coverage Δ
uitests 4.00% <ø> (-0.01%) ⬇️
unittests 17.01% <48.38%> (+0.01%) ⬆️

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.

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

@rohityadavcloud
Copy link
Member Author

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

@rohityadavcloud
Copy link
Member Author

@blueorangutan package

hyv.setFeature("reenlightenment", true);
hyv.setFeature("stimer", true);
hyv.setFeature("ipi", true);
hyv.setFeature("evmcs", true);
Copy link
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.

@sureshanaparti sureshanaparti changed the title kvm: implement Hyper-V enlightnements correctly kvm: implement Hyper-V enlightenments correctly Jul 23, 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