Skip to content

Commit e8e0a11

Browse files
committed
가상머신 마이그레이션 시 migrationIp와 VNC graphics IP 분리 적용
1 parent de72433 commit e8e0a11

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2918,6 +2918,9 @@ protected MigrateCommand buildMigrateCommand(VMInstanceVO vmInstance, VirtualMac
29182918
String destIp = StringUtils.isNotBlank(destHost.getMigrationIp())
29192919
? destHost.getMigrationIp()
29202920
: destination.getHost().getPrivateIpAddress();
2921+
if (StringUtils.isBlank(virtualMachineTO.getVncAddr())) {
2922+
virtualMachineTO.setVncAddr(destination.getHost().getPrivateIpAddress());
2923+
}
29212924

29222925
final boolean isWindows = _guestOsCategoryDao.findById(_guestOsDao.findById(vmInstance.getGuestOSId()).getCategoryId()).getName().equalsIgnoreCase("Windows");
29232926
final MigrateCommand migrateCommand = new MigrateCommand(vmInstance.getInstanceName(), destIp, isWindows, virtualMachineTO,

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,9 @@ public Answer execute(final MigrateCommand command, final LibvirtComputingResour
135135

136136
dm = conn.domainLookupByName(vmName);
137137
/*
138-
We replace the private IP address with the address of the destination host.
139-
This is because the VNC listens on the private IP address of the hypervisor,
140-
but that address is of course different on the target host.
141-
142-
MigrateCommand.getDestinationIp() returns the private IP address of the target
143-
hypervisor. So it's safe to use.
138+
We replace the VNC graphics listen address with the VNC address configured for
139+
the target host. This is typically the private IP address of the destination
140+
hypervisor, but it must remain independent from the migration transport IP.
144141
145142
The Domain.migrate method from libvirt supports passing a different XML
146143
description for the instance to be used on the target host.
@@ -156,6 +153,7 @@ Use VIR_DOMAIN_XML_SECURE (value = 1) prior to v1.0.0.
156153
final int xmlFlag = conn.getLibVirVersion() >= 1000000 ? 8 : 1; // 1000000 equals v1.0.0
157154

158155
final String target = command.getDestinationIp();
156+
final String vncTarget = StringUtils.defaultIfBlank(to.getVncAddr(), target);
159157
xmlDesc = dm.getXMLDesc(xmlFlag);
160158
if (logger.isDebugEnabled()) {
161159
logger.debug(String.format("VM [%s] with XML configuration [%s] will be migrated to host [%s].", vmName, xmlDesc, target));
@@ -164,7 +162,7 @@ Use VIR_DOMAIN_XML_SECURE (value = 1) prior to v1.0.0.
164162
// Limit the VNC password in case the length is greater than 8 characters
165163
// Since libvirt version 8 VNC passwords are limited to 8 characters
166164
String vncPassword = org.apache.commons.lang3.StringUtils.truncate(to.getVncPassword(), 8);
167-
xmlDesc = replaceIpForVNCInDescFileAndNormalizePassword(xmlDesc, target, vncPassword, vmName);
165+
xmlDesc = replaceIpForVNCInDescFileAndNormalizePassword(xmlDesc, vncTarget, vncPassword, vmName);
168166

169167
// Replace Config Drive ISO path
170168
String oldIsoVolumePath = getOldVolumePath(disks, vmName);

0 commit comments

Comments
 (0)