Skip to content

Commit c7bd99e

Browse files
committed
kvm-storage: provide isVMMigrate information to storage plugins
Particular Linstor needs can use this information to only allow dual volume access for live migration and not enable it in general, which can and will lead to data corruption if for some reason 2 VMs get started on 2 different hosts.
1 parent f9b1767 commit c7bd99e

File tree

18 files changed

+42
-32
lines changed

18 files changed

+42
-32
lines changed

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public Answer execute(final PrepareForMigrationCommand command, final LibvirtCom
120120

121121
skipDisconnect = true;
122122

123-
if (!storagePoolMgr.connectPhysicalDisksViaVmSpec(vm)) {
123+
if (!storagePoolMgr.connectPhysicalDisksViaVmSpec(vm, true)) {
124124
return new PrepareForMigrationAnswer(command, "failed to connect physical disks to host");
125125
}
126126

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStartCommandWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public Answer execute(final StartCommand command, final LibvirtComputingResource
7777

7878
libvirtComputingResource.createVbd(conn, vmSpec, vmName, vm);
7979

80-
if (!storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec)) {
80+
if (!storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec, false)) {
8181
return new StartAnswer(command, "Failed to connect physical disks to host");
8282
}
8383

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public KVMPhysicalDisk createPhysicalDisk(String volumeUuid, KVMStoragePool pool
7979
}
8080

8181
@Override
82-
public boolean connectPhysicalDisk(String volumeUuid, KVMStoragePool pool, Map<String, String> details) {
82+
public boolean connectPhysicalDisk(String volumeUuid, KVMStoragePool pool, Map<String, String> details, boolean isVMMigrate) {
8383
// ex. sudo iscsiadm -m node -T iqn.2012-03.com.test:volume1 -p 192.168.233.10:3260 -o new
8484
Script iScsiAdmCmd = new Script(true, "iscsiadm", 0, s_logger);
8585

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public KVMPhysicalDisk createPhysicalDisk(String name, Storage.ProvisioningType
106106

107107
@Override
108108
public boolean connectPhysicalDisk(String name, Map<String, String> details) {
109-
return this._storageAdaptor.connectPhysicalDisk(name, this, details);
109+
return this._storageAdaptor.connectPhysicalDisk(name, this, details, false);
110110
}
111111

112112
@Override

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ public boolean connectPhysicalDisk(StoragePoolType type, String poolUuid, String
133133
StorageAdaptor adaptor = getStorageAdaptor(type);
134134
KVMStoragePool pool = adaptor.getStoragePool(poolUuid);
135135

136-
return adaptor.connectPhysicalDisk(volPath, pool, details);
136+
return adaptor.connectPhysicalDisk(volPath, pool, details, false);
137137
}
138138

139-
public boolean connectPhysicalDisksViaVmSpec(VirtualMachineTO vmSpec) {
139+
public boolean connectPhysicalDisksViaVmSpec(VirtualMachineTO vmSpec, boolean isVMMigrate) {
140140
boolean result = false;
141141

142142
final String vmName = vmSpec.getName();
@@ -159,7 +159,7 @@ public boolean connectPhysicalDisksViaVmSpec(VirtualMachineTO vmSpec) {
159159
KVMStoragePool pool = getStoragePool(store.getPoolType(), store.getUuid());
160160
StorageAdaptor adaptor = getStorageAdaptor(pool.getType());
161161

162-
result = adaptor.connectPhysicalDisk(vol.getPath(), pool, disk.getDetails());
162+
result = adaptor.connectPhysicalDisk(vol.getPath(), pool, disk.getDetails(), isVMMigrate);
163163

164164
if (!result) {
165165
s_logger.error("Failed to connect disks via vm spec for vm: " + vmName + " volume:" + vol.toString());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ private KVMPhysicalDisk createPhysicalDiskByQemuImg(String name, KVMStoragePool
10111011
}
10121012

10131013
@Override
1014-
public boolean connectPhysicalDisk(String name, KVMStoragePool pool, Map<String, String> details) {
1014+
public boolean connectPhysicalDisk(String name, KVMStoragePool pool, Map<String, String> details, boolean isVMMigrate) {
10151015
// this is for managed storage that needs to prep disks prior to use
10161016
return true;
10171017
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public KVMPhysicalDisk createPhysicalDisk(String volumeUuid, KVMStoragePool pool
9393
* creates a nfs storage pool using libvirt
9494
*/
9595
@Override
96-
public boolean connectPhysicalDisk(String volumeUuid, KVMStoragePool pool, Map<String, String> details) {
96+
public boolean connectPhysicalDisk(String volumeUuid, KVMStoragePool pool, Map<String, String> details, boolean isVMMigrate) {
9797

9898
StoragePool sp = null;
9999
Connect conn = null;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public boolean deleteStoragePool(String uuid) {
181181
}
182182

183183
@Override
184-
public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map<String, String> details) {
184+
public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map<String, String> details, boolean isVMMigrate) {
185185
LOGGER.info("connectPhysicalDisk called for [" + volumePath + "]");
186186

187187
if (StringUtils.isEmpty(volumePath)) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public KVMPhysicalDisk createPhysicalDisk(String arg0, PhysicalDiskFormat arg1,
7878

7979
@Override
8080
public boolean connectPhysicalDisk(String volumeUuid, Map<String, String> details) {
81-
return storageAdaptor.connectPhysicalDisk(volumeUuid, this, details);
81+
return storageAdaptor.connectPhysicalDisk(volumeUuid, this, details, false);
8282
}
8383

8484
@Override

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool, Qemu
178178
return null;
179179
}
180180

181-
if(!connectPhysicalDisk(name, pool, null)) {
181+
if(!connectPhysicalDisk(name, pool, null, false)) {
182182
throw new CloudRuntimeException(String.format("Failed to ensure disk %s was present", name));
183183
}
184184

@@ -221,7 +221,7 @@ public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool, Qemu
221221
}
222222

223223
@Override
224-
public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map<String, String> details) {
224+
public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map<String, String> details, boolean isMigration) {
225225
if (StringUtils.isEmpty(volumePath) || pool == null) {
226226
LOGGER.error("Unable to connect physical disk due to insufficient data");
227227
throw new CloudRuntimeException("Unable to connect physical disk due to insufficient data");

0 commit comments

Comments
 (0)