-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test-Layout s390x #483
Test-Layout s390x #483
Changes from 1 commit
561ce19
a724048
7065052
a054be9
cf9728d
c3c1000
58c42a8
83d6f29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ package v1_6_exp | |
import ( | ||
"fmt" | ||
"strings" | ||
"regexp" | ||
"strconv" | ||
|
||
baseutil "github.com/coreos/butane/base/util" | ||
"github.com/coreos/butane/config/common" | ||
|
@@ -29,6 +31,11 @@ import ( | |
"github.com/coreos/vcontext/report" | ||
) | ||
|
||
var ( | ||
dasdRe = regexp.MustCompile("(/dev/dasd[a-z]$)") | ||
sdRe = regexp.MustCompile("(/dev/sd[a-z]$)") | ||
) | ||
|
||
const ( | ||
reservedTypeGuid = "8DA63339-0007-60C0-C436-083AC8230908" | ||
biosTypeGuid = "21686148-6449-6E6F-744E-656564454649" | ||
|
@@ -109,16 +116,25 @@ func (c Config) processBootDevice(config *types.Config, ts *translate.Translatio | |
var r report.Report | ||
|
||
// check for high-level features | ||
wantLuks := util.IsTrue(c.BootDevice.Luks.Tpm2) || len(c.BootDevice.Luks.Tang) > 0 | ||
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 | ||
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 | ||
} | ||
|
||
// compute layout rendering options | ||
var wantBIOSPart bool | ||
var wantEFIPart bool | ||
var wantPRePPart bool | ||
var wantMBR bool | ||
var wantDasd bool | ||
var wantKVM bool | ||
layout := c.BootDevice.Layout | ||
switch { | ||
case layout == nil || *layout == "x86_64": | ||
|
@@ -128,6 +144,14 @@ func (c Config) processBootDevice(config *types.Config, ts *translate.Translatio | |
wantEFIPart = true | ||
case *layout == "ppc64le": | ||
wantPRePPart = true | ||
case *layout == "s390x-zfcp": | ||
wantMBR = true | ||
case *layout == "s390x-eckd": | ||
wantDasd = true | ||
case *layout == "s390x-virt": | ||
wantBIOSPart = true | ||
wantEFIPart = true | ||
|
||
default: | ||
// should have failed validation | ||
panic("unknown layout") | ||
|
@@ -258,6 +282,42 @@ func (c Config) processBootDevice(config *types.Config, ts *translate.Translatio | |
renderedTranslations.AddTranslation(lpath, path.New("json", "storage", "luks")) | ||
r.Merge(r2) | ||
} | ||
|
||
//encrypted root partition for s390x | ||
if wantLuksDevice { | ||
var luksDevice string | ||
dasd := dasdRe.FindString(c.BootDeviceLuks.Device) | ||
sd := sdRe.FindString(c.BootDeviceLuks.Device) | ||
|
||
switch { | ||
case wantMBR && len(sd) != 0: | ||
luksDevice = sd + strconv.Itoa(2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we get a comment explaining the luks device value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also why strconv.Itoa()? and not "2" and is there a better way so there is not string magic? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will add the comment explaining the luks device value.. Also why strconv.Itoa()? and not "2" and is there a better way so there is not string magic? |
||
case wantDasd && len(dasd) != 0: | ||
luksDevice = dasd + strconv.Itoa(2) | ||
default: | ||
panic("can't happen") | ||
} | ||
clevis, ts2, r2 := translateBootDeviceLuks(c.BootDevice.Luks, options) | ||
rendered.Storage.Luks = []types.Luks{{ | ||
Clevis: clevis, | ||
Device: &luksDevice, | ||
Discard: c.BootDevice.Luks.Discard, | ||
Label: util.StrToPtr("luks-root"), | ||
Name: "root", | ||
WipeVolume: util.BoolToPtr(true), | ||
}} | ||
lpath := path.New("yaml", "boot_device", "luks") | ||
rpath := path.New("json", "storage", "luks", 0) | ||
renderedTranslations.Merge(ts2.PrefixPaths(lpath, rpath.Append("clevis"))) | ||
renderedTranslations.AddTranslation(lpath.Append("discard"), rpath.Append("discard")) | ||
for _, f := range []string{"device", "label", "name", "wipeVolume"} { | ||
renderedTranslations.AddTranslation(lpath, rpath.Append(f)) | ||
} | ||
renderedTranslations.AddTranslation(lpath, rpath) | ||
renderedTranslations.AddTranslation(lpath, path.New("json", "storage", "luks")) | ||
r.Merge(r2) | ||
|
||
} | ||
|
||
// create root filesystem | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will remove the extra line. |
||
var rootDevice string | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit 561ce19 should be amended with a724048
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll create a new PR with less clutter on spaces and new line. This PR was not supposed to raised, As i need some assistance is some of the logic in coding which i am not able to meet. I'll work upon.