in options.go [280:314]
func parseBlockDevices(entries []string) ([]models.Drive, error) {
devices := []models.Drive{}
for i, entry := range entries {
path := ""
readOnly := true
if strings.HasSuffix(entry, ":rw") {
readOnly = false
path = strings.TrimSuffix(entry, ":rw")
} else if strings.HasSuffix(entry, ":ro") {
path = strings.TrimSuffix(entry, ":ro")
} else {
return nil, errInvalidDriveSpecificationNoSuffix
}
if path == "" {
return nil, errInvalidDriveSpecificationNoPath
}
if _, err := os.Stat(path); err != nil {
return nil, err
}
e := models.Drive{
// i + 2 represents the drive ID. We will reserve 1 for root.
DriveID: firecracker.String(strconv.Itoa(i + 2)),
PathOnHost: firecracker.String(path),
IsReadOnly: firecracker.Bool(readOnly),
IsRootDevice: firecracker.Bool(false),
}
devices = append(devices, e)
}
return devices, nil
}