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

refactor: adds GCP support, refactors machine, kernel and image configuration #20

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
24 changes: 13 additions & 11 deletions conf/distro/cvm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ FULL_OPTIMIZATION="-Os -pipe ${DEBUG_FLAGS}"
# Distro config is evaluated after the machine config, so we have to explicitly
# set the kernel provider to override a machine config.
PREFERRED_PROVIDER_virtual/kernel = "linux-yocto-tiny"
PREFERRED_VERSION_linux-yocto-tiny ?= "6.6%"
PREFERRED_VERSION_linux-yocto-tiny ?= "6.10%"

# We can use packagegroup-core-boot, but in the future we may need a new packagegroup-core-tiny
#POKY_DEFAULT_EXTRA_RDEPENDS += "packagegroup-core-boot"
Expand All @@ -65,7 +65,7 @@ IMAGE_LINGUAS = ""

# Comment out any of the lines below to disable them in the build
# DISTRO_FEATURES options:
DISTRO_FEATURES_TINY = "pci ext4"
DISTRO_FEATURES_TINY = "pci ext4 sysvinit"
DISTRO_FEATURES_CVM = "cvm"
DISTRO_FEATURES_NET = "ipv4 ipv6"

Expand All @@ -76,14 +76,11 @@ DISTRO_FEATURES = "${DISTRO_FEATURES_TINY} \

CVM_DISTRO_FEATURES_NATIVE = "acl debuginfod ext2 ipv4 ipv6 xattr nfs zeroconf pci vfat seccomp ptest"

DISTRO_FEATURES:class-native = "${CVM_DISTRO_FEATURES_NATIVE} tpm2"
DISTRO_FEATURES:class-nativesdk = "${CVM_DISTRO_FEATURES_NATIVE} tpm2"
#DISTRO_FEATURES:class-native = "${CVM_DISTRO_FEATURES_NATIVE} tpm2"
#DISTRO_FEATURES:class-nativesdk = "${CVM_DISTRO_FEATURES_NATIVE} tpm2"
Comment on lines +79 to +80
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of commenting them out, we can remove them right?


# add /dev/sd* disk config
KERNEL_EXTRA_FEATURES:append = " features/scsi/disk.scc"

# enable mdev/busybox for init
#POKY_INIT_MANAGER:cvm = "mdev-busybox"
DISTRO_EXTRA_RDEPENDS = "date-sync ca-certificates"
DISTRO_EXTRA_RDEPENDS:append = '${@bb.utils.contains_any("IMAGE_FEATURES", [ "debug-tweaks" ], " dropbear", "",d)}'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should consider making the dropbear (ssh access) not tightly coupled with debug-tweaks in the image features in case we want to have ssh access to the machine but not necessarily building it with debug tweaks.
Do you know by change what debug-tweaks add to the image when adding it to the IMAGE_FEAUTRES?
I mean beside giving root access without password? It probably sets the image in debugging state and add some debugging info and symbols to the image, which in practice would have "some" impact on the performance.


# FIXME: Consider adding "modules" to MACHINE_FEATURES and using that in
# packagegroup-core-base to select modutils-initscripts or not. Similar with "net" and
Expand All @@ -93,10 +90,10 @@ KERNEL_EXTRA_FEATURES:append = " features/scsi/disk.scc"
# pulls in a lot of dependencies for the live image and the installer, like
# udev, grub, etc. These pull in gettext, which fails to build with wide
# character support.
IMAGE_FSTYPES = "wic wic.vhd"
IMAGE_FSTYPES = "wic"
QB_DEFAULT_FSTYPE = "wic"

INITRAMFS_IMAGE = "cvm-initramfs"
INITRAMFS_IMAGE = "core-image-tiny-initramfs"

# Drop v86d from qemu dependency list (we support serial)
# Drop grub from meta-intel BSPs
Expand All @@ -121,3 +118,8 @@ SKIP_RECIPE[core-image-weston] = "not buildable with poky-tiny"

# Disable python usage in opkg-utils since it won't build with tiny config
PACKAGECONFIG:remove:pn-opkg-utils = "python"

# add cvm.scc cfg changes
KERNEL_FEATURES:append:pn-linux-yocto-tiny = " cvm.scc"
KERNEL_FEATURES:append:pn-linux-yocto = " cvm.scc"
KERNEL_FEATURES:append:pn-linux-yocto-rt = " cvm.scc"
13 changes: 13 additions & 0 deletions conf/machine/include/gcp.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
MACHINEOVERRIDES =. "gcp:"

# gcp tdx depends on kvm and virtio
KERNEL_FEATURES:append:pn-linux-yocto-tiny = " gcp.scc cfg/virtio.scc cfg/paravirt_kvm.scc"
KERNEL_FEATURES:append:pn-linux-yocto = " gcp.scc cfg/virtio.scc cfg/paravirt_kvm.scc"
KERNEL_FEATURES:append:pn-linux-yocto-rt = " gcp.scc cfg/virtio.scc cfg/paravirt_kvm.scc"

# gcp is not compatible with udhcpc, needs dhcpcd
MACHINE_ESSENTIAL_EXTRA_RDEPENDS:append = " dhcpcd"


# doesnt work, no idea why
# IMAGE_FSTYPES:append = " wic.tar.gz"
12 changes: 12 additions & 0 deletions conf/machine/include/hyperv.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
MACHINEOVERRIDES =. "hyperv:"

# Provide the tdx guest driver kernel module for all images
KERNEL_FEATURES:append:pn-linux-yocto-tiny = " hyperv.scc features/tpm/tpm-2.0.scc features/tpm/tpm-2.0-crb.scc"
KERNEL_FEATURES:append:pn-linux-yocto = " hyperv.scc features/tpm/tpm-2.0.scc features/tpm/tpm-2.0-crb.scc"
KERNEL_FEATURES:append:pn-linux-yocto-rt = " hyperv.scc features/tpm/tpm-2.0.scc features/tpm/tpm-2.0-crb.scc"


MACHINE_FEATURES:append = " tpm2"

# doesnt work, no idea why
# IMAGE_FSTYPES:append:core-image-minimal = " wic.vhd"
Comment on lines +11 to +12
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't we have that before working as part of the cvm-image-azure custom image?

6 changes: 6 additions & 0 deletions conf/machine/include/qemu-x86.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
KERNEL_FEATURES:append:pn-linux-yocto-tiny = " cfg/virtio.scc cfg/paravirt_kvm.scc"
KERNEL_FEATURES:append:pn-linux-yocto = " cfg/virtio.scc cfg/paravirt_kvm.scc"
KERNEL_FEATURES:append:pn-linux-yocto-rt = " cfg/virtio.scc cfg/paravirt_kvm.scc"

# doesnt work, no idea why
# IMAGE_FSTYPES:append:core-image-minimal = " wic.qcow2"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here as the comment above 🤔

8 changes: 8 additions & 0 deletions conf/machine/include/sev-snp-guest.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require conf/machine/include/x86.inc

MACHINEOVERRIDES =. "sev-snp-guest:"

# Provide the tdx guest driver kernel module for all images
KERNEL_FEATURES:append:pn-linux-yocto-tiny = " sev-snp-guest.scc"
KERNEL_FEATURES:append:pn-linux-yocto = " sev-snp-guest.scc"
KERNEL_FEATURES:append:pn-linux-yocto-rt = " sev-snp-guest.scc"
8 changes: 8 additions & 0 deletions conf/machine/include/tdx-guest.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require conf/machine/include/x86.inc

MACHINEOVERRIDES =. "tdx-guest:"

# Provide the tdx guest driver kernel module for all images
KERNEL_FEATURES:append:pn-linux-yocto-tiny = " tdx-guest.scc"
KERNEL_FEATURES:append:pn-linux-yocto = " tdx-guest.scc"
KERNEL_FEATURES:append:pn-linux-yocto-rt = " tdx-guest.scc"
Comment on lines +6 to +8
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aren't we only using the linux yocto tiny? why do we need to adjust the other ones too if we don't necessarily use them in any other image?

18 changes: 18 additions & 0 deletions conf/machine/include/x86.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
DEFAULTTUNE ?= "x86-64-v3"

require conf/machine/include/x86/tune-x86-64-v3.inc

KERNEL_IMAGETYPE = "bzImage"
SERIAL_CONSOLES ?= "115200;ttyS0 115200;ttyS1"

MACHINE_FEATURES:append = "x86 pci"

do_image_wic[depends] += "syslinux:do_populate_sysroot syslinux-native:do_populate_sysroot mtools-native:do_populate_sysroot dosfstools-native:do_populate_sysroot"

# For runqemu
IMAGE_CLASSES += "qemuboot"

QB_CPU:x86-64 ?= "-cpu IvyBridge -machine q35,i8042=off"
QB_CPU_KVM:x86-64 ?= "-cpu IvyBridge -machine q35,i8042=off"

QB_SYSTEM_NAME = "qemu-system-x86_64"
6 changes: 6 additions & 0 deletions conf/machine/sev-snp-azure.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#@TYPE: Machine
#@NAME: Azure x86-64 SEV-SNP enabled machine
#@DESCRIPTION: Machine configuration for running a SEV-SNP enabled x86-64 system on Azure

require conf/machine/include/sev-snp-guest.inc
require conf/machine/include/hyperv.inc
43 changes: 0 additions & 43 deletions conf/machine/sev-snp.conf

This file was deleted.

6 changes: 6 additions & 0 deletions conf/machine/tdx-azure.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#@TYPE: Machine
#@NAME: Azure x86-64 tdx enabled machine
#@DESCRIPTION: Machine configuration for running a TDX enabled x86-64 system on Azure

require conf/machine/include/tdx-guest.inc
require conf/machine/include/hyperv.inc
6 changes: 6 additions & 0 deletions conf/machine/tdx-gcp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#@TYPE: Machine
#@NAME: GCP x86-64 tdx enabled machine
#@DESCRIPTION: Machine configuration for running a TDX enabled x86-64 system on GCP

require conf/machine/include/tdx-guest.inc
require conf/machine/include/gcp.inc
6 changes: 6 additions & 0 deletions conf/machine/tdx-qemu.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#@TYPE: Machine
#@NAME: QEMU x86-64 tdx enabled machine
#@DESCRIPTION: Machine configuration for running an x86-64 system on QEMU

require conf/machine/include/qemu-x86.inc
require conf/machine/include/tdx-guest.inc
43 changes: 0 additions & 43 deletions conf/machine/tdx.conf

This file was deleted.

16 changes: 16 additions & 0 deletions recipes-core/images/core-image-minimal.bbappend
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
SUMMARY = "Placeholder image to using IMAGE_FSTYPES to create wic based images of the initramfs."

IMAGE_INSTALL = ""

IMAGE_LINGUAS = " "

# override vhd conversion cmd - azure rquirements of virtual size aligned to 1 MiB
CONVERSION_CMD:vhd:prepend = "truncate -s %1MiB ${IMAGE_NAME}.wic; \
qemu-img convert -O vpc -o subformat=fixed,force_size ${IMAGE_NAME}.wic ${IMAGE_NAME}.wic.vhd; \
echo "

CONVERSION_CMD:tar = "tar --format=oldgnu -Scf ${IMAGE_NAME}.${type}.tar --transform='s|${IMAGE_NAME}.${type}|disk.raw|' ${IMAGE_NAME}.${type}"
CONVERSION_DEPENDS_tar = "tar-native"
CONVERSIONTYPES:append = " tar"

IMAGE_FSTYPES:append = " wic.tar.gz wic.vhd wic.qcow2"
8 changes: 8 additions & 0 deletions recipes-core/images/core-image-tiny-initramfs.bbappend
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PACKAGE_INSTALL = "${DISTRO_EXTRA_RDEPENDS} packagegroup-core-boot ${VIRTUAL-RUNTIME_base-utils} ${VIRTUAL-RUNTIME_dev_manager} base-passwd ${ROOTFS_BOOTSTRAP_INSTALL}"

IMAGE_FEATURES = "${EXTRA_IMAGE_FEATURES}"

INITRAMFS_MAXSIZE = "20000000"

python tinyinitrd () {
}
Comment on lines +7 to +8
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is piece needed ?

21 changes: 0 additions & 21 deletions recipes-core/images/cvm-image-azure.bb

This file was deleted.

60 changes: 0 additions & 60 deletions recipes-core/images/cvm-initramfs.bb

This file was deleted.

Loading