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

mount: Virtio-blk container rootfs mount for ACRN hypervisor #574

Merged
merged 1 commit into from
Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,28 @@ func virtioFSStorageHandler(storage pb.Storage, s *sandbox) (string, error) {

// virtioBlkStorageHandler handles the storage for blk driver.
func virtioBlkStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
// Get the device node path based on the PCI address provided
// in Storage Source
devPath, err := getPCIDeviceName(s, storage.Source)
if err != nil {
return "", err

// If hot-plugged, get the device node path based on the PCI address else
// use the virt path provided in Storage Source
if strings.HasPrefix(storage.Source, "/dev") {

FileInfo, err := os.Stat(storage.Source)
if err != nil {
return "", err
}
// Make sure the virt path is valid
if FileInfo.Mode()&os.ModeDevice == 0 {
return "", err
}

} else {
devPath, err := getPCIDeviceName(s, storage.Source)
if err != nil {
return "", err
}

storage.Source = devPath
}
storage.Source = devPath

return commonStorageHandler(storage)
}
Expand Down
24 changes: 24 additions & 0 deletions mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,30 @@ func TestVirtio9pStorageHandlerSuccessful(t *testing.T) {
assert.Nil(t, err, "storage9pDriverHandler() failed: %v", err)
}

func TestVirtioBlkStoragePathFailure(t *testing.T) {
s := &sandbox{}

storage := pb.Storage{
Source: "/home/developer/test",
}

_, err := virtioBlkStorageHandler(storage, s)
agentLog.WithError(err).Error("virtioBlkStorageHandler error")
assert.NotNil(t, err, "virtioBlkStorageHandler() should have failed")
}

func TestVirtioBlkStorageDeviceFailure(t *testing.T) {
s := &sandbox{}

storage := pb.Storage{
Source: "/dev/foo",
}

_, err := virtioBlkStorageHandler(storage, s)
agentLog.WithError(err).Error("virtioBlkStorageHandler error")
assert.NotNil(t, err, "virtioBlkStorageHandler() should have failed")
}

func TestVirtioBlkStorageHandlerSuccessful(t *testing.T) {
skipUnlessRoot(t)

Expand Down