boot

package
v2.42.5-go-mod+incompa... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBootNameAndRevisionNotReady = errors.New("boot revision not yet established")
)

Functions

func InUse

func InUse(name string, rev snap.Revision) bool

InUse checks if the given name/revision is used in the boot environment

func MakeBootable

func MakeBootable(model *asserts.Model, rootdir string, bootWith map[string]*snap.Info, unpackedGadgetDir string) error

MakeBootable sets up the image filesystem with the given rootdir such that it can be booted. bootWith is a map from the paths in the image seed for kernel and boot base to their snap info. This entails:

  • installing the bootloader configuration from the gadget
  • creating symlinks for boot snaps from seed to the runtime blob dir
  • setting boot env vars pointing to the revisions of the boot snaps to use
  • extracting kernel assets as needed by the bootloader

func MarkBootSuccessful

func MarkBootSuccessful() error

MarkBootSuccessful marks the current boot as successful. This means that snappy will consider this combination of kernel/os a valid target for rollback.

The states that a boot goes through are the following:

  • By default snap_mode is "" in which case the bootloader loads two squashfs'es denoted by variables snap_core and snap_kernel.
  • On a refresh of core/kernel snapd will set snap_mode=try and will also set snap_try_{core,kernel} to the core/kernel that will be tried next.
  • On reboot the bootloader will inspect the snap_mode and if the mode is set to "try" it will set "snap_mode=trying" and then try to boot the snap_try_{core,kernel}".
  • On a successful boot snapd resets snap_mode to "" and copies snap_try_{core,kernel} to snap_{core,kernel}. The snap_try_* values are cleared afterwards.
  • On a failing boot the bootloader will see snap_mode=trying which means snapd did not start successfully. In this case the bootloader will set snap_mode="" and the system will boot with the known good values from snap_{core,kernel}

Types

type BootKernel

type BootKernel interface {
	// RemoveKernelAssets removes the unpacked kernel/initrd for the given
	// kernel snap.
	RemoveKernelAssets() error
	// ExtractKernelAssets extracts kernel/initrd/dtb data from the given
	// kernel snap, if required, to a versioned bootloader directory so
	// that the bootloader can use it.
	ExtractKernelAssets(snap.Container) error
	// Is this a trivial implementation of the interface?
	IsTrivial() bool
}

A BootKernel handles the bootloader setup of a kernel.

func Kernel

func Kernel(s snap.PlaceInfo, t snap.Type, model Model, onClassic bool) BootKernel

Kernel checks that the given arguments refer to a kernel snap that participates in the boot process, and returns the associated BootKernel, or a trivial implementation otherwise.

type BootParticipant

type BootParticipant interface {
	// SetNextBoot will schedule the snap to be used in the next boot. For
	// base snaps it is up to the caller to select the right bootable base
	// (from the model assertion).
	SetNextBoot() error
	// ChangeRequiresReboot returns whether a reboot is required to switch
	// to the snap.
	ChangeRequiresReboot() bool
	// Is this a trivial implementation of the interface?
	IsTrivial() bool
}

A BootParticipant handles the boot process details for a snap involved in it.

func Participant

func Participant(s snap.PlaceInfo, t snap.Type, model Model, onClassic bool) BootParticipant

Participant figures out what the BootParticipant is for the given arguments, and returns it. If the snap does _not_ participate in the boot process, the returned object will be a NOP, so it's safe to call anything on it always.

Currently, on classic, nothing is a boot participant (returned will always be NOP).

type Model

type Model interface {
	Kernel() string
	Base() string
	Classic() bool
}

Model carries information about the model that is relevant to boot. Note *asserts.Model implements this, and that's the expected use case.

type NameAndRevision

type NameAndRevision struct {
	Name     string
	Revision snap.Revision
}

func GetCurrentBoot

func GetCurrentBoot(t snap.Type) (*NameAndRevision, error)

GetCurrentBoot returns the currently set name and revision for boot for the given type of snap, which can be snap.TypeBase (or snap.TypeOS), or snap.TypeKernel. Returns ErrBootNameAndRevisionNotReady if the values are temporarily not established.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL