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

osbuild: fix virtiofs data loss; switch compression to off #3729

Closed
wants to merge 5 commits into from
Closed
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
4 changes: 3 additions & 1 deletion mantle/platform/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down Expand Up @@ -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")
Expand Down
15 changes: 11 additions & 4 deletions src/cmdlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/coreos.osbuild.aarch64.mpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -674,5 +674,5 @@ pipelines:
mpp-format-string: '{filename}'
format:
type: qcow2
compression: true
compression: false
compat: '1.1'
2 changes: 1 addition & 1 deletion src/coreos.osbuild.ppc64le.mpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -641,5 +641,5 @@ pipelines:
mpp-format-string: '{filename}'
format:
type: qcow2
compression: true
compression: false
compat: '1.1'
2 changes: 1 addition & 1 deletion src/coreos.osbuild.s390x.mpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -640,5 +640,5 @@ pipelines:
mpp-format-string: '{filename}'
format:
type: qcow2
compression: true
compression: false
compat: '1.1'
2 changes: 1 addition & 1 deletion src/coreos.osbuild.x86_64.mpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -680,5 +680,5 @@ pipelines:
mpp-format-string: '{filename}'
format:
type: qcow2
compression: true
compression: false
compat: '1.1'
22 changes: 12 additions & 10 deletions src/runvm-osbuild
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
3 changes: 0 additions & 3 deletions src/supermin-init-prelude.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading