diff --git a/mantle/platform/qemu.go b/mantle/platform/qemu.go index a9841597c9..939998431d 100644 --- a/mantle/platform/qemu.go +++ b/mantle/platform/qemu.go @@ -1071,6 +1071,8 @@ func (disk *Disk) prepare(builder *QemuBuilder) error { // on our own. if strings.HasSuffix(backingFile, "qcow2") { format = "qcow2" + } else if strings.HasSuffix(backingFile, "raw") { + format = "raw" } } if format != "" { @@ -1618,7 +1620,7 @@ func (builder *QemuBuilder) VirtioJournal(config *conf.Conf, queryArguments stri // createVirtiofsCmd returns a new command instance configured to launch virtiofsd. func createVirtiofsCmd(directory, socketPath string) exec.Cmd { - args := []string{"--sandbox", "none", "--socket-path", socketPath, "--shared-dir", "."} + args := []string{"--sandbox=none", "--cache=never", "--socket-path", socketPath, "--shared-dir", "."} // Work around https://gitlab.com/virtio-fs/virtiofsd/-/merge_requests/197 if os.Getuid() == 0 { args = append(args, "--modcaps=-mknod:-setfcap") diff --git a/src/cmdlib.sh b/src/cmdlib.sh index be616a912d..986e3f7483 100755 --- a/src/cmdlib.sh +++ b/src/cmdlib.sh @@ -753,17 +753,24 @@ export USER=$(id -u) export RUNVM_NONET=${RUNVM_NONET:-} $(cat "${DIR}"/supermin-init-prelude.sh) rc=0 -# tee to the virtio port so its output is also part of the supermin output in -# case e.g. a key msg happens in dmesg when the command does a specific operation +# - tee to the virtio port so its output is also part of the supermin output in +# case e.g. a key msg happens in dmesg when the command does a specific operation. +# - Use a subshell because otherwise init will use workdir as its cwd and we won't +# be able to unmount the virtiofs mount cleanly. This leads to consistency issues. if [ -z "${RUNVM_SHELL:-}" ]; then - bash ${tmp_builddir}/cmd.sh |& tee /dev/virtio-ports/cosa-cmdout || rc=\$? + (cd ${workdir}; bash ${tmp_builddir}/cmd.sh |& tee /dev/virtio-ports/cosa-cmdout) || rc=\$? else - bash; poweroff -f -f; sleep infinity + (cd ${workdir}; bash) fi echo \$rc > ${rc_file} if [ -n "\${cachedev}" ]; then /sbin/fstrim -v ${workdir}/cache + mount -o remount,ro ${workdir}/cache + fsfreeze -f ${workdir}/cache + fsfreeze -u ${workdir}/cache + umount ${workdir}/cache fi +umount ${workdir} /sbin/reboot -f EOF chmod a+x "${vmpreparedir}"/init diff --git a/src/coreos.osbuild.aarch64.mpp.yaml b/src/coreos.osbuild.aarch64.mpp.yaml index 2eb460e2db..8d652580df 100644 --- a/src/coreos.osbuild.aarch64.mpp.yaml +++ b/src/coreos.osbuild.aarch64.mpp.yaml @@ -674,5 +674,5 @@ pipelines: mpp-format-string: '{filename}' format: type: qcow2 - compression: true + compression: false compat: '1.1' diff --git a/src/coreos.osbuild.ppc64le.mpp.yaml b/src/coreos.osbuild.ppc64le.mpp.yaml index 669eabd7a0..f74cd68aa5 100644 --- a/src/coreos.osbuild.ppc64le.mpp.yaml +++ b/src/coreos.osbuild.ppc64le.mpp.yaml @@ -641,5 +641,5 @@ pipelines: mpp-format-string: '{filename}' format: type: qcow2 - compression: true + compression: false compat: '1.1' diff --git a/src/coreos.osbuild.s390x.mpp.yaml b/src/coreos.osbuild.s390x.mpp.yaml index 42f7e1f1a6..99a307c6b3 100644 --- a/src/coreos.osbuild.s390x.mpp.yaml +++ b/src/coreos.osbuild.s390x.mpp.yaml @@ -640,5 +640,5 @@ pipelines: mpp-format-string: '{filename}' format: type: qcow2 - compression: true + compression: false compat: '1.1' diff --git a/src/coreos.osbuild.x86_64.mpp.yaml b/src/coreos.osbuild.x86_64.mpp.yaml index 1d2569f353..ff34d0953d 100644 --- a/src/coreos.osbuild.x86_64.mpp.yaml +++ b/src/coreos.osbuild.x86_64.mpp.yaml @@ -680,5 +680,5 @@ pipelines: mpp-format-string: '{filename}' format: type: qcow2 - compression: true + compression: false compat: '1.1' diff --git a/src/runvm-osbuild b/src/runvm-osbuild index 348f5925cb..1a651d3e18 100755 --- a/src/runvm-osbuild +++ b/src/runvm-osbuild @@ -65,10 +65,11 @@ fi # Since it doesn't exist create loop-control mknod /dev/loop-control c 10 237 -# Tell osbuild to write out artifacts into a file in the root -# filesystem of the supermin VM, which is ephemeral. -mkdir /var/osbuild -outdir=/var/osbuild/out +# Put the store and the output dir on the cache. At the end we'll mv +# out the created artifact from the output dir to the place it's supposed +# to go. +outdir=cache/osbuild/out +storedir=cache/osbuild/store # Run through the preprocessor # Note: don't quote the size arguements since they are numbers, not strings @@ -82,17 +83,18 @@ osbuild-mpp \ -D metal_image_size_mb="${metal_image_size_mb}" \ -D cloud_image_size_mb="${cloud_image_size_mb}" \ "${mppyaml}" \ - /var/osbuild/processed.json + /processed.json # Build the image osbuild \ - --out "$outdir" \ - --store cache/osbuild/store/ \ + --out "$outdir" \ + --store "$storedir" \ --cache-max-size 9GiB \ --checkpoint tree \ --checkpoint raw-image \ - --export "$platform" /var/osbuild/processed.json + --export "$platform" /processed.json -# Copy it out to the specified location -cp "${outdir}/${platform}/${filename}" "${filepath}" +# Copy it out to the specified location. Use mv here so we remove it +# from the cache qcow2 so we don't cache it. +mv "${outdir}/${platform}/${filename}" "${filepath}" diff --git a/src/supermin-init-prelude.sh b/src/supermin-init-prelude.sh index 8cf8150d50..24eed7ea76 100644 --- a/src/supermin-init-prelude.sh +++ b/src/supermin-init-prelude.sh @@ -69,6 +69,3 @@ touch /etc/cosa-supermin # the missing link. Hehe. update-alternatives --install /etc/alternatives/iptables iptables /usr/sbin/iptables-legacy 1 update-alternatives --install /etc/alternatives/ip6tables ip6tables /usr/sbin/ip6tables-legacy 1 - -# https://github.com/koalaman/shellcheck/wiki/SC2164 -cd "${workdir}" || exit