Pearl1594 commented on code in PR #12617:
URL: https://github.com/apache/cloudstack/pull/12617#discussion_r3390404701
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java:
##########
@@ -6820,4 +6827,242 @@ public String getHypervisorPath() {
public String getGuestCpuArch() {
return guestCpuArch;
}
+
+ /**
+ * CLVM volume state for migration operations on source host
+ */
+ public enum ClvmVolumeState {
+ /** Shared mode (-asy) - used before migration to allow both hosts to
access volume */
+ SHARED("-asy", "shared", "Before migration: activating in shared
mode"),
+
+ /** Deactivate (-an) - used after successful migration to release
volume on source */
+ DEACTIVATE("-an", "deactivated", "After successful migration:
deactivating volume"),
+
+ /** Exclusive mode (-aey) - used after failed migration to revert to
original exclusive state */
+ EXCLUSIVE("-aey", "exclusive", "After failed migration: reverting to
exclusive mode");
+
+ private final String lvchangeFlag;
+ private final String description;
+ private final String logMessage;
+
+ ClvmVolumeState(String lvchangeFlag, String description, String
logMessage) {
+ this.lvchangeFlag = lvchangeFlag;
+ this.description = description;
+ this.logMessage = logMessage;
+ }
+
+ public String getLvchangeFlag() {
+ return lvchangeFlag;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getLogMessage() {
+ return logMessage;
+ }
+ }
+
+ public static void modifyClvmVolumesStateForMigration(List<DiskDef> disks,
LibvirtComputingResource resource,
Review Comment:
these methods don't rely on any instance field of LibvirtComputingResource,
so having them static makes sense.
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java:
##########
@@ -6820,4 +6827,242 @@ public String getHypervisorPath() {
public String getGuestCpuArch() {
return guestCpuArch;
}
+
+ /**
+ * CLVM volume state for migration operations on source host
+ */
+ public enum ClvmVolumeState {
+ /** Shared mode (-asy) - used before migration to allow both hosts to
access volume */
+ SHARED("-asy", "shared", "Before migration: activating in shared
mode"),
+
+ /** Deactivate (-an) - used after successful migration to release
volume on source */
+ DEACTIVATE("-an", "deactivated", "After successful migration:
deactivating volume"),
+
+ /** Exclusive mode (-aey) - used after failed migration to revert to
original exclusive state */
+ EXCLUSIVE("-aey", "exclusive", "After failed migration: reverting to
exclusive mode");
+
+ private final String lvchangeFlag;
+ private final String description;
+ private final String logMessage;
+
+ ClvmVolumeState(String lvchangeFlag, String description, String
logMessage) {
+ this.lvchangeFlag = lvchangeFlag;
+ this.description = description;
+ this.logMessage = logMessage;
+ }
+
+ public String getLvchangeFlag() {
+ return lvchangeFlag;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getLogMessage() {
+ return logMessage;
+ }
+ }
+
+ public static void modifyClvmVolumesStateForMigration(List<DiskDef> disks,
LibvirtComputingResource resource,
+ VirtualMachineTO
vmSpec, ClvmVolumeState state) {
+ for (DiskDef disk : disks) {
+ if (isClvmVolume(disk, resource, vmSpec)) {
+ String volumePath = disk.getDiskPath();
+ try {
+ modifyClvmVolumeState(volumePath, state.getLvchangeFlag(),
state.getDescription(), state.getLogMessage());
+ } catch (Exception e) {
+ LOGGER.error("[CLVM Migration] Exception while setting
volume [{}] to {} state: {}",
+ volumePath, state.getDescription(),
e.getMessage(), e);
+ }
+ }
+ }
+ }
+
+ private static void modifyClvmVolumeState(String volumePath, String
lvchangeFlag,
Review Comment:
same as above
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]