Skip to content

Commit

Permalink
zfs: Disallow block.* settings for regular custom block volumes
Browse files Browse the repository at this point in the history
Fixes #12188

Signed-off-by: Thomas Hipp <[email protected]>
  • Loading branch information
monstermunchkin committed Sep 1, 2023
1 parent 16ec502 commit e5a41df
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lxd/storage/drivers/driver_zfs_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,15 @@ func (d *zfs) commonVolumeRules() map[string]func(value string) error {

// ValidateVolume validates the supplied volume config.
func (d *zfs) ValidateVolume(vol Volume, removeUnknownKeys bool) error {
return d.validateVolume(vol, d.commonVolumeRules(), removeUnknownKeys)
commonRules := d.commonVolumeRules()

// Disallow block.* settings for regular custom block volumes.
if vol.volType == VolumeTypeCustom && (vol.contentType == ContentTypeBlock || !vol.IsBlockBacked()) {
delete(commonRules, "block.filesystem")
delete(commonRules, "block.mount_options")
}

return d.validateVolume(vol, commonRules, removeUnknownKeys)
}

// UpdateVolume applies config changes to the volume.
Expand Down Expand Up @@ -3330,6 +3338,8 @@ func (d *zfs) FillVolumeConfig(vol Volume) error {
// If vol has a source, ignore the block mode related config keys from the pool.
if vol.hasSource || vol.IsVMBlock() {
excludedKeys = []string{"zfs.block_mode", "block.filesystem", "block.mount_options"}
} else if vol.volType == VolumeTypeCustom && (vol.contentType == ContentTypeBlock || !vol.IsBlockBacked()) {
excludedKeys = []string{"block.filesystem", "block.mount_options"}
}

err := d.fillVolumeConfig(&vol, excludedKeys...)
Expand Down

0 comments on commit e5a41df

Please sign in to comment.