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

Commit

Permalink
Merge pull request #574 from vijaydhanraj/acrn-agent
Browse files Browse the repository at this point in the history
mount: Virtio-blk container rootfs mount for ACRN hypervisor
  • Loading branch information
Julio Montes authored Jun 14, 2019
2 parents f935878 + 9b59925 commit ee06860
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
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

0 comments on commit ee06860

Please sign in to comment.