You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
4.2 KiB
101 lines
4.2 KiB
diff -uNr a/heartbeat/VirtualDomain b/heartbeat/VirtualDomain |
|
--- a/heartbeat/VirtualDomain 2016-03-04 14:41:22.001333979 +0100 |
|
+++ b/heartbeat/VirtualDomain 2016-03-04 14:42:34.516395470 +0100 |
|
@@ -17,12 +17,16 @@ |
|
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs |
|
|
|
# Defaults |
|
+OCF_RESKEY_migration_downtime_default=0 |
|
+OCF_RESKEY_migration_speed_default=0 |
|
OCF_RESKEY_force_stop_default=0 |
|
OCF_RESKEY_autoset_utilization_cpu_default="true" |
|
OCF_RESKEY_autoset_utilization_hv_memory_default="true" |
|
OCF_RESKEY_migrateport_default=$(( 49152 + $(ocf_maybe_random) % 64 )) |
|
OCF_RESKEY_CRM_meta_timeout_default=90000 |
|
|
|
+: ${OCF_RESKEY_migration_downtime=${OCF_RESKEY_migration_downtime_default}} |
|
+: ${OCF_RESKEY_migration_speed=${OCF_RESKEY_migration_speed_default}} |
|
: ${OCF_RESKEY_force_stop=${OCF_RESKEY_force_stop_default}} |
|
: ${OCF_RESKEY_autoset_utilization_cpu=${OCF_RESKEY_autoset_utilization_cpu_default}} |
|
: ${OCF_RESKEY_autoset_utilization_hv_memory=${OCF_RESKEY_autoset_utilization_hv_memory_default}} |
|
@@ -96,6 +100,22 @@ |
|
<content type="string" default="" /> |
|
</parameter> |
|
|
|
+<parameter name="migration_downtime" unique="0" required="0"> |
|
+<longdesc lang="en"> |
|
+Define max downtime during live migration in milliseconds |
|
+</longdesc> |
|
+<shortdesc lang="en">Live migration downtime</shortdesc> |
|
+<content type="integer" default="${OCF_RESKEY_migration_downtime_default}" /> |
|
+</parameter> |
|
+ |
|
+<parameter name="migration_speed" unique="0" required="0"> |
|
+<longdesc lang="en"> |
|
+Define live migration speed per resource in MiB/s |
|
+</longdesc> |
|
+<shortdesc lang="en">Live migration speed</shortdesc> |
|
+<content type="integer" default="${OCF_RESKEY_migration_speed_default}" /> |
|
+</parameter> |
|
+ |
|
<parameter name="migration_network_suffix" unique="0" required="0"> |
|
<longdesc lang="en"> |
|
Use a dedicated migration network. The migration URI is composed by |
|
@@ -562,6 +582,7 @@ |
|
local transport_suffix |
|
local migrateuri |
|
local migrate_opts |
|
+ local migrate_pid |
|
|
|
target_node="$OCF_RESKEY_CRM_meta_migrate_target" |
|
|
|
@@ -586,9 +607,28 @@ |
|
# Scared of that sed expression? So am I. :-) |
|
remoteuri=$(echo ${OCF_RESKEY_hypervisor} | sed -e "s,\(.*\)://[^/:]*\(:\?[0-9]*\)/\(.*\),\1${transport_suffix}://${target_node}\2/\3,") |
|
|
|
+ # Live migration speed limit |
|
+ if [ ${OCF_RESKEY_migration_speed} -ne 0 ]; then |
|
+ ocf_log info "$DOMAIN_NAME: Setting live migration speed limit for $DOMAIN_NAME (using: virsh ${VIRSH_OPTIONS} migrate-setspeed $DOMAIN_NAME ${OCF_RESKEY_migration_speed})." |
|
+ virsh ${VIRSH_OPTIONS} migrate-setspeed $DOMAIN_NAME ${OCF_RESKEY_migration_speed} |
|
+ fi |
|
+ |
|
# OK, we know where to connect to. Now do the actual migration. |
|
- ocf_log info "$DOMAIN_NAME: Starting live migration to ${target_node} (using virsh ${VIRSH_OPTIONS} migrate --live $migrate_opts $DOMAIN_NAME $remoteuri $migrateuri)." |
|
- virsh ${VIRSH_OPTIONS} migrate --live $migrate_opts $DOMAIN_NAME $remoteuri $migrateuri |
|
+ ocf_log info "$DOMAIN_NAME: Starting live migration to ${target_node} (using: virsh ${VIRSH_OPTIONS} migrate --live $migrate_opts $DOMAIN_NAME $remoteuri $migrateuri)." |
|
+ virsh ${VIRSH_OPTIONS} migrate --live $migrate_opts $DOMAIN_NAME $remoteuri $migrateuri & |
|
+ |
|
+ migrate_pid=${!} |
|
+ |
|
+ # Live migration downtime interval |
|
+ # Note: You can set downtime only while live migration is in progress |
|
+ if [ ${OCF_RESKEY_migration_downtime} -ne 0 ]; then |
|
+ sleep 2 |
|
+ ocf_log info "$DOMAIN_NAME: Setting live migration downtime for $DOMAIN_NAME (using: virsh ${VIRSH_OPTIONS} migrate-setmaxdowntime $DOMAIN_NAME ${OCF_RESKEY_migration_downtime})." |
|
+ virsh ${VIRSH_OPTIONS} migrate-setmaxdowntime $DOMAIN_NAME ${OCF_RESKEY_migration_downtime} |
|
+ fi |
|
+ |
|
+ wait ${migrate_pid} |
|
+ |
|
rc=$? |
|
if [ $rc -ne 0 ]; then |
|
ocf_exit_reason "$DOMAIN_NAME: live migration to ${target_node} failed: $rc" |
|
@@ -671,6 +711,18 @@ |
|
return $OCF_ERR_INSTALLED |
|
fi |
|
fi |
|
+ |
|
+ # Check if migration_speed is a decimal value |
|
+ if ! ocf_is_decimal ${OCF_RESKEY_migration_speed}; then |
|
+ ocf_exit_reason "migration_speed has to be a decimal value" |
|
+ return $OCF_ERR_CONFIGURED |
|
+ fi |
|
+ |
|
+ # Check if migration_downtime is a decimal value |
|
+ if ! ocf_is_decimal ${OCF_RESKEY_migration_downtime}; then |
|
+ ocf_exit_reason "migration_downtime has to be a decimal value" |
|
+ return $OCF_ERR_CONFIGURED |
|
+ fi |
|
} |
|
|
|
if [ $# -ne 1 ]; then
|
|
|