Signed-off-by: Emily Bragg <[email protected]>
---
 lib/hypervisor/hv_kvm/__init__.py            | 14 +++++++-------
 test/py/ganeti.hypervisor.hv_kvm_unittest.py | 18 +++++++++---------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/lib/hypervisor/hv_kvm/__init__.py 
b/lib/hypervisor/hv_kvm/__init__.py
index 4a03bd8..e626bbf 100644
--- a/lib/hypervisor/hv_kvm/__init__.py
+++ b/lib/hypervisor/hv_kvm/__init__.py
@@ -898,25 +898,25 @@ class KVMHypervisor(hv_base.BaseHypervisor):
           p.set_cpu_affinity(cpus)
 
   @classmethod
-  def _AssignCpuAffinity(cls, cpu_mask, process_id, thread_dict,
-                         worker_cpu_mask):
+  def _AssignCpuAffinity(cls, cpu_mask, worker_cpu_mask, process_id,
+                         thread_dict):
     """Change CPU affinity for running VM according to given CPU mask.
 
     @param cpu_mask: CPU mask as given by the user. e.g. "0-2,4:all:1,3"
     @type cpu_mask: string
+    @param worker_cpu_mask: CPU mask as given by the user for the worker
+      threads. e.g. "0-2,4"
+    @type worker_cpu_mask: string
     @param process_id: process ID of KVM process. Used to pin entire VM
                        to physical CPUs.
     @type process_id: int
     @param thread_dict: map of virtual CPUs to KVM thread IDs
     @type thread_dict: dict int:int
-    @param worker_cpu_mask: CPU mask as given by the user for the worker
-      threads. e.g. "0-2,4"
-    @type worker_cpu_mask: string
 
     """
     worker_cpu_list = utils.ParseCpuMask(worker_cpu_mask)
     cls._SetProcessAffinity(process_id, worker_cpu_list)
-    
+
     # Convert the string CPU mask to a list of list of ints
     cpu_list = utils.ParseMultiCpuMask(cpu_mask)
     if len(cpu_list) == 1:
@@ -970,7 +970,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     # Get vCPU thread IDs, to be used if need to pin vCPUs separately
     thread_dict = self._GetVcpuThreadIds(instance_name)
     # Run CPU pinning, based on configured mask
-    self._AssignCpuAffinity(cpu_mask, pid, thread_dict, worker_cpu_mask)
+    self._AssignCpuAffinity(cpu_mask, worker_cpu_mask, pid, thread_dict)
 
   def ListInstances(self, hvparams=None):
     """Get the list of running instances.
diff --git a/test/py/ganeti.hypervisor.hv_kvm_unittest.py 
b/test/py/ganeti.hypervisor.hv_kvm_unittest.py
index c8bd838..c7a53b5 100755
--- a/test/py/ganeti.hypervisor.hv_kvm_unittest.py
+++ b/test/py/ganeti.hypervisor.hv_kvm_unittest.py
@@ -630,7 +630,7 @@ class TestKvmCpuPinning(testutils.GanetiTestCase):
     self.MockOut(mock.patch(kvm_class + '._GetVcpuThreadIds',
                             return_value=[1, 3, 5, 2, 4, 0 ]))
     self.params = constants.HVC_DEFAULTS[constants.HT_KVM].copy()
-               
+
   def testCpuPinningDefault(self):
     mock_process = mock.MagicMock()
     cpu_mask = self.params['cpu_mask']
@@ -638,7 +638,7 @@ class TestKvmCpuPinning(testutils.GanetiTestCase):
     hypervisor = hv_kvm.KVMHypervisor()
     with mock.patch('psutil.Process', return_value=mock_process):
       hypervisor._ExecuteCpuAffinity('test_instance', cpu_mask, 
worker_cpu_mask)
-    
+
     self.assertEqual(mock_process.set_cpu_affinity.call_count, 1)
     self.assertEqual(mock_process.set_cpu_affinity.call_args_list[0],
                      mock.call(range(0,12)))
@@ -649,16 +649,16 @@ class TestKvmCpuPinning(testutils.GanetiTestCase):
     mock_process.set_cpu_affinity().return_value = True
     mock_process.get_children.return_value = []
     mock_process.reset_mock()
-    
+
     cpu_mask = "1:2:4:5:10:15-17"
     worker_cpu_mask = self.params['worker_cpu_mask']
     hypervisor = hv_kvm.KVMHypervisor()
-    
+
     # This is necessary so that it provides the same object each time instead 
of
     # overwriting it each time.
     def get_mock_process(unused_pid):
       return mock_process
-    
+
     with mock.patch('psutil.Process', get_mock_process):
       hypervisor._ExecuteCpuAffinity('test_instance', cpu_mask, 
worker_cpu_mask)
       self.assertEqual(mock_process.set_cpu_affinity.call_count, 7)
@@ -666,21 +666,21 @@ class TestKvmCpuPinning(testutils.GanetiTestCase):
                        mock.call(range(0,12)))
       self.assertEqual(mock_process.set_cpu_affinity.call_args_list[6],
                        mock.call([15, 16, 17]))
-      
+
   def testCpuPinningEntireInstance(self):
     mock_process = mock.MagicMock()
     mock_process.set_cpu_affinity = mock.MagicMock()
     mock_process.set_cpu_affinity().return_value = True
     mock_process.get_children.return_value = []
     mock_process.reset_mock()
-    
+
     cpu_mask = "4"
     worker_cpu_mask = "5"
     hypervisor = hv_kvm.KVMHypervisor()
-    
+
     def get_mock_process(unused_pid):
       return mock_process
-    
+
     with mock.patch('psutil.Process', get_mock_process):
       hypervisor._ExecuteCpuAffinity('test_instance', cpu_mask, 
worker_cpu_mask)
       self.assertEqual(mock_process.set_cpu_affinity.call_count, 7)
-- 
1.9.1

Reply via email to