Skip to content
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

s390x: add support for IBM Z DASD disks #153

Merged
merged 3 commits into from
Jul 10, 2020

Conversation

nikita-dubrovskii
Copy link
Contributor

Installation on s390 dasd disks is a bit tricky,
this patch makes coreos-installer able to format,
create partitions, and finally install CoreOS on s390.

Signed-off-by: Nikita Dubrovskii [email protected]

@nikita-dubrovskii
Copy link
Contributor Author

nikita-dubrovskii commented Feb 11, 2020

Hi Colin. We had a short discussion in Brno (DevConf). Could you please review this patch?

Copy link
Contributor

@bgilbert bgilbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! These are initial impressions; I haven't done a detailed review.

src/install.rs Outdated Show resolved Hide resolved
src/s390x/dasd.rs Outdated Show resolved Hide resolved
src/s390x/zipl.rs Outdated Show resolved Hide resolved
src/s390x/zipl.rs Outdated Show resolved Hide resolved
src/s390x/zipl.rs Outdated Show resolved Hide resolved
src/s390x/dasd.rs Outdated Show resolved Hide resolved
src/s390x/dasd.rs Outdated Show resolved Hide resolved
src/s390x/dasd.rs Outdated Show resolved Hide resolved
src/s390x/dasd.rs Outdated Show resolved Hide resolved
src/s390x/dasd.rs Outdated Show resolved Hide resolved
src/s390x/zipl.rs Outdated Show resolved Hide resolved
Copy link
Member

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK so I only skimmed this, and I only have superficial knowledge of what we need for dasd; I know we've talked about it a few times and my recollection is that it boils down to the kernel needing to "activate" devices effectively?

Is there a good reference for this stuff? OK from a quick search the top two (here) results are:

Which look useful. Though what would help me in this PR is perhaps a little bit more elaboration on what "support" here means. Perhaps a block comment in the s390x.rs file or a README-s390x.md?

Also, did you learn Rust just for this? If so (or actually regardless) it's excellent code and really well done!

@cgwalters
Copy link
Member

Does this have any intersection with the discussions around coreos-installer and multipath? I think that one was going to end up on the legacy branch first?

src/s390x/zipl.rs Outdated Show resolved Hide resolved
src/s390x/zipl.rs Outdated Show resolved Hide resolved
@cgwalters
Copy link
Member

My overall feeling here is if you've tested this and the rest of the s390x team is happy with it, I'm inclined to merge.

@nikita-dubrovskii
Copy link
Contributor Author

Does this have any intersection with the discussions around coreos-installer and multipath? I think that one was going to end up on the legacy branch first?

No intersection, Tuan is working on multipath for legacy branch. And i've started working on multipath for master branch

@nikita-dubrovskii
Copy link
Contributor Author

nikita-dubrovskii commented Mar 5, 2020

OK so I only skimmed this, and I only have superficial knowledge of what we need for dasd; I know we've talked about it a few times and my recollection is that it boils down to the kernel needing to "activate" devices effectively?

Exactly, we have to prepare (format & make partitions) DASD device and then tell kernel about it
rd.dasd=xxxxx .... (and networking as well rd.znet=xxxxx ..)

Is there a good reference for this stuff? OK from a quick search the top two (here) results are:
* https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/chap-post-installation-configuration-s390
* https://www.kernel.org/doc/Documentation/s390/DASD

Yes, i read this.

Though what would help me in this PR is perhaps a little bit more elaboration on what "support" here means. Perhaps a block comment in the s390x.rs file or a README-s390x.md?

Ok, makes sense

Also, did you learn Rust just for this? If so (or actually regardless) it's excellent code and really well done!

Yep, i've tried several times before, but was too busy with C++ projects and had no chance to do smth in Rust. thx ))

Copy link
Member

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I gave this another look; some optional changes to make some code more idiomatic/avoid unwraps.

src/s390x/dasd.rs Outdated Show resolved Hide resolved
src/s390x/dasd.rs Outdated Show resolved Hide resolved
src/s390x/dasd.rs Outdated Show resolved Hide resolved
src/s390x/dasd.rs Outdated Show resolved Hide resolved
src/s390x/dasd.rs Outdated Show resolved Hide resolved
src/s390x/dasd.rs Outdated Show resolved Hide resolved
src/s390x/dasd.rs Outdated Show resolved Hide resolved
src/s390x/dasd.rs Outdated Show resolved Hide resolved
src/s390x/dasd.rs Outdated Show resolved Hide resolved
src/s390x/zipl.rs Outdated Show resolved Hide resolved
Copy link
Contributor Author

@nikita-dubrovskii nikita-dubrovskii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one breaks the installation. I'm debugging it

src/install.rs Outdated Show resolved Hide resolved
@bgilbert bgilbert marked this pull request as ready for review July 7, 2020 21:36
@bgilbert
Copy link
Contributor

bgilbert commented Jul 7, 2020

I think this is ready for review!

@bgilbert
Copy link
Contributor

bgilbert commented Jul 7, 2020

@jlebon proposed squashing this series down to one commit before merging. Any preferences?

@nikita-dubrovskii
Copy link
Contributor Author

@jlebon proposed squashing this series down to one commit before merging. Any preferences?

hmm, it's too big for one commit. maybe we can have smth like:

  1. s390x: add support for IBM Z DASD disks
  2. clean-ups
  3. s390x: use ioctls to get DASD parameters
  4. s390x: switch from fdisk to gptman
  5. s390x: drop dd-lib
  6. s390x: stream download directly to disk
  7. clean-ups
  8. s390x: trigger udev_settle after disk format
  9. s390x: remove variable substitutions from kargs
  10. s390x: use '/dev/dasd' as a pattern

@bgilbert
Copy link
Contributor

bgilbert commented Jul 8, 2020

I'll let @jlebon chime in here, but I think his idea is to avoid leaking development history into the master branch. The merged commit would list you as the primary author, and me as a co-author.

I think the prep changes that affect the rest of the codebase (e.g. adding a callback to write_image) should still be separate commits, though.

@bgilbert bgilbert force-pushed the s390 branch 4 times, most recently from 4501977 to aff9055 Compare July 8, 2020 16:28
Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No major issues, looks sane overall!

- rust: beta
arch: s390x
- rust: nightly
arch: s390x
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, what? /me reads https://docs.travis-ci.com/user/multi-cpu-architectures/.

Travis CI can test on amd64, ppc64le (IBM Power CPUs), s390x (IBM Z CPUs) and arm64 (run on ARMv8 compliant CPUs) if the operating system is Linux.

Whoa, didn't realize this! We could use that in cosa at least to get some multi-arch coverage, even if just of ./build.sh (though definitely worth checking if it also has virt support, but likely not).

@@ -10,6 +10,9 @@ PERSIST_KERNEL_NET_PARAMS=("ipv6.disable" "net.ifnames" "net.naming-scheme")
# List from https://www.mankier.com/7/dracut.cmdline#Description-Network
PERSIST_DRACUT_NET_PARAMS=("ip" "ifname" "rd.route" "bootdev" "BOOTIF" "rd.bootif" "nameserver" "rd.peerdns" "biosdevname" "vlan" "bond" "team" "bridge" "rd.net.timeout.carrier" "coreos.no_persist_ip")

# IBM S390X params to persist
PERSIST_S390X_PARAMS=("rd.dasd" "rd.zfcp" "rd.znet" "zfcp.allow_lun_scan" "cio_ignore")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, do we really need this? There is a push in general to not add support for more kargs than we already have and instead direct users towards scripting coreos-installer via Ignition: #124.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand it:

  • rd.dasd activates a DASD device, without which a DASD boot device won't show up
  • rd.zfcp activates a Fibre Channel device, without which an FC boot device won't show up
  • rd.znet activates a network device, without which it won't be available from the initramfs
  • zfcp.allow_lun_scan might be needed to configure activation of certain FC devices
  • cio_ignore tells the kernel not to attach to specified devices on boot

So I suspect they might all be needed. @nikita-dubrovskii, is that correct? Any additional details?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I suspect they might all be needed.

Exactly, we have to persist those kargs.

src/install.rs Outdated Show resolved Hide resolved
src/s390x/dasd.rs Outdated Show resolved Hide resolved
src/s390x/zipl.rs Outdated Show resolved Hide resolved
src/s390x/zipl.rs Outdated Show resolved Hide resolved
src/s390x/zipl.rs Outdated Show resolved Hide resolved
src/s390x/zipl.rs Outdated Show resolved Hide resolved
fn get_boot_kargs<P: AsRef<Path>>(boot_config: P) -> Result<String> {
let contents = read_to_string(&boot_config)
.chain_err(|| format!("reading {}", boot_config.as_ref().display()))?;
// read kargs from options line
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regex is fine, though it'd be cleaner and probably less lines overall to just iterate over the lines and find the one that starts with options. See e.g. bls_entry_delete_and_append_kargs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, I find this cleaner than open-coding an iteration and starts_with(). Can change it if there's a strong preference though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a strong preference. Regex just seemed like overkill for the task at hand, but meh...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As i remember, some of you asked me to use regex for substring-search operations )

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, that was me. 🙂

@jlebon
Copy link
Member

jlebon commented Jul 8, 2020

I'll let @jlebon chime in here, but I think his idea is to avoid leaking development history into the master branch. The merged commit would list you as the primary author, and me as a co-author.

I think the prep changes that affect the rest of the codebase (e.g. adding a callback to write_image) should still be separate commits, though.

Yeah exactly. I think the rule of thumb I personally use is something like: any commit that's just changing content that's all new in the same PR should normally just be squashed in. To take a random example, is this commit valuable to have on its own on the master branch? It's just modifying a README.md file which master hasn't even seen yet.

Commits which refactor existing code as prep should definitely still be kept.

@bgilbert bgilbert force-pushed the s390 branch 2 times, most recently from a9ea689 to 08d4764 Compare July 8, 2020 21:34
@bgilbert
Copy link
Contributor

bgilbert commented Jul 8, 2020

@nikita-dubrovskii If you agree, I'll refactor into three commits:

  • The generic parts of "s390x: stream download directly to disk"
  • The generic parts of "install: correctly detect DASDs if they're behind a symlink"
  • Everything else, with Author: you and Co-authored-by: me

I can do that in a new PR if you'd like the history to be preserved here.

@nikita-dubrovskii
Copy link
Contributor Author

I can do that in a new PR if you'd like the history to be preserved here.

I don't mind, for me any approach is Ok.

@bgilbert bgilbert mentioned this pull request Jul 9, 2020
31 tasks
@bgilbert bgilbert force-pushed the s390 branch 3 times, most recently from ca76ff0 to 6864523 Compare July 9, 2020 21:27
bgilbert and others added 3 commits July 9, 2020 19:46
Return the symlink target if a link, or the original path if not.
Allow callers to provide a custom callback for writing image data
to disk.
Support formatting, creating partitions, and installing onto s390x
DASD disks.

Co-authored-by: Benjamin Gilbert <[email protected]>
@bgilbert
Copy link
Contributor

Updated and squashed!

@bgilbert bgilbert merged commit f9c3ecb into coreos:master Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants