Skip to content

Commit 463f7fe

Browse files
committed
CLOUDSTACK-10231: Dettach ISO fails for direct downloaded ISO on KVM
1 parent 072dbc0 commit 463f7fe

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,13 +1102,23 @@ public Answer dettachIso(final DettachCommand cmd) {
11021102
final DiskTO disk = cmd.getDisk();
11031103
final TemplateObjectTO isoTO = (TemplateObjectTO)disk.getData();
11041104
final DataStoreTO store = isoTO.getDataStore();
1105-
if (!(store instanceof NfsTO)) {
1105+
1106+
String dataStoreUrl;
1107+
if (store instanceof NfsTO) {
1108+
NfsTO nfsStore = (NfsTO)store;
1109+
dataStoreUrl = nfsStore.getUrl();
1110+
} else if (store instanceof PrimaryDataStoreTO && ((PrimaryDataStoreTO) store).getPoolType().equals(StoragePoolType.NetworkFilesystem)) {
1111+
//In order to support directly downloaded ISOs
1112+
String psHost = ((PrimaryDataStoreTO) store).getHost();
1113+
String psPath = ((PrimaryDataStoreTO) store).getPath();
1114+
dataStoreUrl = "nfs://" + psHost + File.separator + psPath;
1115+
} else {
11061116
return new AttachAnswer("unsupported protocol");
11071117
}
1108-
final NfsTO nfsStore = (NfsTO)store;
1118+
11091119
try {
11101120
final Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName());
1111-
attachOrDetachISO(conn, cmd.getVmName(), nfsStore.getUrl() + File.separator + isoTO.getPath(), false);
1121+
attachOrDetachISO(conn, cmd.getVmName(), dataStoreUrl + File.separator + isoTO.getPath(), false);
11121122
} catch (final LibvirtException e) {
11131123
return new Answer(cmd, false, e.toString());
11141124
} catch (final URISyntaxException e) {

0 commit comments

Comments
 (0)