aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/container-orchestrated-devices/container-device-interface/pkg/cdi/container-edits.go
diff options
context:
space:
mode:
authorEvan Lezar <elezar@nvidia.com>2022-05-03 17:24:15 +0200
committerEvan Lezar <elezar@nvidia.com>2022-08-10 10:49:42 +0200
commit658960c97b0dca06cb81472bc9bd7ff820fc56cf (patch)
tree0bfd231b688acf3c32ae6dae07ef22b9a26ca832 /vendor/github.com/container-orchestrated-devices/container-device-interface/pkg/cdi/container-edits.go
parentc33dc90ace724f920c14e41769ce237f5c5d14ec (diff)
downloadpodman-658960c97b0dca06cb81472bc9bd7ff820fc56cf.tar.gz
podman-658960c97b0dca06cb81472bc9bd7ff820fc56cf.tar.bz2
podman-658960c97b0dca06cb81472bc9bd7ff820fc56cf.zip
build(deps) bump CDI dependency from 0.4.0 to 0.5.0
bump github.com/container-orchestrated-devices/container-device-interface from 0.4.0 to 0.5.0 This requires that the cdi.Registry be instantiated with AutoRefresh disabled for CLI clients. [NO NEW TESTS NEEDED] Signed-off-by: Evan Lezar <elezar@nvidia.com>
Diffstat (limited to 'vendor/github.com/container-orchestrated-devices/container-device-interface/pkg/cdi/container-edits.go')
-rw-r--r--vendor/github.com/container-orchestrated-devices/container-device-interface/pkg/cdi/container-edits.go37
1 files changed, 22 insertions, 15 deletions
diff --git a/vendor/github.com/container-orchestrated-devices/container-device-interface/pkg/cdi/container-edits.go b/vendor/github.com/container-orchestrated-devices/container-device-interface/pkg/cdi/container-edits.go
index 80d88b118..1295f75e9 100644
--- a/vendor/github.com/container-orchestrated-devices/container-device-interface/pkg/cdi/container-edits.go
+++ b/vendor/github.com/container-orchestrated-devices/container-device-interface/pkg/cdi/container-edits.go
@@ -85,11 +85,13 @@ func (e *ContainerEdits) Apply(spec *oci.Spec) error {
}
for _, d := range e.DeviceNodes {
- dev := d.ToOCI()
- if err := fillMissingInfo(&dev); err != nil {
+ dn := DeviceNode{d}
+
+ err := dn.fillMissingInfo()
+ if err != nil {
return err
}
-
+ dev := d.ToOCI()
if dev.UID == nil && spec.Process != nil {
if uid := spec.Process.User.UID; uid > 0 {
dev.UID = &uid
@@ -288,26 +290,31 @@ func ensureOCIHooks(spec *oci.Spec) {
}
// fillMissingInfo fills in missing mandatory attributes from the host device.
-func fillMissingInfo(dev *oci.LinuxDevice) error {
- if dev.Type != "" && (dev.Major != 0 || dev.Type == "p") {
+func (d *DeviceNode) fillMissingInfo() error {
+ if d.HostPath == "" {
+ d.HostPath = d.Path
+ }
+
+ if d.Type != "" && (d.Major != 0 || d.Type == "p") {
return nil
}
- hostDev, err := runc.DeviceFromPath(dev.Path, "rwm")
+
+ hostDev, err := runc.DeviceFromPath(d.HostPath, "rwm")
if err != nil {
- return errors.Wrapf(err, "failed to stat CDI host device %q", dev.Path)
+ return errors.Wrapf(err, "failed to stat CDI host device %q", d.HostPath)
}
- if dev.Type == "" {
- dev.Type = string(hostDev.Type)
+ if d.Type == "" {
+ d.Type = string(hostDev.Type)
} else {
- if dev.Type != string(hostDev.Type) {
- return errors.Errorf("CDI device %q, host type mismatch (%s, %s)",
- dev.Path, dev.Type, string(hostDev.Type))
+ if d.Type != string(hostDev.Type) {
+ return errors.Errorf("CDI device (%q, %q), host type mismatch (%s, %s)",
+ d.Path, d.HostPath, d.Type, string(hostDev.Type))
}
}
- if dev.Major == 0 && dev.Type != "p" {
- dev.Major = hostDev.Major
- dev.Minor = hostDev.Minor
+ if d.Major == 0 && d.Type != "p" {
+ d.Major = hostDev.Major
+ d.Minor = hostDev.Minor
}
return nil