diff --git a/src/cmd-buildextend-metal b/src/cmd-buildextend-metal index 162bdf81c8..f229faebbb 100755 --- a/src/cmd-buildextend-metal +++ b/src/cmd-buildextend-metal @@ -234,20 +234,16 @@ 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") +target_device_opt="scsi-disk,drive=target,wwn=0x2a" # 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" \ - "-device" "${device_type},drive=target,physical_block_size=4096,logical_block_size=4096,scsi=off") + target_device_opt="${target_device_opt},physical_block_size=4096,logical_block_size=4096" fi +target_drive=("-drive" "if=none,id=target,format=${image_format},file=${path}.tmp,cache=unsafe" \ + "-device" "virtio-scsi-${devtype},id=scsitarget" "-device" "${target_device_opt}") runvm "${target_drive[@]}" -- \ /usr/lib/coreos-assembler/create_disk.sh \ - --disk /dev/vda \ --buildid "${build}" \ --imgid "${img}" \ --grub-script /usr/lib/coreos-assembler/grub.cfg \ diff --git a/src/create_disk.sh b/src/create_disk.sh index 192c17d11d..b499472b48 100755 --- a/src/create_disk.sh +++ b/src/create_disk.sh @@ -37,6 +37,7 @@ run as part of 'coreos-assembler build'. EOC } +disk= rootfs_size="0" boot_verity=0 rootfs_type="xfs" @@ -73,7 +74,25 @@ udevtrig() { export PATH=$PATH:/sbin:/usr/sbin arch="$(uname -m)" -disk="${disk:?--disk must be defined}" + +if [ -z "${disk:-}" ]; then + # hex 0x2a = 42 in decimal; this is set in cmd-buildextend-metal. + # We use the WWN as an unambiguous way to identify our target disk, + # independent of other devices attached to the VM (caches, etc.) + wwn=000000000000002a + for dev in /sys/block/*; do + if grep -F -e "${wwn}" "${dev}/device/wwid" 2>/dev/null; then + disk="/dev/$(basename ${dev})" + break + fi + done + if [ -z "${disk:-}" ]; then + echo "failed to find disk with wwn ${wwn}" 1>&2 + bash + exit 1 + fi +fi + buildid="${buildid:?--buildid must be defined}" imgid="${imgid:?--imgid must be defined}" ostree="${ostree:?--ostree-repo must be defined}" diff --git a/src/supermin-init-prelude.sh b/src/supermin-init-prelude.sh index 8b2eb78088..8f5cd87212 100644 --- a/src/supermin-init-prelude.sh +++ b/src/supermin-init-prelude.sh @@ -30,7 +30,7 @@ if [ -L "${workdir}"/src/config ]; then mount -t 9p -o rw,trans=virtio,version=9p2000.L source "${workdir}"/src/config fi mkdir -p "${workdir}"/cache /host/container-work -cachedev=$(blkid -lt LABEL=cosa-cache -o device) +cachedev=$(blkid -lt LABEL=cosa-cache -o device || true) if [ -n "${cachedev}" ]; then mount "${cachedev}" "${workdir}"/cache else