mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
Merge pull request #3231 from najohnsn/no-linux-section
fix createDevices when no Linux section
This commit is contained in:
@@ -678,7 +678,7 @@ func createDevices(spec *specs.Spec, config *configs.Config) ([]*devices.Device,
|
||||
|
||||
next:
|
||||
for _, ad := range AllowedDevices {
|
||||
if ad.Path != "" {
|
||||
if ad.Path != "" && spec.Linux != nil {
|
||||
for _, sd := range spec.Linux.Devices {
|
||||
if sd.Path == ad.Path {
|
||||
continue next
|
||||
|
||||
@@ -546,6 +546,28 @@ func TestSpecconvExampleValidate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSpecconvNoLinuxSection(t *testing.T) {
|
||||
spec := Example()
|
||||
spec.Root.Path = "/"
|
||||
spec.Linux = nil
|
||||
spec.Hostname = ""
|
||||
|
||||
opts := &CreateOpts{
|
||||
CgroupName: "ContainerID",
|
||||
Spec: spec,
|
||||
}
|
||||
|
||||
config, err := CreateLibcontainerConfig(opts)
|
||||
if err != nil {
|
||||
t.Errorf("Couldn't create libcontainer config: %v", err)
|
||||
}
|
||||
|
||||
validator := validate.New()
|
||||
if err := validator.Validate(config); err != nil {
|
||||
t.Errorf("Expected specconv to produce valid container config: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDupNamespaces(t *testing.T) {
|
||||
spec := &specs.Spec{
|
||||
Root: &specs.Root{
|
||||
|
||||
Reference in New Issue
Block a user