Skip to content

Commit 60dc4e1

Browse files
author
zhouhao
committed
Verify the added device contents
Signed-off-by: zhouhao <zhouhao@cn.fujitsu.com>
1 parent 529d676 commit 60dc4e1

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

generate/generate.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,16 @@ func (g *Generator) RemoveLinuxNamespace(ns string) error {
918918
func (g *Generator) AddDevice(device rspec.Device) {
919919
g.initSpecLinux()
920920

921+
for i, dev := range g.spec.Linux.Devices {
922+
if dev.Path == device.Path {
923+
g.spec.Linux.Devices[i] = device
924+
return
925+
}
926+
if dev.Type == device.Type && dev.Major == device.Major && dev.Minor == device.Minor {
927+
fmt.Println("WARNING: The same type, major and minor should not be used for multiple devices.")
928+
}
929+
}
930+
921931
g.spec.Linux.Devices = append(g.spec.Linux.Devices, device)
922932
}
923933

0 commit comments

Comments
 (0)