Skip to content

Commit

Permalink
incusd/devices/disk: Always apply the disk options
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Graber <[email protected]>
  • Loading branch information
stgraber committed Oct 27, 2023
1 parent 0b8f0ba commit 203c9e6
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions internal/server/device/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,16 +744,6 @@ func (d *disk) detectVMPoolMountOpts() []string {
opts = append(opts, DiskIOUring)
}

// Allow the user to override the bus.
if d.config["io.bus"] != "" {
opts = append(opts, fmt.Sprintf("bus=%s", d.config["io.bus"]))
}

// Allow the user to override the caching mode.
if d.config["io.cache"] != "" {
opts = append(opts, fmt.Sprintf("cache=%s", d.config["io.cache"]))
}

return opts
}

Expand All @@ -764,18 +754,33 @@ func (d *disk) startVM() (*deviceConfig.RunConfig, error) {
revert := revert.New()
defer revert.Fail()

// Handle user overrides.
opts := []string{}

// Allow the user to override the bus.
if d.config["io.bus"] != "" {
opts = append(opts, fmt.Sprintf("bus=%s", d.config["io.bus"]))
}

// Allow the user to override the caching mode.
if d.config["io.cache"] != "" {
opts = append(opts, fmt.Sprintf("cache=%s", d.config["io.cache"]))
}

if internalInstance.IsRootDiskDevice(d.config) {
// Handle previous requests for setting new quotas.
err := d.applyDeferredQuota()
if err != nil {
return nil, err
}

opts = append(opts, d.detectVMPoolMountOpts()...)

runConf.Mounts = []deviceConfig.MountEntryItem{
{
TargetPath: d.config["path"], // Indicator used that this is the root device.
DevName: d.name,
Opts: d.detectVMPoolMountOpts(),
Opts: opts,
},
}

Expand Down Expand Up @@ -803,6 +808,7 @@ func (d *disk) startVM() (*deviceConfig.RunConfig, error) {
DevPath: fmt.Sprintf("%s:%d:%s", DiskFileDescriptorMountPrefix, f.Fd(), isoPath),
DevName: d.name,
FSType: "iso9660",
Opts: opts,
},
}

Expand All @@ -818,6 +824,7 @@ func (d *disk) startVM() (*deviceConfig.RunConfig, error) {
{
DevPath: DiskGetRBDFormat(clusterName, userName, fields[0], fields[1]),
DevName: d.name,
Opts: opts,
},
}
} else {
Expand All @@ -827,6 +834,7 @@ func (d *disk) startVM() (*deviceConfig.RunConfig, error) {
mount := deviceConfig.MountEntryItem{
DevPath: d.config["source"],
DevName: d.name,
Opts: opts,
}

// Mount the pool volume and update srcPath to mount path so it can be recognised as dir
Expand Down Expand Up @@ -879,6 +887,7 @@ func (d *disk) startVM() (*deviceConfig.RunConfig, error) {
mount := deviceConfig.MountEntryItem{
DevPath: DiskGetRBDFormat(clusterName, userName, poolName, d.config["source"]),
DevName: d.name,
Opts: opts,
}

if contentType == db.StoragePoolVolumeContentTypeISO {
Expand All @@ -897,7 +906,7 @@ func (d *disk) startVM() (*deviceConfig.RunConfig, error) {

revert.Add(revertFunc)

mount.Opts = d.detectVMPoolMountOpts()
mount.Opts = append(mount.Opts, d.detectVMPoolMountOpts()...)
}

if util.IsTrue(d.config["readonly"]) {
Expand Down

0 comments on commit 203c9e6

Please sign in to comment.