-
Notifications
You must be signed in to change notification settings - Fork 160
add device-remove and device-remove-all option #325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--device -> --device-add
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
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"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be cli.BoolFlag
cmd/oci-runtime-tool/generate.go
Outdated
| } | ||
| } | ||
|
|
||
| if context.IsSet("device-remove-all") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid this will break default output. Maybe fmt.Fprintln(os.Stderr, "") will be better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated, PTAL
1a4edce to
80b1053
Compare
|
@mrunalp @liangchenye PTAL |
Signed-off-by: zhouhao <[email protected]>
Signed-off-by: zhouhao <[email protected]>
Signed-off-by: zhouhao <[email protected]>
Signed-off-by: zhouhao [email protected]