Optimize image loading for Podman machines

Add support for loading images directly from machine paths to avoid
unnecessary file transfers when the image archive is already accessible
on the running machine through mounted directories.

Changes include:
- New /libpod/local/images/load API endpoint for direct machine loading
- Machine detection and path mapping functionality
- Fallback in tunnel mode to try optimized loading first

This optimization significantly speeds up image loading operations
when working with remote Podman machines by eliminating redundant
file transfers for already-accessible image archives.

Fixes: https://issues.redhat.com/browse/RUN-3249
Fixes: https://github.com/containers/podman/issues/26321

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
This commit is contained in:
Jan Rodák
2025-08-07 14:58:08 +02:00
parent 0a9d5ca75d
commit cfe4d46d89
11 changed files with 333 additions and 44 deletions

View File

@ -478,4 +478,32 @@ t GET images/json 200 \
t GET images/json?shared-size=true 200 \
.[0].SharedSize=0
TMPD=$(mktemp -d podman-apiv2-test.build.XXXXXXXX)
function cleanLoad() {
podman rmi -a -f
rm -rf "${TMPD}" &> /dev/null
}
podman pull quay.io/libpod/alpine:latest quay.io/libpod/busybox:latest
podman save -o ${TMPD}/test.tar quay.io/libpod/alpine:latest quay.io/libpod/busybox:latest
podman rmi quay.io/libpod/alpine:latest quay.io/libpod/busybox:latest
ABS_PATH=$( realpath "${TMPD}/test.tar" )
t POST libpod/local/images/load?path="${ABS_PATH}" 200
t GET libpod/images/quay.io/libpod/alpine:latest/exists 204
t GET libpod/images/quay.io/libpod/busybox:latest/exists 204
# Test with directory instead of file
mkdir -p ${TMPD}/testdir
t POST libpod/local/images/load?path="${TMPD}/testdir" 500
cleanLoad
t POST libpod/local/images/load?path="/tmp/notexisting.tar" 404
t POST libpod/local/images/load?invalid=arg 400
t POST libpod/local/images/load?path="" 400
t POST libpod/local/images/load?path="../../../etc/passwd" 404
# vim: filetype=sh