Skip to content
Closed
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
26 changes: 26 additions & 0 deletions compute/src/main/java/org/zstack/compute/vm/VmInstanceBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -7033,6 +7033,7 @@ public void handle(final Map data) {
extEmitter.afterMigrateVm(vm, vm.getLastHostUuid(), new NoErrorCompletion(completion) {
@Override
public void done() {
syncVmDevicesAddressInfo(self.getUuid());
completion.success();
}
});
Expand Down Expand Up @@ -7226,6 +7227,7 @@ protected void scripts() {
self.setZoneUuid(spec.getDestHost().getZoneUuid());
}
}.execute());
syncVmDevicesAddressInfo(self.getUuid());
logger.debug(String.format("vm[uuid:%s] is running ..", self.getUuid()));
VmInstanceInventory inv = VmInstanceInventory.valueOf(self);
extEmitter.afterStartVm(inv);
Expand Down Expand Up @@ -7495,6 +7497,9 @@ public void run(FlowTrigger trigger, Map data) {
self.setHypervisorType(spec.getDestHost().getHypervisorType());
self.setRootVolumeUuid(spec.getDestRootVolume().getUuid());
});
if (struct.getStrategy() == VmCreationStrategy.InstantStart) {
syncVmDevicesAddressInfo(self.getUuid());
}
logger.debug(String.format("vm[uuid:%s] is started ..", self.getUuid()));
VmInstanceInventory inv = VmInstanceInventory.valueOf(self);
extEmitter.afterStartNewCreatedVm(inv);
Expand Down Expand Up @@ -7931,6 +7936,7 @@ public void handle(Map data) {
public void done() {
self = changeVmStateInDb(VmInstanceStateEvent.running,
() -> self.setHostUuid(originalCopy.getHostUuid()));
syncVmDevicesAddressInfo(self.getUuid());
VmInstanceInventory inv = VmInstanceInventory.valueOf(self);
extEmitter.afterRebootVm(inv);
new StaticIpOperator().deleteIpChange(self.getUuid());
Expand Down Expand Up @@ -8347,6 +8353,7 @@ protected void resumeVm(final Message msg, Completion completion) {
@Override
public void handle(Map Data) {
self = changeVmStateInDb(VmInstanceStateEvent.running);
syncVmDevicesAddressInfo(self.getUuid());
completion.success();
}
}).error(new FlowErrorHandler(completion) {
Expand Down Expand Up @@ -8467,6 +8474,25 @@ public String getName() {
});
}

private void syncVmDevicesAddressInfo(String vmUuid) {
SyncVmDeviceInfoMsg msg = new SyncVmDeviceInfoMsg();
msg.setVmInstanceUuid(vmUuid);
msg.setHostUuid(self.getHostUuid());
bus.makeTargetServiceIdByResourceUuid(msg, HostConstant.SERVICE_ID, msg.getHostUuid());
bus.send(msg, new CloudBusCallBack(msg) {
@Override
public void run(MessageReply reply) {
if (!reply.isSuccess()) {
logger.warn(String.format("Failed to sync vm device info for vm[uuid:%s], %s",
vmUuid, reply.getError()));
} else {
logger.debug(String.format("Sent SyncVmDeviceInfoMsg for vm[uuid:%s] on host[uuid:%s]",
vmUuid, self.getHostUuid()));
}
}
});
}

private void deleteVmCdRom(String cdRomUuid, Completion completion) {
boolean exist = dbf.isExist(cdRomUuid, VmCdRomVO.class);
if (!exist) {
Expand Down