Ensure configdrive path is edited properly during live migration (#6173)

This commit is contained in:
Nicolas Vazquez 2022-03-29 05:09:08 -03:00 committed by GitHub
parent 908f594f00
commit a69ab3b28f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 17 deletions

View File

@ -2722,27 +2722,27 @@ 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();
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();
} else {
return data.getPath();
}
}
return dataPath;
}
public void createVbd(final Connect conn, final VirtualMachineTO vmSpec, final String vmName, final LibvirtVMDef vm) throws InternalErrorException, LibvirtException, URISyntaxException {
final Map<String, String> details = vmSpec.getDetails();
final List<DiskTO> disks = Arrays.asList(vmSpec.getDisks());

View File

@ -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;
}