Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2023,6 +2023,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());
Expand Down Expand Up @@ -2109,14 +2122,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();
Expand All @@ -2128,7 +2137,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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,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='");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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;

import junit.framework.TestCase;

Expand Down Expand Up @@ -188,12 +187,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() {
Expand Down