Skip to content

Commit 6defcc8

Browse files
authored
Applying PR 2870 from upstream. This adds additional hyper-v enlightenments. apache#2870 (#62)
1 parent 6340f0d commit 6defcc8

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,6 +2023,19 @@ protected void setQuotaAndPeriod(VirtualMachineTO vmTO, CpuTuneDef ctd) {
20232023
}
20242024
}
20252025

2026+
protected void enlightenWindowsVm(VirtualMachineTO vmTO, FeaturesDef features) {
2027+
if (vmTO.getOs().contains("Windows PV")) {
2028+
// If OS is Windows PV, then enable the features. Features supported on Windows 2008 and later
2029+
LibvirtVMDef.HyperVEnlightenmentFeatureDef hyv = new LibvirtVMDef.HyperVEnlightenmentFeatureDef();
2030+
hyv.setFeature("relaxed", true);
2031+
hyv.setFeature("vapic", true);
2032+
hyv.setFeature("spinlocks", true);
2033+
hyv.setRetries(8096);
2034+
features.addHyperVFeature(hyv);
2035+
s_logger.info("Enabling KVM Enlightment Features to VM domain " + vmTO.getUuid());
2036+
}
2037+
}
2038+
20262039
public LibvirtVMDef createVMFromSpec(final VirtualMachineTO vmTO) {
20272040
final LibvirtVMDef vm = new LibvirtVMDef();
20282041
vm.setDomainName(vmTO.getName());
@@ -2109,14 +2122,10 @@ So if getMinSpeed() returns null we fall back to getSpeed().
21092122
features.addFeatures("pae");
21102123
features.addFeatures("apic");
21112124
features.addFeatures("acpi");
2112-
//for rhel 6.5 and above, hyperv enlightment feature is added
2113-
/*
2114-
* if (vmTO.getOs().contains("Windows Server 2008") && hostOsVersion != null && ((hostOsVersion.first() == 6 && hostOsVersion.second() >= 5) || (hostOsVersion.first() >= 7))) {
2115-
* LibvirtVMDef.HyperVEnlightenmentFeatureDef hyv = new LibvirtVMDef.HyperVEnlightenmentFeatureDef();
2116-
* hyv.setRelaxed(true);
2117-
* features.addHyperVFeature(hyv);
2118-
* }
2119-
*/
2125+
2126+
//KVM hyperv enlightenment features based on OS Type
2127+
enlightenWindowsVm(vmTO, features);
2128+
21202129
vm.addComp(features);
21212130

21222131
final TermPolicy term = new TermPolicy();
@@ -2128,7 +2137,7 @@ So if getMinSpeed() returns null we fall back to getSpeed().
21282137
final ClockDef clock = new ClockDef();
21292138
if (vmTO.getOs().startsWith("Windows")) {
21302139
clock.setClockOffset(ClockDef.ClockOffset.LOCALTIME);
2131-
clock.setTimer("rtc", "catchup", null);
2140+
clock.setTimer("hypervclock", null, null);
21322141
} else if (vmTO.getType() != VirtualMachine.Type.User || isGuestPVEnabled(vmTO.getOs())) {
21332142
if (_hypervisorLibvirtVersion >= 9 * 1000 + 10) {
21342143
clock.setTimer("kvmclock", null, null, _noKvmClock);

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,8 @@ public String toString() {
379379

380380
if (_timerName.equals("kvmclock") && _noKvmClock) {
381381
clockBuilder.append("present='no' />");
382+
} else if (_timerName.equals("hypervclock")) {
383+
clockBuilder.append("present='yes' />");
382384
} else {
383385
if (_tickPolicy != null) {
384386
clockBuilder.append("tickpolicy='");

plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.ChannelDef;
2525
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef;
2626
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.SCSIDef;
27-
import com.cloud.utils.Pair;
2827

2928
import junit.framework.TestCase;
3029

@@ -188,12 +187,8 @@ public void testHypervEnlightDef() {
188187
assertFalse(defs.contains("relaxed"));
189188
assertFalse(defs.contains("vapic"));
190189
assertFalse(defs.contains("spinlocks"));
191-
assertTrue("Windows Server 2008 R2".contains("Windows Server 2008"));
190+
assertTrue("Windows PV".contains("Windows PV"));
192191

193-
Pair<Integer,Integer> hostOsVersion = new Pair<Integer,Integer>(6,5);
194-
assertTrue((hostOsVersion.first() == 6 && hostOsVersion.second() >= 5) || (hostOsVersion.first() >= 7));
195-
hostOsVersion = new Pair<Integer,Integer>(7,1);
196-
assertTrue((hostOsVersion.first() == 6 && hostOsVersion.second() >= 5) || (hostOsVersion.first() >= 7));
197192
}
198193

199194
public void testRngDef() {

0 commit comments

Comments
 (0)