Skip to content

Commit 965180d

Browse files
check and set config drive path when it is on host cache
1 parent 2e79237 commit 965180d

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3424,15 +3424,19 @@ public synchronized String attachOrDetachISO(final Connect conn, final String vm
34243424
InternalErrorException {
34253425
final DiskDef iso = new DiskDef();
34263426
if (isAttach && StringUtils.isNotBlank(isoPath) && isoPath.lastIndexOf("/") > 0) {
3427-
final int index = isoPath.lastIndexOf("/");
3428-
final String path = isoPath.substring(0, index);
3429-
final String name = isoPath.substring(index + 1);
3430-
final KVMStoragePool secondaryPool = storagePoolManager.getStoragePoolByURI(path);
3431-
final KVMPhysicalDisk isoVol = secondaryPool.getPhysicalDisk(name);
3432-
final DiskDef.DiskType diskType = getDiskType(isoVol);
3433-
isoPath = isoVol.getPath();
3434-
3435-
iso.defISODisk(isoPath, diskSeq, diskType);
3427+
if (isoPath.startsWith(getConfigPath() + "/" + ConfigDrive.CONFIGDRIVEDIR) && isoPath.contains(vmName)) {
3428+
iso.defISODisk(isoPath, diskSeq, DiskDef.DiskType.FILE);
3429+
} else {
3430+
final int index = isoPath.lastIndexOf("/");
3431+
final String path = isoPath.substring(0, index);
3432+
final String name = isoPath.substring(index + 1);
3433+
final KVMStoragePool storagePool = storagePoolManager.getStoragePoolByURI(path);
3434+
final KVMPhysicalDisk isoVol = storagePool.getPhysicalDisk(name);
3435+
final DiskDef.DiskType diskType = getDiskType(isoVol);
3436+
isoPath = isoVol.getPath();
3437+
3438+
iso.defISODisk(isoPath, diskSeq, diskType);
3439+
}
34363440
} else {
34373441
iso.defISODisk(null, diskSeq, DiskDef.DiskType.FILE);
34383442
}

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ public KVMStoragePool getStoragePoolByURI(String uri) {
287287
URI storageUri = null;
288288

289289
try {
290+
s_logger.debug("Get storage pool by uri: " + uri);
290291
storageUri = new URI(uri);
291292
} catch (URISyntaxException e) {
292293
throw new CloudRuntimeException(e.toString());

0 commit comments

Comments
 (0)