Skip to content

Commit

Permalink
[antlir1][vm] remove initrd targets and most disk API
Browse files Browse the repository at this point in the history
Summary:
All users are migrated to antlir2. Clean up disk and initrd targets
and API. There are still some more complicated customer images that are not
migrated to antlir2 and requires antlir1 control layer. Thus that part is left
behind, but they are invoked through metalos/vm, instead of directly. (fbgs
rootfs_layer_is_antlir1 will find them.)

Test Plan: CI

Reviewed By: vmagro

Differential Revision: D51207836

fbshipit-source-id: 71b42c0074cc182c51902167a62dcb4bce0c27b1
  • Loading branch information
wujj123456 authored and facebook-github-bot committed Nov 13, 2023
1 parent 535c6a1 commit 5431469
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 210 deletions.
4 changes: 2 additions & 2 deletions antlir/bzl/linux/boot/ble_build.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ load("//antlir/antlir2/bzl/feature:defs.bzl", "feature")
load("//antlir/antlir2/bzl/image:defs.bzl", "image")
load("//antlir/antlir2/bzl/package:defs.bzl", "package")
load("//antlir/bzl:shape.bzl", "shape")
load("//antlir/bzl:target_helpers.bzl", "antlir_dep")
load("//antlir/vm/bzl:initrd.bzl", "initrd")
load(":boot_loader_entry.shape.bzl", "boot_loader_entry_t")

def ble_build(
Expand Down Expand Up @@ -41,7 +41,7 @@ def ble_build(

features.extend([
feature.install(
src = antlir_dep("vm/initrd:{}-initrd".format(kernel.uname)),
src = initrd(arch = kernel.arch, uname = kernel.uname),
dst = "/initrd-{}.img".format(kernel.uname),
),
feature.install(
Expand Down
11 changes: 0 additions & 11 deletions antlir/vm/bzl/BUCK

This file was deleted.

3 changes: 0 additions & 3 deletions antlir/vm/bzl/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ antlir2/antlir2_vm/bzl/defs.bzl.
"""

load("//antlir/bzl:constants.bzl", "REPO_CFG")
load(":types.bzl", "api")

vm = struct(
# This nested structure is for looking up the default set of artifacts
Expand All @@ -19,6 +18,4 @@ vm = struct(
layer = REPO_CFG.artifact["vm.rootfs.layer"],
),
),
# API export for building vm_opt_t and related types
types = api,
)
75 changes: 9 additions & 66 deletions antlir/vm/bzl/initrd.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,13 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

load("@bazel_skylib//lib:paths.bzl", "paths")
load("//antlir/antlir2/bzl/feature:defs.bzl?v2_only", "feature")
load("//antlir/antlir2/bzl/image:defs.bzl?v2_only", "image")
load("//antlir/antlir2/bzl/package:defs.bzl?v2_only", "package")
load("//antlir/bzl:build_defs.bzl", "get_visibility")
load("//antlir/bzl:systemd.bzl", "systemd")
load("//antlir/bzl:types.bzl", "types")
load("//metalos/kernel:kernel.shape.bzl", "kernel_t")

_KERNEL_T = types.shape(kernel_t)
_OPT_STR = types.optional(types.str)
_OPT_VISIBILITY = types.optional(types.visibility)

types.lint_noop(_KERNEL_T, _OPT_STR, _OPT_VISIBILITY)

def initrd(
kernel: _KERNEL_T,
*,
name: _OPT_STR = None,
features = None,
visibility: _OPT_VISIBILITY = None):
"""
Construct an initrd (gzipped cpio archive) that can be used to boot this
kernel in a virtual machine.
def initrd(arch: str, uname: str):
""" Get the initrd target based on arch and uname.
Initrd data isn't really antlir's business, but some of our images need it.
MetalOS initrd is our only option, but we don't want to import its code. So
we hardcode target path here for now. Ideally, either we include some OSS
initrd, or we set this as a REPO_CFG so it's easier to specify where initrd
targets live.
"""

if not name:
name = "{}-initrd".format(kernel.uname)
visibility = get_visibility(visibility)

# Build an initrd specifically for operating as a VM. This is built on top of the
# MetalOS initrd and modified to support 9p shared mounts for the repository,
# kernel modules, and others.

image.layer(
name = name + "-layer",
parent_layer = "//metalos/initrd:initrd",
visibility = visibility,
features = [
feature.ensure_subdirs_exist(
into_dir = "/usr/lib",
subdirs_to_create = "modules-load.d",
),
feature.install(
src = "//antlir/vm/initrd:modules.conf",
dst = "/usr/lib/modules-load.d/vm.conf",
),
feature.ensure_subdirs_exist(
into_dir = "/usr/lib",
subdirs_to_create = "modules",
),
feature.install(
src = kernel.derived_targets.disk_boot_modules,
dst = paths.join("/usr/lib/modules", kernel.uname) + "/",
),
systemd.install_dropin("//antlir/vm/initrd:reboot-on-fail.conf", "default.target", use_antlir2 = True),
systemd.install_dropin("//antlir/vm/initrd:reboot-on-fail.conf", "metalos-init.service", use_antlir2 = True),
# vm has no network
systemd.skip_unit("systemd-networkd-wait-online.service", use_antlir2 = True),
] + (features or []),
)

package.cpio_gz(
name = name,
layer = ":" + name + "-layer",
visibility = visibility,
)
return "//metalos/vm/initrd:vm-{}-{}-initrd".format(arch, uname)
91 changes: 0 additions & 91 deletions antlir/vm/bzl/types.bzl

This file was deleted.

28 changes: 0 additions & 28 deletions antlir/vm/bzl/vm.shape.bzl

This file was deleted.

10 changes: 1 addition & 9 deletions antlir/vm/initrd/BUCK
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
load("//antlir/bzl:build_defs.bzl", "export_file", "is_buck2")
load("//antlir/bzl:kernel_shim.bzl", "kernels")
load("//antlir/vm/bzl:initrd.bzl", "initrd")
load("//antlir/bzl:build_defs.bzl", "export_file")

oncall("antlir")

Expand All @@ -13,9 +11,3 @@ export_file(
name = "reboot-on-fail.conf",
visibility = ["PUBLIC"],
)

# build a vmtest initrd for every kernel
[initrd(
kernel = kernels.get(uname),
visibility = ["PUBLIC"],
) for uname in kernels.all_kernels] if is_buck2() else None

0 comments on commit 5431469

Please sign in to comment.