Skip to content
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
9 changes: 9 additions & 0 deletions drives.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,12 @@ func WithCacheType(cacheType string) DriveOpt {
d.CacheType = String(cacheType)
}
}

// WithIoEngine sets the io engine of the drive
// Defaults to Sync, Async is in developer preview at the moment
// https://github.com/firecracker-microvm/firecracker/blob/v1.1.0/docs/api_requests/block-io-engine.md
func WithIoEngine(ioEngine string) DriveOpt {
return func(d *models.Drive) {
d.IoEngine = String(ioEngine)
}
}
20 changes: 20 additions & 0 deletions drives_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,23 @@ func TestDrivesBuilderAddDrive(t *testing.T) {
t.Errorf("expected drives %+v\n, but received %+v", e, a)
}
}

func TestDrivesBuilderWithIoEngine(t *testing.T) {
expectedPath := "/path/to/rootfs"
expectedVal := "Async"
expectedDrives := []models.Drive{
{
DriveID: String(rootDriveName),
PathOnHost: &expectedPath,
IsRootDevice: Bool(true),
IsReadOnly: Bool(false),
IoEngine: &expectedVal,
},
}

drives := NewDrivesBuilder(expectedPath).WithRootDrive(expectedPath,
WithDriveID(string(rootDriveName)), WithIoEngine(expectedVal)).Build()
if e, a := expectedDrives, drives; !reflect.DeepEqual(e, a) {
t.Errorf("expected drives %+v, but received %+v", e, a)
}
}