From bd5b673a99edf5a20d9265b7bd035113e2f6f32b Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Thu, 10 Feb 2022 23:36:22 +0100 Subject: [PATCH] distro: use FindMountable() to get root filesystem The `PartitionTable.FindMountable` method is the more generic version of `PartitionTable.RootFilesystem` which returns a `Mountable` interface, instead of a specific `Filesystem` object. This commit thus prepares for the more generic case, like when root is a Btrfs sub-volume. Co-Authored-By: Christian Kellner --- internal/distro/rhel84/distro.go | 8 ++++---- internal/distro/rhel85/pipelines.go | 4 ++-- internal/distro/rhel86/pipelines.go | 4 ++-- internal/distro/rhel90/pipelines.go | 6 +++++- internal/distro/rhel90beta/pipelines.go | 6 +++++- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/internal/distro/rhel84/distro.go b/internal/distro/rhel84/distro.go index bca3a4acc..00a21807d 100644 --- a/internal/distro/rhel84/distro.go +++ b/internal/distro/rhel84/distro.go @@ -402,13 +402,13 @@ func (t *imageType) pipeline(c *blueprint.Customizations, options distro.ImageOp panic("s390x image must have a partition table, this is a programming error") } - rootFs := pt.RootFilesystem() + rootFs := pt.FindMountable("/") if rootFs == nil { panic("s390x image must have a root filesystem, this is a programming error") } p.AddStage(osbuild.NewKernelCmdlineStage(&osbuild.KernelCmdlineStageOptions{ - RootFsUUID: rootFs.UUID, + RootFsUUID: rootFs.GetFSSpec().UUID, KernelOpts: t.kernelOptions, })) } @@ -646,13 +646,13 @@ func (t *imageType) grub2StageOptions(pt *disk.PartitionTable, kernelOptions str if pt == nil { panic("partition table must be defined for grub2 stage, this is a programming error") } - rootFs := pt.RootFilesystem() + rootFs := pt.FindMountable("/") if rootFs == nil { panic("root filesystem must be defined for grub2 stage, this is a programming error") } stageOptions := osbuild.GRUB2StageOptions{ - RootFilesystemUUID: uuid.MustParse(rootFs.UUID), + RootFilesystemUUID: uuid.MustParse(rootFs.GetFSSpec().UUID), KernelOptions: kernelOptions, Legacy: legacy, } diff --git a/internal/distro/rhel85/pipelines.go b/internal/distro/rhel85/pipelines.go index 30f3f97b5..66d687a64 100644 --- a/internal/distro/rhel85/pipelines.go +++ b/internal/distro/rhel85/pipelines.go @@ -63,11 +63,11 @@ func qcow2Pipelines(t *imageType, customizations *blueprint.Customizations, opti func prependKernelCmdlineStage(pipeline *osbuild.Pipeline, t *imageType, pt *disk.PartitionTable) *osbuild.Pipeline { if t.arch.name == distro.S390xArchName { - rootFs := pt.RootFilesystem() + rootFs := pt.FindMountable("/") if rootFs == nil { panic("s390x image must have a root filesystem, this is a programming error") } - kernelStage := osbuild.NewKernelCmdlineStage(osbuild.NewKernelCmdlineStageOptions(rootFs.UUID, t.kernelOptions)) + kernelStage := osbuild.NewKernelCmdlineStage(osbuild.NewKernelCmdlineStageOptions(rootFs.GetFSSpec().UUID, t.kernelOptions)) pipeline.Stages = append([]*osbuild.Stage{kernelStage}, pipeline.Stages...) } return pipeline diff --git a/internal/distro/rhel86/pipelines.go b/internal/distro/rhel86/pipelines.go index 9a12d5c8e..fa46c151f 100644 --- a/internal/distro/rhel86/pipelines.go +++ b/internal/distro/rhel86/pipelines.go @@ -42,11 +42,11 @@ func qcow2Pipelines(t *imageType, customizations *blueprint.Customizations, opti func prependKernelCmdlineStage(pipeline *osbuild.Pipeline, t *imageType, pt *disk.PartitionTable) *osbuild.Pipeline { if t.arch.name == distro.S390xArchName { - rootFs := pt.RootFilesystem() + rootFs := pt.FindMountable("/") if rootFs == nil { panic("s390x image must have a root filesystem, this is a programming error") } - kernelStage := osbuild.NewKernelCmdlineStage(osbuild.NewKernelCmdlineStageOptions(rootFs.UUID, t.kernelOptions)) + kernelStage := osbuild.NewKernelCmdlineStage(osbuild.NewKernelCmdlineStageOptions(rootFs.GetFSSpec().UUID, t.kernelOptions)) pipeline.Stages = append([]*osbuild.Stage{kernelStage}, pipeline.Stages...) } return pipeline diff --git a/internal/distro/rhel90/pipelines.go b/internal/distro/rhel90/pipelines.go index 128a0aaff..55eb65d19 100644 --- a/internal/distro/rhel90/pipelines.go +++ b/internal/distro/rhel90/pipelines.go @@ -41,7 +41,11 @@ func qcow2Pipelines(t *imageType, customizations *blueprint.Customizations, opti } func prependKernelCmdlineStage(pipeline *osbuild.Pipeline, t *imageType, pt *disk.PartitionTable) *osbuild.Pipeline { - rootFsUUID := pt.RootFilesystem().UUID + rootFs := pt.FindMountable("/") + if rootFs == nil { + panic("root filesystem must be defined for kernel-cmdline stage, this is a programming error") + } + rootFsUUID := rootFs.GetFSSpec().UUID kernelStage := osbuild.NewKernelCmdlineStage(osbuild.NewKernelCmdlineStageOptions(rootFsUUID, t.kernelOptions)) pipeline.Stages = append([]*osbuild.Stage{kernelStage}, pipeline.Stages...) return pipeline diff --git a/internal/distro/rhel90beta/pipelines.go b/internal/distro/rhel90beta/pipelines.go index 12d9abea1..424de2d33 100644 --- a/internal/distro/rhel90beta/pipelines.go +++ b/internal/distro/rhel90beta/pipelines.go @@ -58,7 +58,11 @@ func qcow2Pipelines(t *imageType, customizations *blueprint.Customizations, opti } func prependKernelCmdlineStage(pipeline *osbuild.Pipeline, t *imageType, pt *disk.PartitionTable) *osbuild.Pipeline { - rootFsUUID := pt.RootFilesystem().UUID + rootFs := pt.FindMountable("/") + if rootFs == nil { + panic("root filesystem must be defined for kernel-cmdline stage, this is a programming error") + } + rootFsUUID := rootFs.GetFSSpec().UUID kernelStage := osbuild.NewKernelCmdlineStage(osbuild.NewKernelCmdlineStageOptions(rootFsUUID, t.kernelOptions)) pipeline.Stages = append([]*osbuild.Stage{kernelStage}, pipeline.Stages...) return pipeline