diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index cdcbf24b92fe..425084e4c9b6 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -2722,25 +2722,25 @@ public String getVolumePath(final Connect conn, final DiskTO volume) throws Libv 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 { diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java index 1ad1802e9499..ab448df3009f 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java @@ -154,7 +154,7 @@ Use VIR_DOMAIN_XML_SECURE (value = 1) prior to v1.0.0. 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 @@ private String getNewVolumePathIfDatastoreHasChanged(LibvirtComputingResource li String newIsoVolumePath = null; if (newDisk != null) { - newIsoVolumePath = libvirtComputingResource.getVolumePath(conn, newDisk); + newIsoVolumePath = libvirtComputingResource.getVolumePath(conn, newDisk, to.isConfigDriveOnHostCache()); } return newIsoVolumePath; }