Skip to content

Commit

Permalink
Linstor: awlays use RAW as copy sourceFormat for Linstor devices
Browse files Browse the repository at this point in the history
Also use .getPath() for resource names, as they are altered after
a primary storage migration.
  • Loading branch information
rp- committed Aug 14, 2024
1 parent 150e7e0 commit 1916e87
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,10 @@ public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name, KVMSt
*/

KVMStoragePool srcPool = disk.getPool();
PhysicalDiskFormat sourceFormat = disk.getFormat();
/* Linstor images are always stored as RAW, but Linstor uses qcow2 in DB,
to support snapshots(backuped) as qcow2 files. */
PhysicalDiskFormat sourceFormat = srcPool.getType() != StoragePoolType.Linstor ?
disk.getFormat() : PhysicalDiskFormat.RAW;
String sourcePath = disk.getPath();

KVMPhysicalDisk newDisk;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ public void copyAsync(DataObject srcData, DataObject dstData, AsyncCompletionCal
VolumeInfo volume = sinfo.getBaseVolume();
deleteSnapshot(
srcData.getDataStore(),
LinstorUtil.RSC_PREFIX + volume.getUuid(),
LinstorUtil.RSC_PREFIX + volume.getPath(),
LinstorUtil.RSC_PREFIX + sinfo.getUuid());
}
res = new CopyCommandResult(null, answer);
Expand Down Expand Up @@ -969,7 +969,7 @@ private Answer copyVolume(DataObject srcData, DataObject dstData) {
VolumeInfo srcVolInfo = (VolumeInfo) srcData;
final StoragePoolVO pool = _storagePoolDao.findById(srcVolInfo.getDataStore().getId());
final DevelopersApi api = LinstorUtil.getLinstorAPI(pool.getHostAddress());
final String rscName = LinstorUtil.RSC_PREFIX + srcVolInfo.getUuid();
final String rscName = LinstorUtil.RSC_PREFIX + srcVolInfo.getPath();

VolumeObjectTO to = (VolumeObjectTO) srcVolInfo.getTO();
// patch source format
Expand Down Expand Up @@ -1082,7 +1082,7 @@ protected Answer copySnapshot(DataObject srcData, DataObject destData) {
options.put("volumeSize", snapshotObject.getBaseVolume().getSize() + "");

try {
final String rscName = LinstorUtil.RSC_PREFIX + snapshotObject.getBaseVolume().getUuid();
final String rscName = LinstorUtil.RSC_PREFIX + snapshotObject.getBaseVolume().getPath();
String snapshotName = setCorrectSnapshotPath(api, rscName, snapshotObject);

CopyCommand cmd = new LinstorBackupSnapshotCommand(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public boolean deleteVMSnapshot(VMSnapshot vmSnapshot) {
final String snapshotName = vmSnapshotVO.getName();
final List<String> failedToDelete = new ArrayList<>();
for (VolumeObjectTO volumeObjectTO : volumeTOs) {
final String rscName = LinstorUtil.RSC_PREFIX + volumeObjectTO.getUuid();
final String rscName = LinstorUtil.RSC_PREFIX + volumeObjectTO.getPath();
String err = linstorDeleteSnapshot(api, rscName, snapshotName);

if (err != null)
Expand Down Expand Up @@ -292,7 +292,7 @@ private boolean revertVMSnapshotOperation(VMSnapshot vmSnapshot, long userVmId)
final String snapshotName = vmSnapshotVO.getName();

for (VolumeObjectTO volumeObjectTO : volumeTOs) {
final String rscName = LinstorUtil.RSC_PREFIX + volumeObjectTO.getUuid();
final String rscName = LinstorUtil.RSC_PREFIX + volumeObjectTO.getPath();
String err = linstorRevertSnapshot(api, rscName, snapshotName);
if (err != null) {
throw new CloudRuntimeException(String.format(
Expand Down

0 comments on commit 1916e87

Please sign in to comment.