commit 8dc76d54bb231d20f4e9f8a6a80052f1c76aab67
Author: Guido Trotter <ultrotter@google.com>
Date:   Wed Oct 19 18:29:22 2011 +0100

    Revert "Rename utils.mlock to utils.cfunc"
    
    The rename is not needed either, since we're not adding more code as of
    now.
    This reverts commit 57ca011e1cd2681948969724e2646edaac22da28.
    
    Signed-off-by: Guido Trotter <ultrotter@google.com>
    Reviewed-by: Michael Hanselmann <hansmi@google.com>

diff --git a/Makefile.am b/Makefile.am
index 2a513f1..98d8a4f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -273,11 +273,11 @@ pytools_PYTHON = \
 utils_PYTHON = \
 	lib/utils/__init__.py \
 	lib/utils/algo.py \
-	lib/utils/cfunc.py \
 	lib/utils/filelock.py \
 	lib/utils/hash.py \
 	lib/utils/io.py \
 	lib/utils/log.py \
+	lib/utils/mlock.py \
 	lib/utils/nodesetup.py \
 	lib/utils/process.py \
 	lib/utils/retry.py \
@@ -724,11 +724,11 @@ python_tests = \
 	test/ganeti.tools.ensure_dirs_unittest.py \
 	test/ganeti.uidpool_unittest.py \
 	test/ganeti.utils.algo_unittest.py \
-	test/ganeti.utils.cfunc_unittest.py \
 	test/ganeti.utils.filelock_unittest.py \
 	test/ganeti.utils.hash_unittest.py \
 	test/ganeti.utils.io_unittest.py \
 	test/ganeti.utils.log_unittest.py \
+	test/ganeti.utils.mlock_unittest.py \
 	test/ganeti.utils.nodesetup_unittest.py \
 	test/ganeti.utils.process_unittest.py \
 	test/ganeti.utils.retry_unittest.py \
diff --git a/lib/utils/__init__.py b/lib/utils/__init__.py
index 5d332ab..9f7cb24 100644
--- a/lib/utils/__init__.py
+++ b/lib/utils/__init__.py
@@ -43,11 +43,11 @@ from ganeti import constants
 from ganeti import compat
 
 from ganeti.utils.algo import *
-from ganeti.utils.cfunc import *
 from ganeti.utils.filelock import *
 from ganeti.utils.hash import *
 from ganeti.utils.io import *
 from ganeti.utils.log import *
+from ganeti.utils.mlock import *
 from ganeti.utils.nodesetup import *
 from ganeti.utils.process import *
 from ganeti.utils.retry import *
diff --git a/lib/utils/cfunc.py b/lib/utils/cfunc.py
deleted file mode 100644
index ea14d68..0000000
--- a/lib/utils/cfunc.py
+++ /dev/null
@@ -1,77 +0,0 @@
-#
-#
-
-# Copyright (C) 2009, 2010, 2011 Google Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-
-"""Wrapper around mlockall(2).
-
-"""
-
-import os
-import logging
-
-from ganeti import errors
-
-try:
-  # pylint: disable=F0401
-  import ctypes
-except ImportError:
-  ctypes = None
-
-
-# Flags for mlockall() (from bits/mman.h)
-_MCL_CURRENT = 1
-_MCL_FUTURE = 2
-
-
-def Mlockall(_ctypes=ctypes):
-  """Lock current process' virtual address space into RAM.
-
-  This is equivalent to the C call mlockall(MCL_CURRENT|MCL_FUTURE),
-  see mlock(2) for more details. This function requires ctypes module.
-
-  @raises errors.NoCtypesError: if ctypes module is not found
-
-  """
-  if _ctypes is None:
-    raise errors.NoCtypesError()
-
-  try:
-    libc = _ctypes.cdll.LoadLibrary("libc.so.6")
-  except EnvironmentError, err:
-    logging.error("Failure trying to load libc: %s", err)
-    libc = None
-  if libc is None:
-    logging.error("Cannot set memory lock, ctypes cannot load libc")
-    return
-
-  # Some older version of the ctypes module don't have built-in functionality
-  # to access the errno global variable, where function error codes are stored.
-  # By declaring this variable as a pointer to an integer we can then access
-  # its value correctly, should the mlockall call fail, in order to see what
-  # the actual error code was.
-  # pylint: disable=W0212
-  libc.__errno_location.restype = _ctypes.POINTER(_ctypes.c_int)
-
-  if libc.mlockall(_MCL_CURRENT | _MCL_FUTURE):
-    # pylint: disable=W0212
-    logging.error("Cannot set memory lock: %s",
-                  os.strerror(libc.__errno_location().contents.value))
-    return
-
-  logging.debug("Memory lock set")
diff --git a/lib/utils/mlock.py b/lib/utils/mlock.py
new file mode 100644
index 0000000..ea14d68
--- /dev/null
+++ b/lib/utils/mlock.py
@@ -0,0 +1,77 @@
+#
+#
+
+# Copyright (C) 2009, 2010, 2011 Google Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+"""Wrapper around mlockall(2).
+
+"""
+
+import os
+import logging
+
+from ganeti import errors
+
+try:
+  # pylint: disable=F0401
+  import ctypes
+except ImportError:
+  ctypes = None
+
+
+# Flags for mlockall() (from bits/mman.h)
+_MCL_CURRENT = 1
+_MCL_FUTURE = 2
+
+
+def Mlockall(_ctypes=ctypes):
+  """Lock current process' virtual address space into RAM.
+
+  This is equivalent to the C call mlockall(MCL_CURRENT|MCL_FUTURE),
+  see mlock(2) for more details. This function requires ctypes module.
+
+  @raises errors.NoCtypesError: if ctypes module is not found
+
+  """
+  if _ctypes is None:
+    raise errors.NoCtypesError()
+
+  try:
+    libc = _ctypes.cdll.LoadLibrary("libc.so.6")
+  except EnvironmentError, err:
+    logging.error("Failure trying to load libc: %s", err)
+    libc = None
+  if libc is None:
+    logging.error("Cannot set memory lock, ctypes cannot load libc")
+    return
+
+  # Some older version of the ctypes module don't have built-in functionality
+  # to access the errno global variable, where function error codes are stored.
+  # By declaring this variable as a pointer to an integer we can then access
+  # its value correctly, should the mlockall call fail, in order to see what
+  # the actual error code was.
+  # pylint: disable=W0212
+  libc.__errno_location.restype = _ctypes.POINTER(_ctypes.c_int)
+
+  if libc.mlockall(_MCL_CURRENT | _MCL_FUTURE):
+    # pylint: disable=W0212
+    logging.error("Cannot set memory lock: %s",
+                  os.strerror(libc.__errno_location().contents.value))
+    return
+
+  logging.debug("Memory lock set")
diff --git a/test/ganeti.utils.cfunc_unittest.py b/test/ganeti.utils.cfunc_unittest.py
deleted file mode 100755
index 8c5c746..0000000
--- a/test/ganeti.utils.cfunc_unittest.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/python
-#
-
-# Copyright (C) 2010, 2011 Google Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-
-
-"""Script for testing utils.Mlockall
-
-This test is run in a separate process because it changes memory behaviour.
-
-"""
-
-import unittest
-
-from ganeti import utils
-from ganeti import errors
-
-import testutils
-
-
-# WARNING: The following tests modify the memory behaviour at runtime. Don't
-# add unrelated tests here.
-
-
-class TestMlockallWithCtypes(unittest.TestCase):
-  """Whether Mlockall() works if ctypes is present.
-
-  """
-
-  def test(self):
-    if utils.ctypes:
-      utils.Mlockall()
-
-
-class TestMlockallWithNoCtypes(unittest.TestCase):
-  """Whether Mlockall() raises an error if ctypes is not present.
-
-  """
-
-  def test(self):
-    self.assertRaises(errors.NoCtypesError, utils.Mlockall, _ctypes=None)
-
-
-if __name__ == "__main__":
-  testutils.GanetiTestProgram()
diff --git a/test/ganeti.utils.mlock_unittest.py b/test/ganeti.utils.mlock_unittest.py
new file mode 100755
index 0000000..8c5c746
--- /dev/null
+++ b/test/ganeti.utils.mlock_unittest.py
@@ -0,0 +1,60 @@
+#!/usr/bin/python
+#
+
+# Copyright (C) 2010, 2011 Google Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+
+"""Script for testing utils.Mlockall
+
+This test is run in a separate process because it changes memory behaviour.
+
+"""
+
+import unittest
+
+from ganeti import utils
+from ganeti import errors
+
+import testutils
+
+
+# WARNING: The following tests modify the memory behaviour at runtime. Don't
+# add unrelated tests here.
+
+
+class TestMlockallWithCtypes(unittest.TestCase):
+  """Whether Mlockall() works if ctypes is present.
+
+  """
+
+  def test(self):
+    if utils.ctypes:
+      utils.Mlockall()
+
+
+class TestMlockallWithNoCtypes(unittest.TestCase):
+  """Whether Mlockall() raises an error if ctypes is not present.
+
+  """
+
+  def test(self):
+    self.assertRaises(errors.NoCtypesError, utils.Mlockall, _ctypes=None)
+
+
+if __name__ == "__main__":
+  testutils.GanetiTestProgram()
