NAME
shutdown_windows_server - shut down a Windows guest through its SAC console
SYNOPSIS
/opt/omnicube/sbin/shutdown_windows_server zone
DESCRIPTION
shutdown_windows_server shuts down the Windows guest running in zone by driving the guest's Special Administration Console (SAC) over the zone console, so that the guest stops its own services before the virtual machine disappears.
It is an expect(1) script, run directly by /opt/ooce/bin/expect, and the whole conversation is four steps:
The pfexec test exists because pfexec adds no privilege when the caller is already root, while pfexec zlogin into an LX zone can emit pfexecd not running; pid NNNNN privileges not elevated on standard error, which expect would then mix into the console stream it is matching on. Being a Tcl script it cannot source /opt/omnicube/lib/common/utils.sh, so id -u stands in for the ${PFEXEC} test made there; for the same reason there is no run-level guard and no locking.
Use from manage_zone.sh
This command is normally not run by hand. The shutdown_zone path of manage_zone.sh(8) reads the zone's type attribute with zonecfg and, when it is windows, runs
/opt/omnicube/sbin/shutdown_windows_server zone
before issuing zoneadm -z zone shutdown, falling back to zoneadm ... halt if that fails. The guest is thus given the chance to stop cleanly first, and the host-side shutdown becomes the backstop rather than the primary mechanism.
OPERANDS
USAGE
Example 1: shut a Windows guest down by hand
pfexec /opt/omnicube/sbin/shutdown_windows_server win2022 zoneadm -z win2022 list -v
Example 2: check first whether the guest agent could do it instead
/opt/omnicube/sbin/qemu-monitor-command -z win2022 -c ping \\
|| /opt/omnicube/sbin/shutdown_windows_server win2022
EXIT STATUS
The script sets no status of its own.
FILES
ENVIRONMENT
SECURITY
A non-root caller reaches the console through pfexec, which requires the root-equivalent OmniCube Administration profile; the restricted per-zone alternative is restrict-shell-cmd(8). The zone name is interpolated into the spawned command line without validation, so this command must not be exposed to untrusted callers or driven from unvalidated input.
SEE ALSO
omnicube_utils(3), omnicube(7), manage_zone.sh(8), qemu-monitor-command(8), restart_windows_server(8), restrict-shell-cmd(8).
NOTES
SAC must be enabled in the guest (Emergency Management Services on the serial port) and reachable on the console that zlogin -C attaches to. If the SAC> prompt never appears, the wait ends on the default expect timeout and the shutdown line is sent anyway, into whatever is listening - there is no timeout branch and no error is reported. A guest sitting at a login prompt instead of SAC is the common case for this.
The command detaches from the console as soon as shutdown has been sent and does not wait for the guest to finish. When it is called from manage_zone.sh(8) the subsequent zoneadm shutdown may therefore overtake a guest that is still stopping services; the zoneadm halt fallback makes that unconditional.
Where the QEMU guest agent is installed and configured, qemu-monitor-command -z zone -c shutdown --arguments.mode powerdown is the more observable route, since it reports whether the agent accepted the request.