Skip to content

Commit 7a1f61e

Browse files
committed
qemu: support --add-disk 1G:channel=nvme
I'm testing stuff related to NVMe and this is useful. Note the primary disk can already be put on NVMe using `--qemu-nvme`. But with this, you can customize the serial as you wish, e.g. `--add-disk 1G:channel=nvme,serial=foo_bar`.
1 parent 88ee06e commit 7a1f61e

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

docs/cosa/run.md

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Additional disks CLI arguments support optional flags using the `--add-disk
8787

8888
- `mpath`: enables multipathing for the disk (see below for details).
8989
- `4k`: sets the disk as 4Kn (4096 physical sector size)
90+
- `channel=CHANNEL`: set the channel type (e.g. `virtio`, `nvme`)
9091
- `serial=NAME`: sets the disk serial; this can then be used to customize the
9192
default `diskN` naming documented above (e.g. `serial=foobar` will make the
9293
device show up as `/dev/disk/by-id/virtio-foobar`)

mantle/platform/qemu.go

+7
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ type Disk struct {
106106
func ParseDiskSpec(spec string) (*Disk, error) {
107107
split := strings.Split(spec, ":")
108108
var size string
109+
var channel string
109110
multipathed := false
110111
sectorSize := 0
111112
serial_opt := []string{}
@@ -118,6 +119,11 @@ func ParseDiskSpec(spec string) (*Disk, error) {
118119
multipathed = true
119120
} else if opt == "4k" {
120121
sectorSize = 4096
122+
} else if strings.HasPrefix(opt, "channel=") {
123+
channel = strings.TrimPrefix(opt, "channel=")
124+
if channel == "" {
125+
return nil, fmt.Errorf("invalid channel opt %s", opt)
126+
}
121127
} else if strings.HasPrefix(opt, "serial=") {
122128
serial := strings.TrimPrefix(opt, "serial=")
123129
if serial == "" {
@@ -133,6 +139,7 @@ func ParseDiskSpec(spec string) (*Disk, error) {
133139
}
134140
return &Disk{
135141
Size: size,
142+
Channel: channel,
136143
DeviceOpts: serial_opt,
137144
SectorSize: sectorSize,
138145
MultiPathDisk: multipathed,

0 commit comments

Comments
 (0)