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

incusd/instance/qemu: Fix issues with old NVRAM #1257

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions internal/server/instance/drivers/driver_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -1323,13 +1323,21 @@ func (d *qemu) start(stateful bool, op *operationlock.InstanceOperation) error {
}

// Copy EDK2 settings firmware to nvram file if needed.
// This firmware file can be modified by the VM so it must be copied from the defaults.
if d.architectureSupportsUEFI(d.architecture) && (!util.PathExists(d.nvramPath()) || util.IsTrue(d.localConfig["volatile.apply_nvram"])) {
err = d.setupNvram()
if err != nil {
op.Done(err)
// Set up EDK2 NVRAM when on EFI.
if d.architectureSupportsUEFI(d.architecture) {
fi, err := os.Lstat(d.nvramPath())
if err != nil && !errors.Is(err, fs.ErrNotExist) {
return err
}

// Generate new NVRAM if missing, or if requested by the user or if the NVRAM file is of an invalid format (needs to be a valid symlink).
if util.IsTrue(d.localConfig["volatile.apply_nvram"]) || fi == nil || fi.Mode()&os.ModeSymlink != os.ModeSymlink {
err = d.setupNvram()
if err != nil {
op.Done(err)
return err
}
}
}

// Clear volatile.apply_nvram if set.
Expand Down
Loading