fix locking at vol/vm creation

This commit is contained in:
Pearl Dsilva 2026-02-23 12:00:53 -05:00
parent 82d6edd4bb
commit 7b5af5e6ca
1 changed files with 0 additions and 30 deletions

View File

@ -1206,12 +1206,6 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
volName = vol.getName();
volAllocation = vol.getInfo().allocation;
volCapacity = vol.getInfo().capacity;
// For CLVM volumes, activate in shared mode so all cluster hosts can access it
if (pool.getType() == StoragePoolType.CLVM) {
logger.info("Activating CLVM volume {} in shared mode for cluster-wide access", volPath);
activateClvmVolumeInSharedMode(volPath);
}
} catch (LibvirtException e) {
throw new CloudRuntimeException(e.toString());
}
@ -1223,30 +1217,6 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
return disk;
}
/**
* Activates a CLVM volume in shared mode so all hosts in the cluster can access it.
* This is necessary after volume creation since libvirt creates LVs with exclusive activation by default.
*
* @param volumePath The full path to the LV (e.g., /dev/vgname/volume-path)
*/
private void activateClvmVolumeInSharedMode(String volumePath) {
try {
Script cmd = new Script("lvchange", 5000, logger);
cmd.add("-asy"); // Activate in shared mode
cmd.add(volumePath);
String result = cmd.execute();
if (result != null) {
logger.error("Failed to activate CLVM volume {} in shared mode. Result: {}", volumePath, result);
throw new CloudRuntimeException("Failed to activate CLVM volume in shared mode: " + result);
}
logger.info("Successfully activated CLVM volume {} in shared mode", volumePath);
} catch (Exception e) {
logger.error("Exception while activating CLVM volume {} in shared mode: {}", volumePath, e.getMessage(), e);
throw new CloudRuntimeException("Failed to activate CLVM volume in shared mode: " + e.getMessage(), e);
}
}
private KVMPhysicalDisk createPhysicalDiskByQemuImg(String name, KVMStoragePool pool, PhysicalDiskFormat format, Storage.ProvisioningType provisioningType, long size,
byte[] passphrase) {