Skip to content

Commit

Permalink
Linstor: Fix migrate primary storage
Browse files Browse the repository at this point in the history
Always use RAW as copy sourceFormat for Linstor devices,
as all images are stored as RAW on Linstor, but we have to
pretend to use qcow2 to be able to use qcow2 as snapshot format.
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 21f3fde commit f83fa2b
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 @@ -1402,7 +1402,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 f83fa2b

Please sign in to comment.