File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -758,14 +758,23 @@ def launch_from_arg(cls, arg):
758758
759759 @staticmethod
760760 def cgclassify (pid ):
761-
762- # We dont provide any <controllers>:<path>
763- # so cgclassify uses /etc/cgrules.conf which
764- # we have configured in the spec file.
765- cmd = ["cgclassify" , str (pid )]
766761 try :
767- util .pread2 (cmd )
768- except util .CommandException as e :
762+ # We dont provide any <controllers>:<path>
763+ # so cgclassify uses /etc/cgrules.conf which
764+ # we have configured in the spec file.
765+ cmd = ["cgclassify" , str (pid )]
766+ try :
767+ util .pread2 (cmd )
768+ except util .CommandException as e :
769+ util .logException (e )
770+ # cgroup-v2 path
771+ cmd = ["cgcreate" , "-g" , "cpu:vm.slice/tapdisk" ]
772+ util .pread2 (cmd )
773+ cgroup_slice_dir = os .path .join ("/sys/fs/cgroup" , "vm.slice" , "tapdisk" )
774+ procs_file = os .path .join (cgroup_slice_dir , "cgroup.procs" )
775+ with open (procs_file , 'w' ) as f :
776+ f .write (str (pid ))
777+ except Exception as e :
769778 util .logException (e )
770779
771780 @classmethod
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ def test_cgclassify_normal_call(self, mock_pread2):
4747 def test_cgclassify_exception_swallow (self , mock_log , mock_pread2 ):
4848 mock_pread2 .side_effect = util .CommandException (999 )
4949 blktap2 .Tapdisk .cgclassify (123 )
50- mock_pread2 .assert_called_with (['cgclassify ' , '123 ' ])
50+ mock_pread2 .assert_called_with (['cgcreate ' , '-g' , 'cpu:vm.slice/tapdisk ' ])
5151 self .assertEqual (mock_log .call_count , 1 )
5252
5353 @mock .patch ('sm.blktap2.Tapdisk.cgclassify' )
You can’t perform that action at this time.
0 commit comments