KVM: Migration bandwidth and downtime control
authorApollon Oikonomopoulos <apollon@noc.grnet.gr>
Mon, 31 May 2010 11:28:47 +0000 (14:28 +0300)
committerBalazs Lecz <leczb@google.com>
Mon, 31 May 2010 12:16:53 +0000 (13:16 +0100)
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
lib/hypervisor/hv_kvm.py
man/gnt-cluster.sgml
man/gnt-instance.sgml

index e13d82c..2fbc025 100644 (file)
@@ -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 = {
index af04dca..51fa10f 100644 (file)
@@ -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)
 
index 5de8cc1..13f4f7b 100644 (file)
               </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>
index 2cf24af..44dd9ff 100644 (file)
               </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>