Page MenuHomeFreeBSD

Implenent power cycle option to reboot
ClosedPublic

Authored by imp on Oct 24 2017, 5:25 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 7, 1:57 PM
Unknown Object (File)
Jan 26 2024, 7:37 PM
Unknown Object (File)
Jan 26 2024, 7:37 PM
Unknown Object (File)
Jan 26 2024, 7:37 PM
Unknown Object (File)
Jan 26 2024, 7:37 PM
Unknown Object (File)
Jan 26 2024, 7:37 PM
Unknown Object (File)
Jan 26 2024, 7:37 PM
Unknown Object (File)
Jan 26 2024, 7:37 PM
Subscribers

Details

Summary

Define RB_POWERCYCLE

RB_POWERCYCLE instructs the platform to power off and then power back
on a short time later, if that's possible. Otherwise, degrade to the
RB_POWEROFF behavior.

Add power cycle support (-c) to shutdown.

Add power cycle support to reboot/halt as -c.

When -c is specified, the system will be power cycled if the
underlying hardware supports it. Otherwise the system will be halted
or rebooted depending on which command was used.

Implement power cycle in init.

If SIGWINCH is received, then halt with power cycle.

Document RB_POWERCYCLE.

Handle RB_POWERCYCLE.

Signal init with SIGWINCH in shutdown_nice for RB_POWERCYCLE.

Handle RB_POWERCYCLE in ada driver

Allow the disks to be spun down when doing a POWERCYCLE as well as
POWEROFF.

Implement IPMI support for RB_POWRECYCLE

Some BMCs support power cycling the chassis via the chassis control
command 2 subcommand 2 (ipmitool called it 'chassis power cycle'). If
the BMC supports the chassis device, register a shutdown_final handler
that sends the power cycle command if request and waits up to 10s for
it to take effect. To minimize stack strain, we preallocate a ipmi
request in the softc. At the moment, we're verbose about what we're
doing.

Sponsored by: Netflix

for review this is one review, but will be several commits

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 12212
Build 12508: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Oct 24 2017, 5:49 PM

Seems like a good idea! See in-line comments.

sbin/reboot/reboot.c
125

Suggest adding a similar check for -p and -c used together.

sbin/shutdown/shutdown.8
75

It looks like it might be clearer if this was turned into a separate sentence.

For example:

The system is halted and the power is turned off at the specified
.Ar time .
If the hardware does not support this option, the system is halted instead.
sys/dev/ipmi/ipmi.c
697

Where is ipmi_req defined? Or, is this supposed to be sc->ipmi_static_req?

Is there a reason not to use IPMI_ALLOC_DRIVER_REQUEST()?

sys/dev/ipmi/ipmivars.h
123

Is this what you used as ipmi_req before? Also, as I noted before, does IPMI_ALLOC_DRIVER_REQUEST() - which uses alloca - obviate the need for this?

sys/kern/kern_shutdown.c
267

SIGWINCH?

kib added inline comments.
lib/libc/sys/reboot.2
91

I think that being more specific there and saying that the power-reset cycle only supported for IPMI with chassis device capabilities would be useful.

lib/libc/sys/reboot.2
91

I'll find some way to say this. We didn't say that POWEROFF was only supported on apm machines when that flag went into the tree, so I get that we need to provide some guidance about what can do this, but don't want to get too specific... thanks!

sbin/reboot/reboot.c
125

Good idea.

sbin/shutdown/shutdown.8
75

Good suggestion. Might also be good to sprinkle kib's suggestion in as well.

sys/dev/ipmi/ipmi.c
697

Doh! It was a last minute change to ipmi_static_req in the header...

I wanted to make sure there was sufficient stack space, but I suppose that's a good assumption...

sys/dev/ipmi/ipmivars.h
123

Yes. I think I'll simplify as you suggest. I think I may have been paranoid about the stack for no good reason.

vangyzen added a subscriber: vangyzen.
vangyzen added inline comments.
sys/dev/ipmi/ipmi.c
899

Update this comment.

sys/sys/ipmi.h
59

CHASIS -> CHASSIS, here and the following line

  • Define RB_POWERCYCLE
  • Add power cycle support (-c) to shutdown.
  • Add power cycle support to reboot/halt as -c.
  • Implement power cycle in init.
  • Handle RB_POWERCYCLE.
  • Handle RB_POWERCYCLE in ada driver
  • Implement IPMI support for RB_POWRECYCLE
  • RB_POWERCYCLE needs to be handled like RB_POWEROFF for decoding.
This revision now requires review to proceed.Oct 24 2017, 8:13 PM
  • Add power cycle support to reboot/halt as -c.
  • Implement power cycle in init.
  • Handle RB_POWERCYCLE.
  • Handle RB_POWERCYCLE in ada driver
  • Implement IPMI support for RB_POWRECYCLE
  • RB_POWERCYCLE needs to be handled like RB_POWEROFF for decoding.

with this change, all the comments should be addressed

  • Define RB_POWERCYCLE
  • Add power cycle support (-c) to shutdown.
  • Add power cycle support to reboot/halt as -c.
  • Implement power cycle in init.
  • Handle RB_POWERCYCLE.
  • Handle RB_POWERCYCLE in ada driver
  • Implement IPMI support for RB_POWRECYCLE
  • RB_POWERCYCLE needs to be handled like RB_POWEROFF for decoding.
vangyzen added inline comments.
share/man/man4/ipmi.4
99

PMC -> BMC

This revision is now accepted and ready to land.Oct 24 2017, 8:21 PM

Fix the comment I cut and pasted...

This revision now requires review to proceed.Oct 24 2017, 8:25 PM
imp marked 13 inline comments as done.Oct 24 2017, 8:28 PM
  • Implement IPMI support for RB_POWRECYCLE
This revision is now accepted and ready to land.Oct 24 2017, 8:29 PM
dhw added inline comments.
sbin/shutdown/shutdown.8
64

"at the specified time"? Where is (or should) it be specified? (A pointer to where one might find the information would be fine -- no point in duplicating the information & risking a change in one, but not the other.)

sbin/shutdown/shutdown.8
64

Already in the shutdown man page. this language is identical to the power off language, so I don't think we need a pointer.

sbin/shutdown/shutdown.8
64

Silly me! -- overlooked the context; sorry for the noise.

wordsmith the power off interval

This revision now requires review to proceed.Oct 24 2017, 11:20 PM
This revision is now accepted and ready to land.Oct 24 2017, 11:37 PM

This was committed w/o the right tags to have it close automatically in r324983-r324990.

dab added inline comments.
lib/libsysdecode/flags.c
652

Not a big deal, but you might consider putting the flags in the same order here as in the comment. It would make it easier to see that the two correspond. Plus, I like alphabetical order. :-)

sys/dev/ipmi/ipmi.c
726

s/hanlder/handler/

839

s/system off/system/

(power cycle implies off/on, not just off)