Skip to content

Commit

Permalink
pillar: Separate OVMF firmware files and standardize naming.
Browse files Browse the repository at this point in the history
Switch to using separate OVMF_CODE.fd and OVMF_VARS.fd files for FML and
ARM modes instead of a combined .bin file. This ensures that settings
are stored correctly and maintains consistent naming conventions. These
changes do not affect containers or Xen.

Signed-off-by: Nikolay Martyanov <nikolay@zededa.com>
  • Loading branch information
OhmSpectator committed Sep 18, 2024
1 parent ef09815 commit 71f0a65
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pkg/pillar/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ RUN set -e && for patch in /sys-patches/*.patch; do \
done

RUN mkdir -p /out/usr/lib/xen/boot
COPY --from=uefi-build /OVMF_VARS.fd /out/usr/lib/xen/boot/ovmf_vars.bin
COPY --from=uefi-build /OVMF_VARS.fd /out/usr/lib/xen/boot/OVMF_VARS.fd

COPY --from=zfs /out /out
COPY --from=fscrypt /opt/zededa/bin /out/opt/zededa/bin
Expand Down
2 changes: 1 addition & 1 deletion pkg/pillar/cmd/zedmanager/handledomainmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func MaybeAddDomainConfig(ctx *zedmanagerContext,
}
}
if dc.BootLoader == "" && (dc.VirtualizationModeOrDefault() == types.FML || runtime.GOARCH == "arm64") {
dc.BootLoader = "/usr/lib/xen/boot/ovmf.bin"
dc.BootLoader = "/usr/lib/xen/boot/OVMF_CODE.fd"
}
if ns != nil {
adapterCount := len(ns.AppNetAdapterList)
Expand Down
2 changes: 1 addition & 1 deletion pkg/pillar/hypervisor/kvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ func vmmOverhead(domainName string, domainUUID uuid.UUID, domainRAMSize int64, v
}

func getOVMFSettingsFile(domainName string) string {
return types.OVMFSettingsDir + "/" + domainName + "_ovmf_vars.bin"
return types.OVMFSettingsDir + "/" + domainName + "_OVMF_VARS.fd"
}

func prepareOVMFSettings(domainName string) (string, error) {
Expand Down
16 changes: 8 additions & 8 deletions pkg/pillar/hypervisor/kvm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func TestCreateDomConfigOnlyCom1(t *testing.T) {
})

config.VirtualizationMode = types.FML
config.BootLoader = "/usr/lib/xen/boot/ovmf.bin"
config.BootLoader = "/usr/lib/xen/boot/OVMF_CODE.fd"
config.BootLoaderSettingsFile = "/persist/ovmf/0000000000000000.0.0_OVMF_VARS.fd"
t.Run("amd64-fml", func(t *testing.T) {
conf.Seek(0, 0)
Expand Down Expand Up @@ -421,7 +421,7 @@ func TestCreateDomConfigOnlyCom1(t *testing.T) {
format = "raw"
readonly = "on"
unit = "0"
file = "/usr/lib/xen/boot/ovmf.bin"
file = "/usr/lib/xen/boot/OVMF_CODE.fd"
[drive "drive-ovmf-vars"]
if = "pflash"
Expand Down Expand Up @@ -649,7 +649,7 @@ func TestCreateDomConfigOnlyCom1(t *testing.T) {
})

config.VirtualizationMode = types.HVM
config.BootLoader = "/usr/lib/xen/boot/ovmf.bin"
config.BootLoader = "/usr/lib/xen/boot/OVMF_CODE.fd"
t.Run("arm64", func(t *testing.T) {
conf.Seek(0, 0)
if err := kvmArm.CreateDomConfig("test", config, types.DomainStatus{},
Expand All @@ -673,7 +673,7 @@ func TestCreateDomConfigOnlyCom1(t *testing.T) {
dump-guest-core = "off"
accel = "kvm:tcg"
gic-version = "host"
firmware = "/usr/lib/xen/boot/ovmf.bin"
firmware = "/usr/lib/xen/boot/OVMF_CODE.fd"
kernel = "/boot/kernel"
initrd = "/boot/ramdisk"
append = "init=/bin/sh"
Expand Down Expand Up @@ -967,7 +967,7 @@ func TestCreateDomConfigAmd64Fml(t *testing.T) {
diskConfigs, diskStatuses := qemuDisks()
config, aa := domainConfigAndAssignableAdapters(diskConfigs)
config.VirtualizationMode = types.FML
config.BootLoader = "/usr/lib/xen/boot/ovmf.bin"
config.BootLoader = "/usr/lib/xen/boot/OVMF_CODE.fd"
config.BootLoaderSettingsFile = "/persist/ovmf/0000000000000000.0.0_OVMF_VARS.fd"
addNonExistingAdapter(&config, &aa)
if err := kvmIntel.CreateDomConfig("test", config, types.DomainStatus{},
Expand Down Expand Up @@ -1001,7 +1001,7 @@ func TestCreateDomConfigArm64(t *testing.T) {
diskConfigs, diskStatuses := qemuDisks()
config, aa := domainConfigAndAssignableAdapters(diskConfigs)
config.VirtualizationMode = types.HVM
config.BootLoader = "/usr/lib/xen/boot/ovmf.bin"
config.BootLoader = "/usr/lib/xen/boot/OVMF_CODE.fd"
if err := kvmArm.CreateDomConfig("test", config, types.DomainStatus{},
diskStatuses, &aa, nil, swtpmCtrlSock, conf); err != nil {
t.Errorf("CreateDomConfig failed %v", err)
Expand Down Expand Up @@ -1146,7 +1146,7 @@ func domConfigArm64() string {
dump-guest-core = "off"
accel = "kvm:tcg"
gic-version = "host"
firmware = "/usr/lib/xen/boot/ovmf.bin"
firmware = "/usr/lib/xen/boot/OVMF_CODE.fd"
kernel = "/boot/kernel"
initrd = "/boot/ramdisk"
append = "init=/bin/sh"
Expand Down Expand Up @@ -1443,7 +1443,7 @@ func domConfigAmd64FML() string {
format = "raw"
readonly = "on"
unit = "0"
file = "/usr/lib/xen/boot/ovmf.bin"
file = "/usr/lib/xen/boot/OVMF_CODE.fd"
[drive "drive-ovmf-vars"]
if = "pflash"
Expand Down
2 changes: 1 addition & 1 deletion pkg/pillar/types/locationconsts.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const (
// OVMFSettingsDir - directory for OVMF settings, they are stored in per-domain files
OVMFSettingsDir = PersistDir + "/ovmf"
// OVMFSettingsTemplate - template file for OVMF settings
OVMFSettingsTemplate = "/usr/lib/xen/boot/ovmf_vars.bin"
OVMFSettingsTemplate = "/usr/lib/xen/boot/OVMF_VARS.fd"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion pkg/xen-tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ RUN if [ "$(uname -m)" = "x86_64" ]; then rm -f qemu-system-i386 && ln -s "qemu-

COPY --from=uefi-build / /uefi/
RUN mkdir -p /out/usr/lib/xen/boot && cp /uefi/OVMF.fd /out/usr/lib/xen/boot/ovmf.bin && \
cp /uefi/OVMF_PVH.fd /out/usr/lib/xen/boot/ovmf-pvh.bin
cp /uefi/OVMF_PVH.fd /out/usr/lib/xen/boot/ovmf-pvh.bin && \
cp /uefi/OVMF_CODE.fd /out/usr/lib/xen/boot/OVMF_CODE.fd
RUN if [ "$(uname -m)" = "x86_64" ]; then cp /uefi/*.rom /out/usr/lib/xen/boot/;fi

FROM scratch
Expand Down

0 comments on commit 71f0a65

Please sign in to comment.