|
1 | | -// Copyright 2017 Intel Corporation. All Rights Reserved. |
| 1 | +// Copyright 2017-2021 Intel Corporation. All Rights Reserved. |
2 | 2 | // |
3 | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | 4 | // you may not use this file except in compliance with the License. |
@@ -201,9 +201,8 @@ func (dp *DevicePlugin) getDeviceID(pciAddr string) (string, error) { |
201 | 201 | func (dp *DevicePlugin) bindDevice(vfBdf string) error { |
202 | 202 | unbindDevicePath := filepath.Join(dp.pciDeviceDir, vfBdf, driverUnbindSuffix) |
203 | 203 |
|
204 | | - // Unbind from the kernel driver |
205 | | - err := os.WriteFile(unbindDevicePath, []byte(vfBdf), 0600) |
206 | | - if err != nil { |
| 204 | + // Unbind from the kernel driver. IsNotExist means the device is not bound to any driver. |
| 205 | + if err := os.WriteFile(unbindDevicePath, []byte(vfBdf), 0600); !os.IsNotExist(err) { |
207 | 206 | return errors.Wrapf(err, "Unbinding from kernel driver failed for the device %s", vfBdf) |
208 | 207 | } |
209 | 208 | vfdevID, err := dp.getDeviceID(vfBdf) |
@@ -319,7 +318,7 @@ func getCurrentDriver(device string) string { |
319 | 318 | symlink := filepath.Join(device, "driver") |
320 | 319 | driver, err := filepath.EvalSymlinks(symlink) |
321 | 320 | if err != nil { |
322 | | - klog.Warningf("unable to evaluate symlink: %s", symlink) |
| 321 | + klog.Infof("no driver bound to device %q", filepath.Base(device)) |
323 | 322 | return "" |
324 | 323 | } |
325 | 324 | return filepath.Base(driver) |
|
0 commit comments