• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kubevirt / kubevirt / 918c2858-31bd-4c0e-ad1a-cde8d851acc7

03 Mar 2026 12:56PM UTC coverage: 71.395% (+0.02%) from 71.38%
918c2858-31bd-4c0e-ad1a-cde8d851acc7

push

prow

web-flow
Merge pull request #16836 from kaizentm/multihypervisor/3-handler

Decouple virt-handler from KVM hypervisor

82 of 356 new or added lines in 14 files covered. (23.03%)

7 existing lines in 4 files now uncovered.

75647 of 105955 relevant lines covered (71.4%)

576.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/pkg/hypervisor/common/process.go
1
/*
2
 * This file is part of the KubeVirt project
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 *
16
 * Copyright The KubeVirt Authors.
17
 *
18
 */
19

20
package common
21

22
import (
23
        "fmt"
24
        "strings"
25
        "unsafe"
26

27
        "github.com/mitchellh/go-ps"
28
        "golang.org/x/sys/unix"
29
)
30

31
// childProcesses given a list of processes, it returns the ones that are children
32
// of the given PID.
33
func childProcesses(processes []ps.Process, pid int) []ps.Process {
6✔
34
        var childProcesses []ps.Process
6✔
35
        for _, process := range processes {
25✔
36
                if process.PPid() == pid {
26✔
37
                        childProcesses = append(childProcesses, process)
7✔
38
                }
7✔
39
        }
40

41
        return childProcesses
6✔
42
}
43

44
// lookupProcessByExecutablePrefix given list of processes, it return the first occurrence
45
// of a process with the given executable prefix.
46
func lookupProcessByExecutablePrefix(processes []ps.Process, execPrefix string) ps.Process {
10✔
47
        if execPrefix == "" {
12✔
48
                return nil
2✔
49
        }
2✔
50
        for _, process := range processes {
18✔
51
                if strings.HasPrefix(process.Executable(), execPrefix) {
14✔
52
                        return process
4✔
53
                }
4✔
54
        }
55

56
        return nil
4✔
57
}
58

59
// SetProcessMemoryLockRLimit Adjusts process MEMLOCK
60
// soft-limit (current) and hard-limit (max) to the given size.
NEW
61
func SetProcessMemoryLockRLimit(pid int, size int64) error {
×
NEW
62
        // standard golang libraries don't provide API to set runtime limits
×
NEW
63
        // for other processes, so we have to directly call to kernel
×
NEW
64
        rlimit := unix.Rlimit{
×
NEW
65
                Cur: uint64(size),
×
NEW
66
                Max: uint64(size),
×
NEW
67
        }
×
NEW
68
        _, _, errno := unix.RawSyscall6(unix.SYS_PRLIMIT64,
×
NEW
69
                uintptr(pid),
×
NEW
70
                uintptr(unix.RLIMIT_MEMLOCK),
×
NEW
71
                uintptr(unsafe.Pointer(&rlimit)), // #nosec used in unix RawSyscall6
×
NEW
72
                0, 0, 0)
×
NEW
73
        if errno != 0 {
×
NEW
74
                return fmt.Errorf("error setting prlimit: %v", errno)
×
NEW
75
        }
×
76

NEW
77
        return nil
×
78
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc