Skip to content

Commit

Permalink
incusd/device/disk: disable 9p if idmap requested
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Somers <[email protected]>
  • Loading branch information
bensmrs committed Jan 13, 2025
1 parent e88f874 commit 0caf262
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/server/device/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,8 @@ func (d *disk) startVM() (*deviceConfig.RunConfig, error) {
var errUnsupported UnsupportedError
if errors.As(err, &errUnsupported) {
d.logger.Warn("Unable to use virtio-fs for device, using 9p as a fallback", logger.Ctx{"err": errUnsupported})
// Fallback to 9p-only.
busOption = "9p"

if errUnsupported == ErrMissingVirtiofsd {
_ = d.state.DB.Cluster.Transaction(context.TODO(), func(ctx context.Context, tx *db.ClusterTx) error {
Expand Down Expand Up @@ -1339,6 +1341,19 @@ func (d *disk) startVM() (*deviceConfig.RunConfig, error) {
if err != nil {
return nil, fmt.Errorf("Failed to setup virtiofsd for device %q: %w", d.name, err)
}

// We can't hotplug 9p shares, so only do 9p for stopped instances.
if !d.inst.IsRunning() {
// If an idmap is specified, disable 9p.
if len(rawIDMaps.Entries) > 0 {
// If we are 9p-only, return an error.
if busOption == "9p" {
return nil, fmt.Errorf("9p shares do not support identity mapping")
}

opts = append(opts, "bus=virtiofs")

Check failure on line 1354 in internal/server/device/disk.go

View workflow job for this annotation

GitHub Actions / Code (oldstable)

ineffectual assignment to opts (ineffassign)

Check failure on line 1354 in internal/server/device/disk.go

View workflow job for this annotation

GitHub Actions / Code (stable)

ineffectual assignment to opts (ineffassign)

Check failure on line 1354 in internal/server/device/disk.go

View workflow job for this annotation

GitHub Actions / Code (tip)

ineffectual assignment to opts (ineffassign)
}
}
} else {
// Confirm we're dealing with block options.
err := validate.Optional(validate.IsOneOf("nvme", "virtio-blk", "virtio-scsi"))(d.config["io.bus"])
Expand Down

0 comments on commit 0caf262

Please sign in to comment.