Skip to content

Commit 85e2a26

Browse files
committed
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 544255b commit 85e2a26

17 files changed

Lines changed: 46 additions & 30 deletions

File tree

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
@@ -100,7 +100,7 @@ public Answer execute(final PrepareForMigrationCommand command, final LibvirtCom
100100

101101
skipDisconnect = true;
102102

103-
if (!storagePoolMgr.connectPhysicalDisksViaVmSpec(vm)) {
103+
if (!storagePoolMgr.connectPhysicalDisksViaVmSpec(vm, true)) {
104104
return new PrepareForMigrationAnswer(command, "failed to connect physical disks to host");
105105
}
106106

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
@@ -80,7 +80,7 @@ public KVMPhysicalDisk createPhysicalDisk(String volumeUuid, KVMStoragePool pool
8080
}
8181

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

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
@@ -103,7 +103,7 @@ public KVMPhysicalDisk createPhysicalDisk(String name, Storage.ProvisioningType
103103

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

109109
@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
@@ -130,10 +130,10 @@ public boolean connectPhysicalDisk(StoragePoolType type, String poolUuid, String
130130
StorageAdaptor adaptor = getStorageAdaptor(type);
131131
KVMStoragePool pool = adaptor.getStoragePool(poolUuid);
132132

133-
return adaptor.connectPhysicalDisk(volPath, pool, details);
133+
return adaptor.connectPhysicalDisk(volPath, pool, details, false);
134134
}
135135

136-
public boolean connectPhysicalDisksViaVmSpec(VirtualMachineTO vmSpec) {
136+
public boolean connectPhysicalDisksViaVmSpec(VirtualMachineTO vmSpec, boolean isVMMigrate) {
137137
boolean result = false;
138138

139139
final String vmName = vmSpec.getName();
@@ -156,7 +156,7 @@ public boolean connectPhysicalDisksViaVmSpec(VirtualMachineTO vmSpec) {
156156
KVMStoragePool pool = getStoragePool(store.getPoolType(), store.getUuid());
157157
StorageAdaptor adaptor = getStorageAdaptor(pool.getType());
158158

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

161161
if (!result) {
162162
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
@@ -851,7 +851,7 @@ private KVMPhysicalDisk createPhysicalDiskByQemuImg(String name, KVMStoragePool
851851
}
852852

853853
@Override
854-
public boolean connectPhysicalDisk(String name, KVMStoragePool pool, Map<String, String> details) {
854+
public boolean connectPhysicalDisk(String name, KVMStoragePool pool, Map<String, String> details, boolean isVMMigrate) {
855855
// this is for managed storage that needs to prep disks prior to use
856856
return true;
857857
}

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/ScaleIOStorageAdaptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool, Qemu
134134
}
135135

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public KVMPhysicalDisk createPhysicalDisk(String volumeUuid, Storage.Provisionin
8181

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

8787
@Override

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,15 @@ public interface StorageAdaptor {
4242
public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool,
4343
PhysicalDiskFormat format, Storage.ProvisioningType provisioningType, long size);
4444

45-
// given disk path (per database) and pool, prepare disk on host
46-
public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map<String, String> details);
45+
/**
46+
* given disk path (per database) and pool, prepare disk on host
47+
* @param volumePath volume path
48+
* @param pool storage pool the disk is part of
49+
* @param details disk details map
50+
* @param isVMMigrate Indicates if request is while VM is migration
51+
* @return true if connect was a success
52+
*/
53+
public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map<String, String> details, boolean isVMMigrate);
4754

4855
// given disk path (per database) and pool, clean up disk on host
4956
public boolean disconnectPhysicalDisk(String volumePath, KVMStoragePool pool);

0 commit comments

Comments
 (0)