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

PHD: support guest-initiated reboot #785

Merged
merged 1 commit into from
Oct 10, 2024
Merged

Conversation

iximeow
Copy link
Member

@iximeow iximeow commented Oct 10, 2024

While in many cases a procedure like "reboot and wait for login" is sufficient to reboot a guest, it is not sufficient for all cases. For Windows, the command is spelled shutdown /r instead. And on Debian (at least 11), reboot will immediately take the guest down instead of printing a new shell prompt first.

So, have guest OS adapters provide commands that impel a guest to reboot, and wait for that reboot to occur (rather than the naive initial approach of reboot, wait for shell prompt, wait for login prompt, proceed).

Fixes #783.

(since the boot order tests are pretty Linux-specific what with efivarfs, the Windows graceful_reboot implementations are for completeness. I don't have a good Windows guest to try running them with at the moment, even...)

While in many cases a procedure like "`reboot` and wait for login" is
sufficient to reboot a guest, it is not sufficient for *all* cases. For
Windows, the command is spelled `shutdown /r` instead. And on Debian (at
least 11), `reboot` will immediately take the guest down instead of
printing a new shell prompt first.

So, have guest OS adapters provide commands that impel a guest to
reboot, and wait for that reboot to occur (rather than the naive initial
approach of reboot, wait for shell prompt, wait for login prompt,
proceed).

Fixes #783.
Copy link
Contributor

@gjcolombo gjcolombo 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 putting this together!

@iximeow iximeow merged commit f5f7bf8 into master Oct 10, 2024
11 checks passed
@iximeow iximeow deleted the ixi/phd-guest-reboots branch October 10, 2024 22:37
iximeow added a commit that referenced this pull request Oct 19, 2024
some smoketests instigated a graceful reboot by sending `reboot\n` to
the serial console, but Windows guests are rewarded (via Cygwin) with

```
bash: reboot: command not found
```

as of #785 there is now a TestVm helper `graceful_reboot` that does this
in whatever way the guest adapter desires, so use that instead.

unfortunately `graceful_reboot` is only mostly right for Windows guests,
so fix that here too: `shutdown` immediately terminates the cmd.exe
session, at which point the SAC redraws the previous screen, which
happens to have all the sigils we look for to detect that Windows has
freshly booted. we then log back into the imminently-shutdown Windows,
shutdown takes effect, and PHD becomes fully desynchronized from the
guest state.

so, look for "BdsDxe: loading " as an outside-the-guest-OS sigil that
tells us we're watching a fresh boot. this comes from OVMF, so a booted
guest will have clobbered the message and not know to redraw it even if
it seeks to recreate a previous display.

other tests depend on Linux-specific features like `efivarfs` or
`mount -o ro`, so skip them on non-Linux guests.
iximeow added a commit that referenced this pull request Oct 19, 2024
some smoketests instigated a graceful reboot by sending `reboot\n` to
the serial console, but Windows guests are rewarded (via Cygwin) with

```
bash: reboot: command not found
```

as of #785 there is now a TestVm helper `graceful_reboot` that does this
in whatever way the guest adapter desires, so use that instead.

unfortunately `graceful_reboot` is only mostly right for Windows guests,
so fix that here too: `shutdown` immediately terminates the cmd.exe
session, at which point the SAC redraws the previous screen, which
happens to have all the sigils we look for to detect that Windows has
freshly booted. we then log back into the imminently-shutdown Windows,
shutdown takes effect, and PHD becomes fully desynchronized from the
guest state.

so, look for "BdsDxe: loading " as an outside-the-guest-OS sigil that
tells us we're watching a fresh boot. this comes from OVMF, so a booted
guest will have clobbered the message and not know to redraw it even if
it seeks to recreate a previous display.

other tests depend on Linux-specific features like `efivarfs` or
`mount -o ro`, so skip them on non-Linux guests.
iximeow added a commit that referenced this pull request Oct 22, 2024
some smoketests instigated a graceful reboot by sending `reboot\n` to
the serial console, but Windows guests are rewarded (via Cygwin) with

```
bash: reboot: command not found
```

as of #785 there is now a TestVm helper `graceful_reboot` that does this
in whatever way the guest adapter desires, so use that instead.

unfortunately `graceful_reboot` is only mostly right for Windows guests,
so fix that here too: `shutdown` immediately terminates the cmd.exe
session, at which point the SAC redraws the previous screen, which
happens to have all the sigils we look for to detect that Windows has
freshly booted. we then log back into the imminently-shutdown Windows,
shutdown takes effect, and PHD becomes fully desynchronized from the
guest state.

so, look for "BdsDxe: loading " as an outside-the-guest-OS sigil that
tells us we're watching a fresh boot. this comes from OVMF, so a booted
guest will have clobbered the message and not know to redraw it even if
it seeks to recreate a previous display.

other tests depend on Linux-specific features like `efivarfs` or
`mount -o ro`, so skip them on non-Linux guests.
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.

boot_order_source_priority fails with Debian 11 guest
2 participants