Skip to content

Commit

Permalink
Added the layout specific features for s390x-zfcp, eckd and virt
Browse files Browse the repository at this point in the history
  • Loading branch information
Madhu authored and Madhu committed Aug 4, 2023
1 parent a724048 commit 7065052
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion config/common/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var (
ErrMountUnitNoFormat = errors.New("format is required if with_mount_unit is true")

// boot device
ErrUnknownBootDeviceLayout = errors.New("layout must be one of: aarch64, ppc64le, x86_64")
ErrUnknownBootDeviceLayout = errors.New("layout must be one of: aarch64, ppc64le, x86_64, s390x-zfcp, s390x-eckd, s390x-virt")
ErrTooFewMirrorDevices = errors.New("mirroring requires at least two devices")

// partition
Expand Down
2 changes: 1 addition & 1 deletion config/fcos/v1_6_exp/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type BootDevice struct {

type BootDeviceLuks struct {
Discard *bool `yaml:"discard"`
Device *string `yaml:"device"`
Device string `yaml:"device"`
Tang []base.Tang `yaml:"tang"`
Threshold *int `yaml:"threshold"`
Tpm2 *bool `yaml:"tpm2"`
Expand Down
32 changes: 17 additions & 15 deletions config/fcos/v1_6_exp/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ func (c Config) processBootDevice(config *types.Config, ts *translate.Translatio

// check for high-level features
wantLuks := util.IsTrue(c.BootDevice.Luks.Tpm2) || len(c.BootDevice.Luks.Tang) > 0
wantLuksDevice := len(c.BootDeviceLuks.Device) > 0 && len(c.BootDevice.Luks.Tang) > 0
wantLuksDevice := len(c.BootDevice.Luks.Device) > 0
wantMirror := len(c.BootDevice.Mirror.Devices) > 0

if !wantLuks && !wantMirror {
return r
}

// s390x zfcp and dasd does not support mirror
if wantLuksDevice && wantMirror {
return r

if wantLuksDevice && wantLuks {
panic("can't happen")
}

// compute layout rendering options
Expand All @@ -134,7 +134,6 @@ func (c Config) processBootDevice(config *types.Config, ts *translate.Translatio
var wantPRePPart bool
var wantMBR bool
var wantDasd bool
var wantKVM bool
layout := c.BootDevice.Layout
switch {
case layout == nil || *layout == "x86_64":
Expand All @@ -144,11 +143,11 @@ func (c Config) processBootDevice(config *types.Config, ts *translate.Translatio
wantEFIPart = true
case *layout == "ppc64le":
wantPRePPart = true
case *layout == "s390x-zfcp":
case *layout == "s390x-zfcp" && wantLuksDevice:
wantMBR = true
case *layout == "s390x-eckd":
case *layout == "s390x-eckd" && wantLuksDevice:
wantDasd = true
case *layout == "s390x-virt":
case *layout == "s390x-virt" && !wantLuksDevice:
wantBIOSPart = true
wantEFIPart = true
default:
Expand Down Expand Up @@ -283,18 +282,18 @@ func (c Config) processBootDevice(config *types.Config, ts *translate.Translatio
}

//encrypted root partition for s390x
if wantLuksDevice {
if wantMBR || wantDasd {
var luksDevice string
dasd := dasdRe.FindString(c.BootDeviceLuks.Device)
sd := sdRe.FindString(c.BootDeviceLuks.Device)
dasd := dasdRe.FindString(c.BootDevice.Luks.Device)
sd := sdRe.FindString(c.BootDevice.Luks.Device)

switch {
case wantMBR && len(sd) != 0:
luksDevice = sd + strconv.Itoa(2)
case wantDasd && len(dasd) != 0:
luksDevice = dasd + strconv.Itoa(2)
default:
panic("can't happen")
panic("Incorrect Device Parameter")
}
clevis, ts2, r2 := translateBootDeviceLuks(c.BootDevice.Luks, options)
rendered.Storage.Luks = []types.Luks{{
Expand Down Expand Up @@ -327,9 +326,12 @@ func (c Config) processBootDevice(config *types.Config, ts *translate.Translatio
case wantMirror:
// RAID without LUKS
rootDevice = "/dev/md/md-root"
case wantLuksDevice:
//Only Luks for s390x
rootDevice = "/dev/mapper/root"
default:
panic("can't happen")
}
}
rootFilesystem := types.Filesystem{
Device: rootDevice,
Format: util.StrToPtr("xfs"),
Expand Down Expand Up @@ -420,4 +422,4 @@ func buildGrubConfig(gb Grub) string {
}
superUserCmd := fmt.Sprintf("set superusers=\"%s\"\n", strings.Join(allUsers, " "))
return "# Generated by Butane\n\n" + superUserCmd + strings.Join(cmds, "\n") + "\n"
}
}

0 comments on commit 7065052

Please sign in to comment.