From e43d4f9f0207b8eb420b14b6c423ce2b0ee70517 Mon Sep 17 00:00:00 2001 From: Apollon Oikonomopoulos <apollon@noc.grnet.gr> Date: Mon, 31 May 2010 14:28:47 +0300 Subject: [PATCH] KVM: Migration bandwidth and downtime control Introduce 2 new hypervisor options, migration_bandwidth and migration_downtime and implement KVM migration bandwidth and downtime control. migration_bandwidth controls KVM's maximal bandwidth during migration, in MiB/s. Default value is 32 MiB/s, same as KVM's internal default. This option is a global hypervisor option. migration_downtime sets the amount of time (in ms) a KVM instance is allowed to freeze while copying memory pages. This is useful when migrating busy guests, as KVM's internal default of 30ms is too low for the page-copying algorithm to converge. This is a per-instance option, with a default of 30ms, same as KVM's internal default. Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr> Signed-off-by: Balazs Lecz <leczb@google.com> Reviewed-by: Balazs Lecz <leczb@google.com> --- lib/constants.py | 7 +++++++ lib/hypervisor/hv_kvm.py | 10 ++++++++++ man/gnt-cluster.sgml | 15 +++++++++++++++ man/gnt-instance.sgml | 18 ++++++++++++++++++ 4 files changed, 50 insertions(+) diff --git a/lib/constants.py b/lib/constants.py index e13d82c97..2fbc02575 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -434,6 +434,8 @@ HV_USB_MOUSE = "usb_mouse" HV_DEVICE_MODEL = "device_model" HV_INIT_SCRIPT = "init_script" HV_MIGRATION_PORT = "migration_port" +HV_MIGRATION_BANDWIDTH = "migration_bandwidth" +HV_MIGRATION_DOWNTIME = "migration_downtime" HV_USE_LOCALTIME = "use_localtime" HV_DISK_CACHE = "disk_cache" HV_SECURITY_MODEL = "security_model" @@ -465,6 +467,8 @@ HVS_PARAMETER_TYPES = { HV_DEVICE_MODEL: VTYPE_STRING, HV_INIT_SCRIPT: VTYPE_STRING, HV_MIGRATION_PORT: VTYPE_INT, + HV_MIGRATION_BANDWIDTH: VTYPE_INT, + HV_MIGRATION_DOWNTIME: VTYPE_INT, HV_USE_LOCALTIME: VTYPE_BOOL, HV_DISK_CACHE: VTYPE_STRING, HV_SECURITY_MODEL: VTYPE_STRING, @@ -732,6 +736,8 @@ HVC_DEFAULTS = { HV_DISK_TYPE: HT_DISK_PARAVIRTUAL, HV_USB_MOUSE: '', HV_MIGRATION_PORT: 8102, + HV_MIGRATION_BANDWIDTH: 32, # MiB/s + HV_MIGRATION_DOWNTIME: 30, # ms HV_USE_LOCALTIME: False, HV_DISK_CACHE: HT_CACHE_DEFAULT, HV_SECURITY_MODEL: HT_SM_NONE, @@ -748,6 +754,7 @@ HVC_DEFAULTS = { HVC_GLOBALS = frozenset([ HV_MIGRATION_PORT, + HV_MIGRATION_BANDWIDTH, ]) BEC_DEFAULTS = { diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index af04dcacb..51fa10f22 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -78,6 +78,8 @@ class KVMHypervisor(hv_base.BaseHypervisor): constants.HV_USB_MOUSE: hv_base.ParamInSet(False, constants.HT_KVM_VALID_MOUSE_TYPES), constants.HV_MIGRATION_PORT: hv_base.NET_PORT_CHECK, + constants.HV_MIGRATION_BANDWIDTH: hv_base.NO_CHECK, + constants.HV_MIGRATION_DOWNTIME: hv_base.NO_CHECK, constants.HV_USE_LOCALTIME: hv_base.NO_CHECK, constants.HV_DISK_CACHE: hv_base.ParamInSet(True, constants.HT_VALID_CACHE_TYPES), @@ -811,6 +813,14 @@ class KVMHypervisor(hv_base.BaseHypervisor): if not live: self._CallMonitorCommand(instance_name, 'stop') + migrate_command = ('migrate_set_speed %dm' % + instance.hvparams[constants.HV_MIGRATION_BANDWIDTH]) + self._CallMonitorCommand(instance_name, migrate_command) + + migrate_command = ('migrate_set_downtime %dms' % + instance.hvparams[constants.HV_MIGRATION_DOWNTIME]) + self._CallMonitorCommand(instance_name, migrate_command) + migrate_command = 'migrate -d tcp:%s:%s' % (target, port) self._CallMonitorCommand(instance_name, migrate_command) diff --git a/man/gnt-cluster.sgml b/man/gnt-cluster.sgml index 5de8cc116..13f4f7bb6 100644 --- a/man/gnt-cluster.sgml +++ b/man/gnt-cluster.sgml @@ -419,6 +419,21 @@ </para> </listitem> </varlistentry> + <varlistentry> + <term>migration_bandwidth</term> + <listitem> + <simpara>Valid for the KVM hypervisor.</simpara> + + <para> + This option specifies the maximum bandwidth that KVM will + use for instance live migrations. The value is in MiB/s. + </para> + + <simpara>This option is only effective with kvm versions >= 78 + and qemu-kvm versions >= 0.10.0. + </simpara> + </listitem> + </varlistentry> </variablelist> </para> diff --git a/man/gnt-instance.sgml b/man/gnt-instance.sgml index 2cf24af14..44dd9ffea 100644 --- a/man/gnt-instance.sgml +++ b/man/gnt-instance.sgml @@ -658,6 +658,24 @@ </listitem> </varlistentry> + <varlistentry> + <term>migration_downtime</term> + <listitem> + <simpara>Valid for the KVM hypervisor.</simpara> + + <simpara>The maximum amount of time (in ms) a KVM instance is + allowed to be frozen during a live migration, in order to copy + dirty memory pages. Default value is 30ms, but you may need to + increase this value for busy instances. + </simpara> + + <simpara>This option is only effective with kvm versions >= 87 + and qemu-kvm versions >= 0.11.0. + </simpara> + + </listitem> + </varlistentry> + </variablelist> </para> -- GitLab