CLOUDSTACK-6788: Add agent property to optionally disable kvmclock on guests

This commit is contained in:
Marcus Sorensen 2014-05-27 16:14:44 -06:00
parent a8140ff58c
commit f3a0d257b8
4 changed files with 43 additions and 13 deletions

View File

@ -129,3 +129,7 @@ domr.scripts.dir=scripts/network/domr/kvm
# vm.memballoon.disable=true
# Disable memory ballooning on vm guests for overcommit, by default overcommit
# feature enables balloon and sets currentMemory to a minimum value.
#
# kvmclock.disable=false
# Some newer linux kernels are incapable of reliably migrating vms with kvmclock
# This is a workaround for the bug, admin can set this to true per-host

View File

@ -447,7 +447,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
protected boolean _noMemBalloon = false;
protected String _guestCpuMode;
protected String _guestCpuModel;
private final Map<String, String> _pifs = new HashMap<String, String>();
protected boolean _noKvmClock;
private final Map <String, String> _pifs = new HashMap<String, String>();
private final Map<String, VmStats> _vmStats = new ConcurrentHashMap<String, VmStats>();
protected boolean _disconnected = true;
@ -800,6 +801,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
value = (String)params.get("host.reserved.mem.mb");
_dom0MinMem = NumbersUtil.parseInt(value, 0) * 1024 * 1024;
value = (String) params.get("kvmclock.disable");
if (Boolean.parseBoolean(value)) {
_noKvmClock = true;
}
LibvirtConnection.initialize(_hypervisorURI);
Connect conn = null;
try {
@ -3724,6 +3730,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
if (vmTO.getOs().startsWith("Windows")) {
clock.setClockOffset(ClockDef.ClockOffset.LOCALTIME);
clock.setTimer("rtc", "catchup", null);
} else if (vmTO.getType() != VirtualMachine.Type.User || isGuestPVEnabled(vmTO.getOs())) {
clock.setTimer("kvmclock", "catchup", null, _noKvmClock);
}
vm.addComp(clock);

View File

@ -242,6 +242,7 @@ public class LibvirtVMDef {
private String _timerName;
private String _tickPolicy;
private String _track;
private boolean _noKvmClock = false;
public ClockDef() {
_offset = ClockOffset.UTC;
@ -257,6 +258,11 @@ public class LibvirtVMDef {
_track = track;
}
public void setTimer(String timerName, String tickPolicy, String track, boolean noKvmClock) {
_noKvmClock = noKvmClock;
setTimer(timerName, tickPolicy, track);
}
@Override
public String toString() {
StringBuilder clockBuilder = new StringBuilder();
@ -268,20 +274,24 @@ public class LibvirtVMDef {
clockBuilder.append(_timerName);
clockBuilder.append("' ");
if (_tickPolicy != null) {
clockBuilder.append("tickpolicy='");
clockBuilder.append(_tickPolicy);
clockBuilder.append("' ");
}
if (_timerName.equals("kvmclock") && _noKvmClock) {
clockBuilder.append("present='no' />");
} else {
if (_tickPolicy != null) {
clockBuilder.append("tickpolicy='");
clockBuilder.append(_tickPolicy);
clockBuilder.append("' ");
}
if (_track != null) {
clockBuilder.append("track='");
clockBuilder.append(_track);
clockBuilder.append("' ");
}
if (_track != null) {
clockBuilder.append("track='");
clockBuilder.append(_track);
clockBuilder.append("' ");
}
clockBuilder.append(">\n");
clockBuilder.append("</timer>\n");
clockBuilder.append(">\n");
clockBuilder.append("</timer>\n");
}
}
clockBuilder.append("</clock>\n");
return clockBuilder.toString();

View File

@ -94,6 +94,8 @@ public class LibvirtComputingResourceTest {
vmStr += "<uuid>b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9</uuid>\n";
vmStr += "<description>" + os + "</description>\n";
vmStr += "<clock offset='utc'>\n";
vmStr += "<timer name='kvmclock' tickpolicy='catchup' >\n";
vmStr += "</timer>\n";
vmStr += "</clock>\n";
vmStr += "<features>\n";
vmStr += "<pae/>\n";
@ -166,6 +168,8 @@ public class LibvirtComputingResourceTest {
vmStr += "<uuid>b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9</uuid>\n";
vmStr += "<description>" + os + "</description>\n";
vmStr += "<clock offset='utc'>\n";
vmStr += "<timer name='kvmclock' tickpolicy='catchup' >\n";
vmStr += "</timer>\n";
vmStr += "</clock>\n";
vmStr += "<features>\n";
vmStr += "<pae/>\n";
@ -236,6 +240,8 @@ public class LibvirtComputingResourceTest {
vmStr += "<uuid>b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9</uuid>\n";
vmStr += "<description>" + os + "</description>\n";
vmStr += "<clock offset='utc'>\n";
vmStr += "<timer name='kvmclock' tickpolicy='catchup' >\n";
vmStr += "</timer>\n";
vmStr += "</clock>\n";
vmStr += "<features>\n";
vmStr += "<pae/>\n";
@ -311,6 +317,8 @@ public class LibvirtComputingResourceTest {
vmStr += "<uuid>b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9</uuid>\n";
vmStr += "<description>" + os + "</description>\n";
vmStr += "<clock offset='utc'>\n";
vmStr += "<timer name='kvmclock' tickpolicy='catchup' >\n";
vmStr += "</timer>\n";
vmStr += "</clock>\n";
vmStr += "<features>\n";
vmStr += "<pae/>\n";