Skip to content

Commit

Permalink
respond to PR feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Kathryn Baldauf <[email protected]>
  • Loading branch information
katiewasnothere committed Nov 30, 2021
1 parent 3271c6e commit 80376f8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
6 changes: 3 additions & 3 deletions internal/guest/runtime/hcsv2/spec_devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func devicePathFromPCIPath(pciPath string) (*devices.Device, error) {
// get all host dev devices
hostDevices, err := devices.HostDevices()
if err != nil {
return nil, nil
return nil, err
}

// find corresponding entry in sysfs
Expand All @@ -76,7 +76,7 @@ func devicePathFromPCIPath(pciPath string) (*devices.Device, error) {
case devices.CharDevice:
deviceTypeString = charType
default:
return nil, errors.New("unsupport device type")
return nil, errors.New("unsupported device type")
}

syfsDevPath := fmt.Sprintf(sysfsDevPathFormat, deviceTypeString, major, minor)
Expand All @@ -90,7 +90,7 @@ func devicePathFromPCIPath(pciPath string) (*devices.Device, error) {
}
}

return nil, errors.Errorf("failed to find the device node from sysfs pci path")
return nil, errors.New("failed to find the device node from sysfs pci path")
}

func addLinuxDeviceToSpec(ctx context.Context, hostDevice *devices.Device, spec *oci.Spec, addCgroupDevice bool) {
Expand Down
18 changes: 14 additions & 4 deletions internal/hcsoci/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func getDeviceExtensionPaths(annots map[string]string) ([]string, error) {
func getGPUVHDPath(annot map[string]string) (string, error) {
gpuVHDPath, ok := annot[annotations.GPUVHDPath]
if !ok || gpuVHDPath == "" {
return "", fmt.Errorf("no gpu vhd specified %s", gpuVHDPath)
return "", errors.New("no gpu vhd specified")
}
if _, err := os.Stat(gpuVHDPath); err != nil {
return "", errors.Wrapf(err, "failed to find gpu support vhd %s", gpuVHDPath)
Expand Down Expand Up @@ -110,7 +110,12 @@ func getDeviceExtensions(annotations map[string]string) (*hcsschema.ContainerDef
// Drivers must be installed after the target devices are assigned into the UVM.
// This ordering allows us to guarantee that driver installation on a device in the UVM is completed
// before we attempt to create a container.
func handleAssignedDevicesWindows(ctx context.Context, vm *uvm.UtilityVM, annotations map[string]string, specDevs []specs.WindowsDevice) (resultDevs []specs.WindowsDevice, closers []resources.ResourceCloser, err error) {
func handleAssignedDevicesWindows(
ctx context.Context,
vm *uvm.UtilityVM,
annotations map[string]string,
specDevs []specs.WindowsDevice) (resultDevs []specs.WindowsDevice, closers []resources.ResourceCloser, err error) {

defer func() {
if err != nil {
// best effort clean up allocated resources on failure
Expand Down Expand Up @@ -163,7 +168,12 @@ func handleAssignedDevicesWindows(ctx context.Context, vm *uvm.UtilityVM, annota
//
// For LCOW, drivers must be installed before the target devices are assigned into the UVM so they
// can be linked on arrival.
func handleAssignedDevicesLCOW(ctx context.Context, vm *uvm.UtilityVM, annotations map[string]string, specDevs []specs.WindowsDevice) (resultDevs []specs.WindowsDevice, closers []resources.ResourceCloser, err error) {
func handleAssignedDevicesLCOW(
ctx context.Context,
vm *uvm.UtilityVM,
annotations map[string]string,
specDevs []specs.WindowsDevice) (resultDevs []specs.WindowsDevice, closers []resources.ResourceCloser, err error) {

defer func() {
if err != nil {
// best effort clean up allocated resources on failure
Expand All @@ -183,7 +193,7 @@ func handleAssignedDevicesLCOW(ctx context.Context, vm *uvm.UtilityVM, annotatio
for _, d := range specDevs {
switch d.IDType {
case uvm.VPCIDeviceIDType, uvm.VPCIDeviceIDTypeLegacy, uvm.GPUDeviceIDType:
gpuPresent = d.IDType == uvm.GPUDeviceIDType
gpuPresent = gpuPresent || d.IDType == uvm.GPUDeviceIDType
pciID, index := getDeviceInfoFromPath(d.ID)
vpci, err := vm.AssignDevice(ctx, pciID, index)
if err != nil {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 80376f8

Please sign in to comment.