You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by de...@apache.org on 2013/07/10 14:34:11 UTC
git commit: updated refs/heads/4.2 to 5a67a6f
Updated Branches:
refs/heads/4.2 82e447aa3 -> 5a67a6f1a
CLOUDSTACK-3443: Timeoffset on windows guest not persisted between VM stop and start on XenServer.
The problem was because in cloudstack when a vm is stopped it gets destroyed on the host. For a
windows vm the timeoffset (which can be set by changing the timezone from within the vm) is stored
in the platform:timeoffset attribute of vm record. The information is lost when the vm is destroted.
Made change to read and persist the platform:timeoffset vm attribute when an instance is stopped.
The value is persisted in the user_vm_details table. When the vm is started again the attribute is
set for the vm instance that gets created.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5a67a6f1
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5a67a6f1
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5a67a6f1
Branch: refs/heads/4.2
Commit: 5a67a6f1a23389f672c9dfdcaa907d35a924589e
Parents: 82e447a
Author: Devdeep Singh <de...@gmail.com>
Authored: Wed Jul 10 17:36:06 2013 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Wed Jul 10 17:56:19 2013 +0530
----------------------------------------------------------------------
core/src/com/cloud/agent/api/StopAnswer.java | 13 ++++++++++++-
.../hypervisor/xen/resource/CitrixResourceBase.java | 12 +++++++++++-
.../xen/resource/XenServer56FP1Resource.java | 7 +++++++
server/src/com/cloud/vm/VirtualMachineManagerImpl.java | 10 ++++++++++
4 files changed, 40 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a67a6f1/core/src/com/cloud/agent/api/StopAnswer.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/StopAnswer.java b/core/src/com/cloud/agent/api/StopAnswer.java
index 1111fed..0af2385 100755
--- a/core/src/com/cloud/agent/api/StopAnswer.java
+++ b/core/src/com/cloud/agent/api/StopAnswer.java
@@ -18,19 +18,27 @@ package com.cloud.agent.api;
public class StopAnswer extends RebootAnswer {
Integer vncPort;
+ Integer timeOffset;
protected StopAnswer() {
}
+ public StopAnswer(StopCommand cmd, String details, Integer vncPort, Integer timeOffset, boolean success) {
+ super(cmd, details, success);
+ this.vncPort = vncPort;
+ this.timeOffset = timeOffset;
+ }
+
public StopAnswer(StopCommand cmd, String details, Integer vncPort, boolean success) {
super(cmd, details, success);
this.vncPort = vncPort;
+ this.timeOffset = null;
}
public StopAnswer(StopCommand cmd, String details, boolean success) {
super(cmd, details, success);
vncPort = null;
-
+ timeOffset = null;
}
public StopAnswer(StopCommand cmd, Exception e) {
@@ -42,4 +50,7 @@ public class StopAnswer extends RebootAnswer {
return vncPort;
}
+ public Integer getTimeOffset() {
+ return timeOffset;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a67a6f1/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index 226956c..f475926 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -4131,6 +4131,16 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
try {
if (vm.getPowerState(conn) == VmPowerState.HALTED) {
+ Map<String, String> platform = vm.getPlatform(conn);
+ Integer timeoffset = null;
+ try {
+ if (platform.containsKey("timeoffset")) {
+ timeoffset = Integer.valueOf(platform.get("timeoffset"));
+ }
+ } catch (NumberFormatException e) {
+ s_logger.error("Error while reading the platform:timeoffset field of the instance", e);
+ }
+
Set<VIF> vifs = vm.getVIFs(conn);
List<Network> networks = new ArrayList<Network>();
for (VIF vif : vifs) {
@@ -4151,7 +4161,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
// network might be destroyed by other host
}
}
- return new StopAnswer(cmd, "Stop VM " + vmName + " Succeed", 0, true);
+ return new StopAnswer(cmd, "Stop VM " + vmName + " Succeed", 0, timeoffset, true);
}
} catch (XenAPIException e) {
String msg = "VM destroy failed in Stop " + vmName + " Command due to " + e.toString();
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a67a6f1/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
index 407f069..2cc592d 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
@@ -193,6 +193,13 @@ public class XenServer56FP1Resource extends XenServer56Resource {
vmr.VCPUsMax = 32L;
}
+ String timeoffset = details.get("timeoffset");
+ if (timeoffset != null) {
+ Map<String, String> platform = vmr.platform;
+ platform.put("timeoffset", timeoffset);
+ vmr.platform = platform;
+ }
+
vmr.VCPUsAtStartup = (long) vmSpec.getCpus();
vmr.consoles.clear();
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a67a6f1/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
index d266454..f8db59d 100755
--- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -1181,6 +1181,16 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
stopped = answer.getResult();
if (!stopped) {
throw new CloudRuntimeException("Unable to stop the virtual machine due to " + answer.getDetails());
+ } else {
+ Integer timeoffset = answer.getTimeOffset();
+ if (timeoffset != null) {
+ if (vm.getType() == VirtualMachine.Type.User) {
+ UserVmVO userVm = _userVmDao.findById(vm.getId());
+ _userVmDao.loadDetails(userVm);
+ userVm.setDetail("timeoffset", timeoffset.toString());
+ _userVmDao.saveDetails(userVm);
+ }
+ }
}
vmGuru.finalizeStop(profile, answer);