diff --git a/internal/server/device/disk.go b/internal/server/device/disk.go index 98007cee59a..991ba079be3 100644 --- a/internal/server/device/disk.go +++ b/internal/server/device/disk.go @@ -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 } @@ -764,6 +754,19 @@ 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() @@ -771,11 +774,13 @@ func (d *disk) startVM() (*deviceConfig.RunConfig, error) { 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, }, } @@ -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, }, } @@ -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 { @@ -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 @@ -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 { @@ -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"]) {