kvm: Introduce support for -mem-path
authorMiguel Di Ciurcio Filho <miguel.filho@gmail.com>
Tue, 5 Oct 2010 13:35:02 +0000 (10:35 -0300)
committerGuido Trotter <ultrotter@google.com>
Tue, 5 Oct 2010 13:45:10 +0000 (14:45 +0100)
Using hugepages, KVM instances can get a good performance boost. To
activate that, we need to pass the -mem-path argument to KVM along with
the mount point of the hugetlbfs file system on the node.

For the sake of memory availability computation, we use the -mem-prealloc
argument when enabling hugepages, so KVM will reserve all hugepages it
needs when it starts. This avoids allocating an instance on a node that
will not have enough pages in case other instance needs more than what
is available after it boots.

Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

lib/constants.py
lib/hypervisor/hv_kvm.py
man/gnt-instance.sgml

index 17c9a2e..2941c8a 100644 (file)
@@ -558,6 +558,7 @@ HV_KVM_FLAG = "kvm_flag"
 HV_VHOST_NET = "vhost_net"
 HV_KVM_USE_CHROOT = "use_chroot"
 HV_CPU_MASK = "cpu_mask"
+HV_MEM_PATH = "mem_path"
 
 HVS_PARAMETER_TYPES = {
   HV_BOOT_ORDER: VTYPE_STRING,
@@ -594,6 +595,7 @@ HVS_PARAMETER_TYPES = {
   HV_VHOST_NET: VTYPE_BOOL,
   HV_KVM_USE_CHROOT: VTYPE_BOOL,
   HV_CPU_MASK: VTYPE_STRING,
+  HV_MEM_PATH: VTYPE_STRING,
   }
 
 HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
@@ -934,6 +936,7 @@ HVC_DEFAULTS = {
     HV_KVM_FLAG: "",
     HV_VHOST_NET: False,
     HV_KVM_USE_CHROOT: False,
+    HV_MEM_PATH: "",
     },
   HT_FAKE: {
     },
index f18bc69..205e571 100644 (file)
@@ -205,6 +205,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
       hv_base.ParamInSet(False, constants.HT_KVM_FLAG_VALUES),
     constants.HV_VHOST_NET: hv_base.NO_CHECK,
     constants.HV_KVM_USE_CHROOT: hv_base.NO_CHECK,
+    constants.HV_MEM_PATH: hv_base.OPT_DIR_CHECK,
     }
 
   _MIGRATION_STATUS_RE = re.compile('Migration\s+status:\s+(\w+)',
@@ -567,6 +568,11 @@ class KVMHypervisor(hv_base.BaseHypervisor):
         root_append.append('console=ttyS0,38400')
       kvm_cmd.extend(['-append', ' '.join(root_append)])
 
+    mem_path = hvp[constants.HV_MEM_PATH]
+    if mem_path:
+      kvm_cmd.extend(["-mem-path", mem_path])
+      kvm_cmd.extend(["-mem-prealloc"])
+
     mouse_type = hvp[constants.HV_USB_MOUSE]
     vnc_bind_address = hvp[constants.HV_VNC_BIND_ADDRESS]
 
index 9be66b1..560b665 100644 (file)
             </varlistentry>
 
             <varlistentry>
+              <term>mem_path</term>
+              <listitem>
+                <simpara>Valid for the KVM hypervisor.</simpara>
+
+                <simpara>This option passes the -mem-path argument to kvm with
+                the path (on the node) to the mount point of the hugetlbfs
+                file system, along with the -mem-prealloc argument too.
+                </simpara>
+
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
               <term>use_chroot</term>
               <listitem>
                 <simpara>Valid for the KVM hypervisor.</simpara>