diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-08-10 15:05:19 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-10 15:05:19 +0000 |
commit | 67e7b2d6e3788c3560a852156a3505f0e2b6c8be (patch) | |
tree | c44ddcea58d212eb309576c52d65a8b3f1f2b05e /vendor/github.com/container-orchestrated-devices/container-device-interface/pkg/cdi/container-edits.go | |
parent | 89ab5c9fab81aaa1800f0da67ae6a10cac7afaa7 (diff) | |
parent | e3f029cb83e1fb3ba79acc4ab8d8c4991e05971e (diff) | |
download | podman-67e7b2d6e3788c3560a852156a3505f0e2b6c8be.tar.gz podman-67e7b2d6e3788c3560a852156a3505f0e2b6c8be.tar.bz2 podman-67e7b2d6e3788c3560a852156a3505f0e2b6c8be.zip |
Merge pull request #15267 from containers/dependabot/go_modules/github.com/container-orchestrated-devices/container-device-interface-0.5.0
build(deps): bump github.com/container-orchestrated-devices/container-device-interface from 0.4.0 to 0.5.0
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.go | 37 |
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 |