add device-remove and device-remove-all option#325
add device-remove and device-remove-all option#325Mashimiao merged 3 commits intoopencontainers:masterfrom
Conversation
man/oci-runtime-tool-generate.1.md
Outdated
| *uid*/*gid* is the user/group id of the device file. | ||
| This option can be specified multiple times. | ||
|
|
||
| **--device-remove**=*TYPE:MAJOR:MINOR:PATH[:OPTIONS...]* |
There was a problem hiding this comment.
type:major:minor:path should be enough to identify the device. There is not need to parse the options.
There was a problem hiding this comment.
I think it will be better to add, if only these optional fields are not the same, then will it delete the wrong device?
There was a problem hiding this comment.
I use the whole structure of the comparison, so I think every field is needed.
1f2936e to
1ee61c0
Compare
generate/generate.go
Outdated
| Devices: []rspec.Device{}, | ||
| Devices: []rspec.Device{ | ||
| { | ||
| Path: "/dev/fuse", |
There was a problem hiding this comment.
New() is supposed to generate a config that the runtime-tools maintainers feel is a good default (without knowing anything about the container itself). I don't think that config should contain/dev/fuse unless the user explicitly asks for it.
There was a problem hiding this comment.
Here I want to add a default value to the devices, so that you can better achieve devices-remove and other functions.
You mean to give the assignment value is not good, or value /dev/fuse is not good?
There was a problem hiding this comment.
There's no need to add a value to the default config just so you can test device removal. Test that by using a template config (although we don't have a test suite for the generator at the moment, see #180 for a stub). But the criterion for adding an entry to New() should be “is this a useful part of a generic config?”, and I don't think /dev/fuse passes that bar.
60dc4e1 to
66ed818
Compare
cmd/oci-runtime-tool/generate.go
Outdated
|
|
||
| // addDevice takes the raw string passed with the --device flag, parses it, and add it | ||
| func addDevice(device string, g *generate.Generator) error { | ||
| // parseDevice takes the raw string passed with the --device flag |
cmd/oci-runtime-tool/generate.go
Outdated
| cli.StringSliceFlag{Name: "device", Usage: "specifies a device which must be made available in the container"}, | ||
| cli.StringSliceFlag{Name: "device-add", Usage: "add a device which must be made available in the container"}, | ||
| cli.StringSliceFlag{Name: "device-remove", Usage: "remove a device which must be made available in the container"}, | ||
| cli.StringSliceFlag{Name: "device-remove-all", Usage: "remove all devices which must be made available in the container"}, |
cmd/oci-runtime-tool/generate.go
Outdated
| } | ||
| } | ||
|
|
||
| if context.IsSet("device-remove-all") { |
There was a problem hiding this comment.
change to context.Bool("device-remove-all")
|
generate.go needs |
generate/generate.go
Outdated
| return | ||
| } | ||
| if dev.Type == device.Type && dev.Major == device.Major && dev.Minor == device.Minor { | ||
| fmt.Println("WARNING: The same type, major and minor should not be used for multiple devices.") |
There was a problem hiding this comment.
I'm afraid this will break default output. Maybe fmt.Fprintln(os.Stderr, "") will be better
1a4edce to
80b1053
Compare
|
@mrunalp @liangchenye PTAL |
Signed-off-by: zhouhao <zhouhao@cn.fujitsu.com>
Signed-off-by: zhouhao <zhouhao@cn.fujitsu.com>
Signed-off-by: zhouhao <zhouhao@cn.fujitsu.com>
Signed-off-by: zhouhao zhouhao@cn.fujitsu.com