rhtyd closed pull request #2870: KVM HyperV Enlightment for Improved Windows 
Server 2008+ Performance
URL: https://github.com/apache/cloudstack/pull/2870
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
 
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index ed87974cd51..f9dc1922e33 100644
--- 
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ 
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -2016,6 +2016,19 @@ protected void setQuotaAndPeriod(VirtualMachineTO vmTO, 
CpuTuneDef ctd) {
         }
     }
 
+    protected void enlightenWindowsVm(VirtualMachineTO vmTO, FeaturesDef 
features) {
+        if (vmTO.getOs().contains("Windows PV")) {
+            // If OS is Windows PV, then enable the features. Features 
supported on Windows 2008 and later
+            LibvirtVMDef.HyperVEnlightenmentFeatureDef hyv = new 
LibvirtVMDef.HyperVEnlightenmentFeatureDef();
+            hyv.setFeature("relaxed", true);
+            hyv.setFeature("vapic", true);
+            hyv.setFeature("spinlocks", true);
+            hyv.setRetries(8096);
+            features.addHyperVFeature(hyv);
+            s_logger.info("Enabling KVM Enlightment Features to VM domain " + 
vmTO.getUuid());
+        }
+    }
+
     public LibvirtVMDef createVMFromSpec(final VirtualMachineTO vmTO) {
         final LibvirtVMDef vm = new LibvirtVMDef();
         vm.setDomainName(vmTO.getName());
@@ -2101,14 +2114,10 @@ So if getMinSpeed() returns null we fall back to 
getSpeed().
         features.addFeatures("pae");
         features.addFeatures("apic");
         features.addFeatures("acpi");
-        //for rhel 6.5 and above, hyperv enlightment feature is added
-        /*
-         * if (vmTO.getOs().contains("Windows Server 2008") && hostOsVersion 
!= null && ((hostOsVersion.first() == 6 && hostOsVersion.second() >= 5) || 
(hostOsVersion.first() >= 7))) {
-         *    LibvirtVMDef.HyperVEnlightenmentFeatureDef hyv = new 
LibvirtVMDef.HyperVEnlightenmentFeatureDef();
-         *    hyv.setRelaxed(true);
-         *    features.addHyperVFeature(hyv);
-         * }
-         */
+
+        //KVM hyperv enlightenment features based on OS Type
+        enlightenWindowsVm(vmTO, features);
+
         vm.addComp(features);
 
         final TermPolicy term = new TermPolicy();
@@ -2120,7 +2129,7 @@ So if getMinSpeed() returns null we fall back to 
getSpeed().
         final ClockDef clock = new ClockDef();
         if (vmTO.getOs().startsWith("Windows")) {
             clock.setClockOffset(ClockDef.ClockOffset.LOCALTIME);
-            clock.setTimer("rtc", "catchup", null);
+            clock.setTimer("hypervclock", null, null);
         } else if (vmTO.getType() != VirtualMachine.Type.User || 
isGuestPVEnabled(vmTO.getOs())) {
             if (_hypervisorLibvirtVersion >= 9 * 1000 + 10) {
                 clock.setTimer("kvmclock", null, null, _noKvmClock);
diff --git 
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
 
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
index 08ece9a104e..1e49cb58e78 100644
--- 
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
+++ 
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
@@ -370,6 +370,8 @@ public String toString() {
 
                 if (_timerName.equals("kvmclock") && _noKvmClock) {
                     clockBuilder.append("present='no' />");
+                } else if (_timerName.equals("hypervclock")) {
+                    clockBuilder.append("present='yes' />");
                 } else {
                     if (_tickPolicy != null) {
                         clockBuilder.append("tickpolicy='");
diff --git 
a/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java
 
b/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java
index b391b94e740..32effb474d8 100644
--- 
a/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java
+++ 
b/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java
@@ -26,7 +26,6 @@
 import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.ChannelDef;
 import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef;
 import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.SCSIDef;
-import com.cloud.utils.Pair;
 
 public class LibvirtVMDefTest extends TestCase {
 
@@ -155,12 +154,8 @@ public void testHypervEnlightDef() {
         assertFalse(defs.contains("relaxed"));
         assertFalse(defs.contains("vapic"));
         assertFalse(defs.contains("spinlocks"));
-        assertTrue("Windows Server 2008 R2".contains("Windows Server 2008"));
+        assertTrue("Windows PV".contains("Windows PV"));
 
-        Pair<Integer,Integer> hostOsVersion = new Pair<Integer,Integer>(6,5);
-        assertTrue((hostOsVersion.first() == 6 && hostOsVersion.second() >= 5) 
|| (hostOsVersion.first() >= 7));
-        hostOsVersion = new Pair<Integer,Integer>(7,1);
-        assertTrue((hostOsVersion.first() == 6 && hostOsVersion.second() >= 5) 
|| (hostOsVersion.first() >= 7));
     }
 
     public void testRngDef() {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to