From c01192e76a139c9bd18d6bedef9ed9554dc5cd1e Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Mon, 1 Jun 2020 12:27:59 -0700 Subject: [PATCH] device: Allow to use the predicted 'VmPath' when adding blk devices 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 --- device.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/device.go b/device.go index 3b0307f97..802490d96 100644 --- a/device.go +++ b/device.go @@ -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) }