Merge pull request #6871 from kmjohansen/bugfix/ptmx

runtime: make debug console work with sandbox_cgroup_only
This commit is contained in:
Fabiano Fidêncio
2023-05-23 22:24:51 +02:00
committed by GitHub

View File

@@ -697,6 +697,7 @@ func (s *Sandbox) createResourceController() error {
// Determine if device /dev/null and /dev/urandom exist, and add if they don't // Determine if device /dev/null and /dev/urandom exist, and add if they don't
nullDeviceExist := false nullDeviceExist := false
urandomDeviceExist := false urandomDeviceExist := false
ptmxDeviceExist := false
for _, device := range resources.Devices { for _, device := range resources.Devices {
if device.Type == "c" && device.Major == intptr(1) && device.Minor == intptr(3) { if device.Type == "c" && device.Major == intptr(1) && device.Minor == intptr(3) {
nullDeviceExist = true nullDeviceExist = true
@@ -705,6 +706,10 @@ func (s *Sandbox) createResourceController() error {
if device.Type == "c" && device.Major == intptr(1) && device.Minor == intptr(9) { if device.Type == "c" && device.Major == intptr(1) && device.Minor == intptr(9) {
urandomDeviceExist = true urandomDeviceExist = true
} }
if device.Type == "c" && device.Major == intptr(5) && device.Minor == intptr(2) {
ptmxDeviceExist = true
}
} }
if !nullDeviceExist { if !nullDeviceExist {
@@ -720,6 +725,18 @@ func (s *Sandbox) createResourceController() error {
}...) }...)
} }
// If the hypervisor debug console is enabled and
// sandbox_cgroup_only are configured, then the vmm needs access to
// /dev/ptmx. Add this to the device allowlist if it is not
// already present in the config.
if s.config.HypervisorConfig.Debug && s.config.SandboxCgroupOnly && !ptmxDeviceExist {
// "/dev/ptmx"
resources.Devices = append(resources.Devices, []specs.LinuxDeviceCgroup{
{Type: "c", Major: intptr(5), Minor: intptr(2), Access: rwm, Allow: true},
}...)
}
if spec.Linux.Resources.CPU != nil { if spec.Linux.Resources.CPU != nil {
resources.CPU = &specs.LinuxCPU{ resources.CPU = &specs.LinuxCPU{
Cpus: spec.Linux.Resources.CPU.Cpus, Cpus: spec.Linux.Resources.CPU.Cpus,