Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
device: Allow to use the predicted 'VmPath' when adding blk devices
Browse files Browse the repository at this point in the history
In case the 'Id' (a.k.a 'PCIAdrr') field is not set for the input block
device, we reply on the predicted 'VmPath' set by the kata-runtime to
locate the blk device in the guest.

Fixes: #789

Signed-off-by: Bo Chen <[email protected]>
  • Loading branch information
likebreath committed Jun 4, 2020
1 parent 906f7e2 commit c01192e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions device.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,15 @@ func virtioBlkCCWDeviceHandler(ctx context.Context, device pb.Device, spec *pb.S
// Here, bridgeAddr is the address at which the brige is attached on the root bus,
// while deviceAddr is the address at which the device is attached on the bridge.
func virtioBlkDeviceHandler(_ context.Context, device pb.Device, spec *pb.Spec, s *sandbox) error {
// Get the device node path based on the PCI device address
devPath, err := getPCIDeviceName(s, device.Id)
if err != nil {
return err
// When "Id (PCIAddr)" is not set, we allow to use the predicted "VmPath" passed from kata-runtime
if device.Id != "" {
// Get the device node path based on the PCI device address
devPath, err := getPCIDeviceName(s, device.Id)
if err != nil {
return err
}
device.VmPath = devPath
}
device.VmPath = devPath

return updateSpecDeviceList(device, spec)
}
Expand Down

0 comments on commit c01192e

Please sign in to comment.