Skip to content

Commit 743fcbf

Browse files
rp-dhslove
authored andcommitted
kvm-storage: provide isVMMigrate information to storage plugins (apache#10093)
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 c43a9ad commit 743fcbf

File tree

19 files changed

+48
-32
lines changed

19 files changed

+48
-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
@@ -134,7 +134,7 @@ public Answer execute(final PrepareForMigrationCommand command, final LibvirtCom
134134

135135
skipDisconnect = true;
136136

137-
if (!storagePoolMgr.connectPhysicalDisksViaVmSpec(vm)) {
137+
if (!storagePoolMgr.connectPhysicalDisksViaVmSpec(vm, true)) {
138138
return new PrepareForMigrationAnswer(command, "failed to connect physical disks to host");
139139
}
140140

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
@@ -74,7 +74,7 @@ public Answer execute(final StartCommand command, final LibvirtComputingResource
7474

7575
libvirtComputingResource.createVbd(conn, vmSpec, vmName, vm);
7676

77-
if (!storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec)) {
77+
if (!storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec, false)) {
7878
return new StartAnswer(command, "Failed to connect physical disks to host");
7979
}
8080

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
@@ -84,7 +84,7 @@ public KVMPhysicalDisk createPhysicalDisk(String volumeUuid, KVMStoragePool pool
8484
}
8585

8686
@Override
87-
public boolean connectPhysicalDisk(String volumeUuid, KVMStoragePool pool, Map<String, String> details) {
87+
public boolean connectPhysicalDisk(String volumeUuid, KVMStoragePool pool, Map<String, String> details, boolean isVMMigrate) {
8888
// ex. sudo iscsiadm -m node -T iqn.2012-03.com.test:volume1 -p 192.168.233.10:3260 -o new
8989
Script iScsiAdmCmd = new Script(true, "iscsiadm", 0, logger);
9090

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
@@ -161,10 +161,10 @@ public boolean connectPhysicalDisk(StoragePoolType type, String poolUuid, String
161161
StorageAdaptor adaptor = getStorageAdaptor(type);
162162
KVMStoragePool pool = adaptor.getStoragePool(poolUuid);
163163

164-
return adaptor.connectPhysicalDisk(volPath, pool, details);
164+
return adaptor.connectPhysicalDisk(volPath, pool, details, false);
165165
}
166166

167-
public boolean connectPhysicalDisksViaVmSpec(VirtualMachineTO vmSpec) {
167+
public boolean connectPhysicalDisksViaVmSpec(VirtualMachineTO vmSpec, boolean isVMMigrate) {
168168
boolean result = false;
169169

170170
final String vmName = vmSpec.getName();
@@ -187,7 +187,7 @@ public boolean connectPhysicalDisksViaVmSpec(VirtualMachineTO vmSpec) {
187187
KVMStoragePool pool = getStoragePool(store.getPoolType(), store.getUuid());
188188
StorageAdaptor adaptor = getStorageAdaptor(pool.getType());
189189

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

192192
if (!result) {
193193
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
@@ -1072,7 +1072,7 @@ private KVMPhysicalDisk createPhysicalDiskByQemuImg(String name, KVMStoragePool
10721072
}
10731073

10741074
@Override
1075-
public boolean connectPhysicalDisk(String name, KVMStoragePool pool, Map<String, String> details) {
1075+
public boolean connectPhysicalDisk(String name, KVMStoragePool pool, Map<String, String> details, boolean isVMMigrate) {
10761076
// this is for managed storage that needs to prep disks prior to use
10771077
return true;
10781078
}

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
@@ -97,7 +97,7 @@ public KVMPhysicalDisk createPhysicalDisk(String volumeUuid, KVMStoragePool pool
9797
* creates a nfs storage pool using libvirt
9898
*/
9999
@Override
100-
public boolean connectPhysicalDisk(String volumeUuid, KVMStoragePool pool, Map<String, String> details) {
100+
public boolean connectPhysicalDisk(String volumeUuid, KVMStoragePool pool, Map<String, String> details, boolean isVMMigrate) {
101101

102102
StoragePool sp = null;
103103
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
@@ -182,7 +182,7 @@ public boolean deleteStoragePool(String uuid) {
182182
}
183183

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

188188
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
@@ -181,7 +181,7 @@ public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool, Qemu
181181
return null;
182182
}
183183

184-
if(!connectPhysicalDisk(name, pool, null)) {
184+
if(!connectPhysicalDisk(name, pool, null, false)) {
185185
throw new CloudRuntimeException(String.format("Failed to ensure disk %s was present", name));
186186
}
187187

@@ -224,7 +224,7 @@ public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool, Qemu
224224
}
225225

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

0 commit comments

Comments
 (0)