@@ -13,7 +13,6 @@ import (
1313 "strings"
1414 "syscall"
1515
16- "github.com/kata-containers/agent/pkg/uevent"
1716 pb "github.com/kata-containers/agent/protocols/grpc"
1817 "github.com/sirupsen/logrus"
1918 "golang.org/x/sys/unix"
@@ -184,7 +183,7 @@ func removeMounts(mounts []string) error {
184183
185184// storageHandler is the type of callback to be defined to handle every
186185// type of storage driver.
187- type storageHandler func (storage pb.Storage ) (string , error )
186+ type storageHandler func (storage pb.Storage , s * sandbox ) (string , error )
188187
189188// storageHandlerList lists the supported drivers.
190189var storageHandlerList = map [string ]storageHandler {
@@ -194,27 +193,25 @@ var storageHandlerList = map[string]storageHandler{
194193}
195194
196195// virtio9pStorageHandler handles the storage for 9p driver.
197- func virtio9pStorageHandler (storage pb.Storage ) (string , error ) {
196+ func virtio9pStorageHandler (storage pb.Storage , s * sandbox ) (string , error ) {
198197 return commonStorageHandler (storage )
199198}
200199
201200// virtioBlkStorageHandler handles the storage for blk driver.
202- func virtioBlkStorageHandler (storage pb.Storage ) (string , error ) {
203- // First need to make sure the expected device shows up properly.
204- devName := strings .TrimPrefix (storage .Source , devPrefix )
205- checkUevent := func (uEv * uevent.Uevent ) bool {
206- return (uEv .Action == "add" &&
207- filepath .Base (uEv .DevPath ) == devName )
208- }
209- if err := waitForDevice (storage .Source , devName , checkUevent ); err != nil {
201+ func virtioBlkStorageHandler (storage pb.Storage , s * sandbox ) (string , error ) {
202+ // Get the device node path based on the PCI address provided
203+ // in Storage Source
204+ devPath , err := getBlockDeviceNodeName (s , storage .Source )
205+ if err != nil {
210206 return "" , err
211207 }
208+ storage .Source = devPath
212209
213210 return commonStorageHandler (storage )
214211}
215212
216213// virtioSCSIStorageHandler handles the storage for scsi driver.
217- func virtioSCSIStorageHandler (storage pb.Storage ) (string , error ) {
214+ func virtioSCSIStorageHandler (storage pb.Storage , s * sandbox ) (string , error ) {
218215 // Retrieve the device path from SCSI address.
219216 devPath , err := getSCSIDevPath (storage .Source )
220217 if err != nil {
@@ -248,7 +245,7 @@ func mountStorage(storage pb.Storage) error {
248245// associated operations such as waiting for the device to show up, and mount
249246// it to a specific location, according to the type of handler chosen, and for
250247// each storage.
251- func addStorages (storages []* pb.Storage ) ([]string , error ) {
248+ func addStorages (storages []* pb.Storage , s * sandbox ) ([]string , error ) {
252249 var mountList []string
253250
254251 for _ , storage := range storages {
@@ -262,7 +259,7 @@ func addStorages(storages []*pb.Storage) ([]string, error) {
262259 "Unknown storage driver %q" , storage .Driver )
263260 }
264261
265- mountPoint , err := devHandler (* storage )
262+ mountPoint , err := devHandler (* storage , s )
266263 if err != nil {
267264 return nil , err
268265 }
0 commit comments