Skip to content

Commit b21662f

Browse files
committed
make sure XS report VM state even if there is no running VM on the host.
1 parent 7ce5e5b commit b21662f

5 files changed

Lines changed: 13 additions & 6 deletions

File tree

api/src/org/apache/cloudstack/context/CallContext.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ public static CallContext unregister() {
252252

253253
if (!stack.isEmpty()) {
254254
s_currentContext.set(stack.peek());
255+
} else {
256+
s_currentContext.set(null);
255257
}
256258

257259
return context;

engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3048,7 +3048,7 @@ public boolean processCommands(long agentId, long seq, Command[] cmds) {
30483048
}
30493049

30503050
if(VmJobEnabled.value()) {
3051-
if (ping.getHostVmStateReport() != null && ping.getHostVmStateReport().size() > 0) {
3051+
if (ping.getHostVmStateReport() != null) {
30523052
_syncMgr.processHostVmStatePingReport(agentId, ping.getHostVmStateReport());
30533053
}
30543054
}

engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ public void processHostVmStatePingReport(long hostId, Map<String, HostVmStateRep
6666

6767
private void processReport(long hostId, Map<Long, VirtualMachine.PowerState> translatedInfo) {
6868

69+
if (s_logger.isDebugEnabled())
70+
s_logger.debug("Process VM state report. host: " + hostId + ", number of records in report: " + translatedInfo.size());
71+
6972
for (Map.Entry<Long, VirtualMachine.PowerState> entry : translatedInfo.entrySet()) {
7073

7174
if (s_logger.isDebugEnabled())
@@ -105,6 +108,9 @@ private void processReport(long hostId, Map<Long, VirtualMachine.PowerState> tra
105108
}
106109
}
107110
}
111+
112+
if (s_logger.isDebugEnabled())
113+
s_logger.debug("Done with process of VM state report. host: " + hostId);
108114
}
109115

110116
@Override

framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobExecutionContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public static void setCurrentExecutionContext(AsyncJobExecutionContext currentCo
207207
public static String getOriginJobId() {
208208
AsyncJobExecutionContext context = AsyncJobExecutionContext.getCurrentExecutionContext();
209209
if (context != null && context.getJob() != null)
210-
return "Job-" + context.getJob().getId();
210+
return "" + context.getJob().getId();
211211

212212
return "";
213213
}

plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,9 @@ public boolean equals(String type) {
324324
static {
325325
s_powerStatesTable = new HashMap<Types.VmPowerState, PowerState>();
326326
s_powerStatesTable.put(Types.VmPowerState.HALTED, PowerState.PowerOff);
327-
s_powerStatesTable.put(Types.VmPowerState.PAUSED, PowerState.PowerOn);
327+
s_powerStatesTable.put(Types.VmPowerState.PAUSED, PowerState.PowerOff);
328328
s_powerStatesTable.put(Types.VmPowerState.RUNNING, PowerState.PowerOn);
329-
s_powerStatesTable.put(Types.VmPowerState.SUSPENDED, PowerState.PowerOn);
329+
s_powerStatesTable.put(Types.VmPowerState.SUSPENDED, PowerState.PowerOff);
330330
s_powerStatesTable.put(Types.VmPowerState.UNRECOGNIZED, PowerState.PowerUnknown);
331331
}
332332

@@ -2524,7 +2524,7 @@ protected HashMap<String, HostVmStateReportEntry> getHostVmStateReport(Connectio
25242524
}
25252525

25262526
if (vm_map == null) {
2527-
return null;
2527+
return vmStates;
25282528
}
25292529
for (VM.Record record : vm_map.values()) {
25302530
if (record.isControlDomain || record.isASnapshot || record.isATemplate) {
@@ -4927,7 +4927,6 @@ protected boolean checkSR(Connection conn, SR sr) {
49274927
}
49284928
if (srr.shared) {
49294929
Host host = Host.getByUuid(conn, _host.uuid);
4930-
49314930
boolean found = false;
49324931
for (PBD pbd : pbds) {
49334932
PBD.Record pbdr = pbd.getRecord(conn);

0 commit comments

Comments
 (0)