Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add io.bus=usb for disks #1835

Merged
merged 4 commits into from
Mar 24, 2025
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
4 changes: 4 additions & 0 deletions doc/api-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2756,3 +2756,7 @@ This adds an `allocated_time` field below `CPU` in the instance state API.
## `network_io_bus`

This introduces a new `io.bus` property for compatible network devices allowing to choose between `virtio` (default) and `usb`.

## `disk_io_bus_usb`

Adds a new `usb` value for `io.bus` on `disk` devices.
1 change: 1 addition & 0 deletions doc/config_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ For block devices (disks), this is one of:
- `nvme`
- `virtio-blk`
- `virtio-scsi` (default)
- `usb`

For file systems (shared directories or custom volumes), this is one of:
- `9p`
Expand Down
5 changes: 3 additions & 2 deletions internal/server/device/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ func (d *disk) validateConfig(instConf instance.ConfigReader) error {
// - `nvme`
// - `virtio-blk`
// - `virtio-scsi` (default)
// - `usb`
//
// For file systems (shared directories or custom volumes), this is one of:
// - `9p`
Expand All @@ -361,7 +362,7 @@ func (d *disk) validateConfig(instConf instance.ConfigReader) error {
// default: `virtio-scsi` for block, `auto` for file system
// required: no
// shortdesc: Only for VMs: Override the bus for the device
"io.bus": validate.Optional(validate.IsOneOf("nvme", "virtio-blk", "virtio-scsi", "auto", "9p", "virtiofs")),
"io.bus": validate.Optional(validate.IsOneOf("nvme", "virtio-blk", "virtio-scsi", "auto", "9p", "virtiofs", "usb")),
}

err := d.config.Validate(rules)
Expand Down Expand Up @@ -1350,7 +1351,7 @@ func (d *disk) startVM() (*deviceConfig.RunConfig, error) {
}
} else {
// Confirm we're dealing with block options.
err := validate.Optional(validate.IsOneOf("nvme", "virtio-blk", "virtio-scsi"))(d.config["io.bus"])
err := validate.Optional(validate.IsOneOf("nvme", "virtio-blk", "virtio-scsi", "usb"))(d.config["io.bus"])
if err != nil {
return nil, err
}
Expand Down
3 changes: 3 additions & 0 deletions internal/server/instance/drivers/driver_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -4366,6 +4366,9 @@ func (d *qemu) addDriveConfig(qemuDev map[string]any, bootIndexes map[string]int
}

qemuDev["driver"] = bus
} else if bus == "usb" {
qemuDev["driver"] = "usb-storage"
qemuDev["bus"] = "qemu_usb.0"
}

if bootIndexes != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/server/metadata/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
{
"io.bus": {
"default": "`virtio-scsi` for block, `auto` for file system",
"longdesc": "This controls what bus a disk device should be attached to.\n\nFor block devices (disks), this is one of:\n- `nvme`\n- `virtio-blk`\n- `virtio-scsi` (default)\n\nFor file systems (shared directories or custom volumes), this is one of:\n- `9p`\n- `auto` (default) (`virtiofs` + `9p`, just `9p` if `virtiofsd` is missing)\n- `virtiofs`",
"longdesc": "This controls what bus a disk device should be attached to.\n\nFor block devices (disks), this is one of:\n- `nvme`\n- `virtio-blk`\n- `virtio-scsi` (default)\n- `usb`\n\nFor file systems (shared directories or custom volumes), this is one of:\n- `9p`\n- `auto` (default) (`virtiofs` + `9p`, just `9p` if `virtiofsd` is missing)\n- `virtiofs`",
"required": "no",
"shortdesc": "Only for VMs: Override the bus for the device",
"type": "string"
Expand Down
1 change: 1 addition & 0 deletions internal/version/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ var APIExtensions = []string{
"network_ovn_ipv4_dhcp_expiry",
"instance_state_cpu_time",
"network_io_bus",
"disk_io_bus_usb",
}

// APIExtensionsCount returns the number of available API extensions.
Expand Down
Loading