Skip to content

Commit

Permalink
WIP: Add metal4k build artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
jlebon committed Feb 13, 2020
1 parent 09eb6b7 commit 6cc1489
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
36 changes: 23 additions & 13 deletions src/cmd-buildextend-metal
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dn=$(dirname "$0")
# image (qemu). `buildextend-qemu` is a symlink to `buildextend-metal`.
case "$(basename "$0")" in
"cmd-buildextend-metal") image_type=metal;;
"cmd-buildextend-metal4k") image_type=metal4k;;
"cmd-buildextend-dasd") image_type=dasd;;
"cmd-buildextend-qemu") image_type=qemu;;
*) fatal "called as unexpected name $0";;
Expand Down Expand Up @@ -137,9 +138,8 @@ img=${name}-${build}-${image_type}.${basearch}.${image_format}
path=${PWD}/${img}

ignition_platform_id="${image_type}"
# dasd is a different disk format, but it's still metal. Just like
# if in the future we introduce a 4k sector size x86_64 image type (metal-4k).
if [ "${image_type}" = dasd ]; then
# dasd and metal4k are different disk formats, but they're still metal
if [ "${image_type}" = dasd ] || [ "${image_type}" = metal4k ]; then
ignition_platform_id=metal
fi

Expand Down Expand Up @@ -171,13 +171,17 @@ echo "Disk size estimated to ${image_size}"

# For bare metal and dasd images, we use the estimated image size. For IaaS/virt, we get it from
# image.yaml because we want a "default" disk size that has some free space.
if [[ "${image_type}" = metal || "${image_type}" = dasd ]]; then
# Unset the root size, which will inherit from the image size
rootfs_size=0
else
image_size="$(python3 -c 'import sys, yaml; print(yaml.safe_load(sys.stdin)["size"])' < "$configdir/image.yaml")G"
rootfs_size="${rootfs_size}M"
fi
case "${image_type}" in
metal*|dasd)
# Unset the root size, which will inherit from the image size
rootfs_size=0
;;
qemu)
image_size="$(python3 -c 'import sys, yaml; print(yaml.safe_load(sys.stdin)["size"])' < "$configdir/image.yaml")G"
rootfs_size="${rootfs_size}M"
;;
*) fatal "unreachable image_type ${image_type}";;
esac

disk_args=()

Expand Down Expand Up @@ -225,12 +229,18 @@ ref_arg=${ref}
if [ -n "${ref_is_temp}" ]; then
ref_arg=${commit}
fi

target_drive=("-drive" "if=virtio,id=target,format=${image_format},file=${path}.tmp,cache=unsafe")
if [[ $image_format == raw && $image_type == dasd ]]; then
# we need 4096 block size for ECKD DASD and (obviously) metal4k
if [[ $image_type == dasd || $image_type == metal4k ]]; then
device_type=virtio-blk
if [[ $image_type == dasd ]]; then
device_type=virtio-blk-ccw
fi
target_drive=("-drive" "if=none,id=target,format=${image_format},file=${path}.tmp,cache=unsafe" \
# we need 4096 block size for ECKD DASD
"-device" "virtio-blk-ccw,drive=target,physical_block_size=4096,logical_block_size=4096,scsi=off")
"-device" "${device_type},drive=target,physical_block_size=4096,logical_block_size=4096,scsi=off")
fi

runvm "${target_drive[@]}" -- \
/usr/lib/coreos-assembler/create_disk.sh \
--disk /dev/vda \
Expand Down
1 change: 1 addition & 0 deletions src/cmd-buildextend-metal4k

0 comments on commit 6cc1489

Please sign in to comment.