Skip to content

Start with config.plist.bak when config.plist can't be loaded - #3

Merged
DrogaBox merged 3 commits into
mainfrom
d7-config-backup-fallback
Nov 24, 2026
Merged

DrogaBox merged 3 commits into
mainfrom
d7-config-backup-fallback

Conversation

@DrogaBox

Copy link
Copy Markdown
Owner

If config.plist can't be loaded (missing, or cut short because the power went out while the editor was saving it), OpenCore now starts with config.plist.bak instead of hanging before the picker. The editor already writes that backup before every save, so it's the last config that worked. The options editor says it started from the backup, and "Undo the last save" puts it back as config.plist. With a vault the backup is never used.

While running from the backup, the editor doesn't overwrite config.plist.bak, so another cut can't take away the only good copy.

Second commit fixes a hang I found testing this in QEMU. Log lines from before the log is set up get logged again once it is, using the HaltLevel of the config that ended up loaded. The "failed to parse config.plist" error then tripped the usual HaltLevel (0x80000000) and stopped OpenCore right after it had loaded the backup. The same thing already happens on main when a config chosen from the editor can't be loaded: it hangs instead of falling back to config.plist, and with keep it hangs on every boot. A failed file that gets replaced by another one is now a warning, and only the last failure is an error.

Tested:

  • DrogaBox/run-tests.sh passes, also with SANITIZE. The power-cut test cuts at every step of a save and of the undo.
  • In QEMU (OVMF, TCG) with RELEASE and DEBUG builds, Target 67 and HaltLevel 0x80000000:
    • cut or missing config with a good backup: starts with the backup;
    • no backup: stops, saying both failed;
    • vault: doesn't use the backup;
    • broken chosen config, with and without keep: falls back to the default;
    • undo from the firmware: writes config.plist and the next boot loads it.

Not tried on real hardware or with a real power cut.

A power cut while the editor saved config.plist could leave it missing or cut
short, and OpenCore stopped before the picker. It now loads the backup the
editor wrote and checked just before, says so in the options editor, and Undo
puts it back. While running from the backup the editor never writes it.

TestPickerEditor cuts the power after every number of writes and deletes in a
save and in the repair, and checks that the next start always finds a config.
Messages from before the log is set up are logged again once it is, with
HaltLevel of the configuration loaded in the end. The error about a
config.plist that could not be loaded, or a chosen configuration that could
not be used, then stopped OpenCore with the usual HaltLevel (DEBUG_ERROR)
right after it had started with the backup or the default. Only the last
failure is an error now.
@DrogaBox
DrogaBox merged commit 8b185aa into main Nov 24, 2026
21 of 22 checks passed
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.

1 participant