Skip to content

Commit 46d2fa5

Browse files
committed
가상머신 복제 오류수정
1 parent 147b754 commit 46d2fa5

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2695,8 +2695,19 @@ public Answer createVolumeFromSnapshot(final CopyCommand cmd) {
26952695

26962696
final String snapshotFullPath = snapshot.getPath();
26972697
final int index = snapshotFullPath.lastIndexOf("/");
2698-
final String snapshotPath = snapshotFullPath.substring(0, index);
2699-
final String snapshotName = snapshotFullPath.substring(index + 1);
2698+
final String snapshotPath;
2699+
final String snapshotName;
2700+
if (index >= 0) {
2701+
snapshotPath = snapshotFullPath.substring(0, index);
2702+
snapshotName = snapshotFullPath.substring(index + 1);
2703+
} else {
2704+
if (pool.getPoolType() == StoragePoolType.SharedMountPoint) {
2705+
snapshotPath = pool.getPath();
2706+
snapshotName = snapshotFullPath;
2707+
} else {
2708+
throw new CloudRuntimeException("Invalid snapshot path format: " + snapshotFullPath);
2709+
}
2710+
}
27002711
KVMPhysicalDisk disk = null;
27012712
if (imageStore instanceof NfsTO) {
27022713
disk = createVolumeFromSnapshotOnNFS(cmd, pool, imageStore, volume, snapshotPath, snapshotName);

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10698,7 +10698,7 @@ public Optional<UserVm> cloneVirtualMachine(CloneVMCmd cmd) throws ResourceAlloc
1069810698
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create vm snapshot: " + e.getMessage(), e);
1069910699
}
1070010700

10701-
List<VMSnapshotDetailsVO> listSnapshots = vmSnapshotDetailsDao.findDetails(vmSnapshot.getId(), "kvmStorageSnapshot");
10701+
List<VMSnapshotDetailsVO> listSnapshots = vmSnapshotDetailsDao.findDetails(vmSnapshot.getId(), "kvmFileBasedStorageSnapshot");
1070210702

1070310703
Integer countOfCloneVM = cmd.getCount();
1070410704
for (int cnt = 1; cnt <= countOfCloneVM; cnt++) {

0 commit comments

Comments
 (0)