Skip to content

Commit 110b37a

Browse files
author
Alex Huang
committed
bug 12040: fixed the problem where if the connection is not retrievable, we cause a classcastexception
Reviewed-by: Anthony
1 parent c6dc4f8 commit 110b37a

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎api/src/com/cloud/agent/api/RebootAnswer.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public RebootAnswer(RebootCommand cmd, String details) {
4545
bytesReceived = null;
4646
}
4747

48+
public RebootAnswer(RebootCommand cmd, Exception e) {
49+
super(cmd, e);
50+
}
51+
4852
public void setBytesReceived(Long bytesReceived) {
4953
this.bytesReceived = bytesReceived;
5054
}

‎api/src/com/cloud/agent/api/StopAnswer.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ public StopAnswer(StopCommand cmd, String details) {
3434

3535
}
3636

37+
public StopAnswer(StopCommand cmd, Exception e) {
38+
super(cmd, e);
39+
}
40+
41+
@Override
3742
public Integer getVncPort() {
3843
return vncPort;
3944
}

‎core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3072,9 +3072,9 @@ protected String callHostPluginAsync(Connection conn, String plugin, String cmd,
30723072

30733073
@Override
30743074
public StopAnswer execute(StopCommand cmd) {
3075-
Connection conn = getConnection();
30763075
String vmName = cmd.getVmName();
30773076
try {
3077+
Connection conn = getConnection();
30783078
Set<VM> vms = VM.getByNameLabel(conn, vmName);
30793079
// stop vm which is running on this host or is in halted state
30803080
Iterator<VM> iter = vms.iterator();
@@ -3190,6 +3190,9 @@ public StopAnswer execute(StopCommand cmd) {
31903190
String msg = "Stop Vm " + vmName + " fail due to " + e.getMessage();
31913191
s_logger.warn(msg, e);
31923192
return new StopAnswer(cmd, msg);
3193+
} catch (Exception e) {
3194+
s_logger.warn("Unable to stop " + vmName + " due to ", e);
3195+
return new StopAnswer(cmd, e);
31933196
}
31943197
return new StopAnswer(cmd, "Stop VM failed");
31953198
}

0 commit comments

Comments
 (0)