mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
Ensure configdrive path is edited properly during live migration (#6173)
This commit is contained in:
parent
908f594f00
commit
a69ab3b28f
@ -2722,25 +2722,25 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
public String getVolumePath(final Connect conn, final DiskTO volume, boolean diskOnHostCache) throws LibvirtException, URISyntaxException {
|
||||
final DataTO data = volume.getData();
|
||||
final DataStoreTO store = data.getDataStore();
|
||||
final String dataPath = data.getPath();
|
||||
|
||||
if (volume.getType() == Volume.Type.ISO && data.getPath() != null && (store instanceof NfsTO ||
|
||||
store instanceof PrimaryDataStoreTO && data instanceof TemplateObjectTO && !((TemplateObjectTO) data).isDirectDownload())) {
|
||||
|
||||
if (data.getPath().startsWith(ConfigDrive.CONFIGDRIVEDIR) && diskOnHostCache) {
|
||||
String configDrivePath = getConfigPath() + "/" + data.getPath();
|
||||
return configDrivePath;
|
||||
if (volume.getType() == Volume.Type.ISO && dataPath != null) {
|
||||
if (dataPath.startsWith(ConfigDrive.CONFIGDRIVEDIR) && diskOnHostCache) {
|
||||
return getConfigPath() + "/" + data.getPath();
|
||||
}
|
||||
|
||||
final String isoPath = store.getUrl().split("\\?")[0] + File.separator + data.getPath();
|
||||
final int index = isoPath.lastIndexOf("/");
|
||||
final String path = isoPath.substring(0, index);
|
||||
final String name = isoPath.substring(index + 1);
|
||||
final KVMStoragePool secondaryPool = _storagePoolMgr.getStoragePoolByURI(path);
|
||||
final KVMPhysicalDisk isoVol = secondaryPool.getPhysicalDisk(name);
|
||||
return isoVol.getPath();
|
||||
} else {
|
||||
return data.getPath();
|
||||
if (store instanceof NfsTO || store instanceof PrimaryDataStoreTO && data instanceof TemplateObjectTO && !((TemplateObjectTO) data).isDirectDownload()) {
|
||||
final String isoPath = store.getUrl().split("\\?")[0] + File.separator + dataPath;
|
||||
final int index = isoPath.lastIndexOf("/");
|
||||
final String path = isoPath.substring(0, index);
|
||||
final String name = isoPath.substring(index + 1);
|
||||
final KVMStoragePool secondaryPool = _storagePoolMgr.getStoragePoolByURI(path);
|
||||
final KVMPhysicalDisk isoVol = secondaryPool.getPhysicalDisk(name);
|
||||
return isoVol.getPath();
|
||||
}
|
||||
}
|
||||
|
||||
return dataPath;
|
||||
}
|
||||
|
||||
public void createVbd(final Connect conn, final VirtualMachineTO vmSpec, final String vmName, final LibvirtVMDef vm) throws InternalErrorException, LibvirtException, URISyntaxException {
|
||||
|
||||
@ -154,7 +154,7 @@ public final class LibvirtMigrateCommandWrapper extends CommandWrapper<MigrateCo
|
||||
String oldIsoVolumePath = getOldVolumePath(disks, vmName);
|
||||
String newIsoVolumePath = getNewVolumePathIfDatastoreHasChanged(libvirtComputingResource, conn, to);
|
||||
if (newIsoVolumePath != null && !newIsoVolumePath.equals(oldIsoVolumePath)) {
|
||||
s_logger.debug("Editing mount path");
|
||||
s_logger.debug(String.format("Editing mount path of iso from %s to %s", oldIsoVolumePath, newIsoVolumePath));
|
||||
xmlDesc = replaceDiskSourceFile(xmlDesc, newIsoVolumePath, vmName);
|
||||
}
|
||||
// delete the metadata of vm snapshots before migration
|
||||
@ -569,7 +569,7 @@ public final class LibvirtMigrateCommandWrapper extends CommandWrapper<MigrateCo
|
||||
|
||||
String newIsoVolumePath = null;
|
||||
if (newDisk != null) {
|
||||
newIsoVolumePath = libvirtComputingResource.getVolumePath(conn, newDisk);
|
||||
newIsoVolumePath = libvirtComputingResource.getVolumePath(conn, newDisk, to.isConfigDriveOnHostCache());
|
||||
}
|
||||
return newIsoVolumePath;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user