935 Commits

Author SHA1 Message Date
1751612f33 Handle SIGPIPE to prevent machine stuck in Starting state
Fixes: #26949
Signed-off-by: Jiri Dostal <jdostal@redhat.com>
2025-09-22 13:15:25 +00:00
cd08b088f6 windows: do not convert unconfined seccomp path
unconfined is a special value and not a path as such it must not be
converted otherwise --security-opt seccomp=unconfined fails as it tries
to access a file called unconfined.

Fixes: 3e8b2d7d96 ("Fix seccomp profile path on Windows")
Fixes: #26855

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-08-21 11:56:47 +00:00
73f3e98947 Feat: send additional build contexts for remote builds
Fixed the --build-context flag to properly send files for remote builds. Previously
only the main context was sent over as a tar while additional contexts were passed as
local paths and this would cause builds to fail since the files wouldn't exist.

New changes modifies the Build API to use multipart HTTP requests allowing multiple
build contexts to be used. Each additional context is packaged and
transferred based on its type:
- Local Directories: Sent as tar archives
- Git Repositories: link sent to the server where its then cloned
- Container Images: Image reference sent to the server, it then pulls the image there
- URLs/archives: URL sent to the server, which handles the download

Fixes: #23433

Signed-off-by: Joshua Arrevillaga <2004jarrevillaga@gmail.com>
2025-07-23 11:34:38 -04:00
68e7136536 Enforce wsl.exe UTF-8 encoded output
Currently WSL uses UTF-16 encoded output by default but is planning
to use UTF-8.

See https://github.com/containers/podman/issues/26527

To get ready for the change we are enforcing UTF-8 encoded output by
setting the environment variable `WSL_UTF8=1` and by updating the
code that transfomed wsl output from UTF-16 to UTF-8.

Fixes https://github.com/containers/podman/issues/26527

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2025-07-02 20:18:52 +00:00
9fbe2fffe9 WSL commands execution refactoring
Introduced a new function to encapsulate the code to execute WSL
commands.

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2025-07-02 20:18:52 +00:00
6355a15082 Merge pull request #25922 from jakecorrenti/krunkit-cmdline
machine: enable nested virt on libkrun by default
2025-07-01 13:39:19 +00:00
1a3b35673d Merge pull request #26461 from Luap99/deadcode
remove deadcode
2025-06-26 19:36:02 +00:00
f3c82a917c pkg/machine: remove deadcode
Yes this is a lot.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-26 19:37:15 +02:00
2ef0148b8a machine: enable nested virt on libkrun by default
With the recent release of krunkit 0.2.0, a CLI option was added to
enable nested virtualization on macOS hosts with an M3 or higher. Enable
this by default. If the host does not support this feature, krunkit will
ignore the argument and continue starting the VM.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2025-06-26 09:53:06 -04:00
e00dfa606a pkg/machine/e2e: add CVE-2025-6032 regression test
Setup a local web server both for HTTP and HTTPS and make sure the
client rejects the connection and does not try to pull the image.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-25 19:27:45 +02:00
726b506acc machine init: fix tls check
Ensure we verify the TLS connection when pulling the OCI image.

Fixes: CVE-2025-6032

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-23 14:12:55 +02:00
60859b07b7 Merge pull request #26201 from lstocchi/wsl
fix wsl install workflow on machine init command
2025-06-13 09:43:50 +00:00
22789928d4 podman machine: pull wsl image from machine-os
Starting with [1] we now build and publish the wsl image from the
machine-os repo, as such this special case is no longer needed.

[1] https://github.com/containers/podman-machine-os/pull/142

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-10 18:09:21 +02:00
0f7b21ad00 pkg/machine: remove unsused net recover file
This is not used in the code so it can be deleted.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-06 19:46:05 +02:00
0c77654be7 Revert "podman machine: fix proxy test"
This reverts commit 0b8dd9084010b1d444d7362c5be6704843c21aba.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-06 19:46:05 +02:00
adc35b157e pkg/machine: remove old fw_cfg service
It has not been in use since commit f218f8430a and should have been
removed there. It seems somehow it is causing a bug since our env file
is empty. In that case it triggers a segfault and since that happens
from within pam we are unable to login in any way.

I reported the issue[1] but because we don't need this just remove it so
we don't have to wait for a fix.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=2370858

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-06 19:44:00 +02:00
0b8dd90840 podman machine: fix proxy test
Do not write /etc/environment.d files, something is broken in the new
image that causes the boot to fail when any basic var is set there.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-06 16:13:44 +02:00
0c406f25ad pkg/machine/e2e: skip rosetta test
We disabled it in the machine os image so it can no longer be used
currently.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-06 15:48:28 +02:00
2d234fab34 Merge pull request #26177 from Luap99/machine-linger
pkg/machine: setup lingering for custom username and remove unnecessary sleep service
2025-06-04 14:04:37 +00:00
8532ecb710 fix wsl install workflow on machine init command
this patch changes how the detection of wsl works.
The old way of using wsl --status command output to detect some missing features required by WSL is not fully reliable.
WSL checks if the wsl feature is enabled and if the vmcompute service do exist. However, this is not enough to identify if the virtual machine platform feature is enabled. The vmcompute service could exist because it has been installed by other tools or it could exist but being stopped.

The way proposed by this patch is to try execute the import command and,
if it fails, check the error and if it is related to the Host Compute
Service try to install all features required by WSL.

The flow is the same as before, the user is asked to execute the podman
machine init command with elevated privileges. Eventually, after
enabling WSL and VMP features, the user is asked to reboot the machine.

When the machine restarts, the powershell gets invoked again and execute
the command init.

The code also fixes some issues that could cause misbehaviors when
invoking recursively the elevated shell, like an unreleased lock, or a
missing file.

Signed-off-by: lstocchi <lstocchi@redhat.com>
2025-06-04 14:26:48 +02:00
f25cefcb1b Fix overlay volumes on Windows
The Windows source folder path was not converted in the corresponding
machine folder path when the volume was of type overlay as it does for
other bind mount volumes.

Fix #25988

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2025-05-27 15:11:36 +02:00
5797c1dd27 pkg/machine: don't use dummy linger service
There is no reason to deifne a dummy service to run sleep just to get
the podman.socket enabled. Enabeling a service is just creating the
symlink so we can do that for the user sessions as well.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-05-21 19:08:41 +02:00
79a857e0a0 pkg/machine: correctly enable lingering
When a custom username is requested we must stil enable lingering for
it. The linger setup in the coreos image with the hard coded core user
doesn't really make sense as it doesn't work when another name is used.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-05-21 19:08:41 +02:00
9872f0e83c Update expected output for a machine copy test
The podman machine copy test "attempt copying file to a new directory"
was failing because on recent version of Windows the error message
doesn't match the expected error message. To make it work on new and
old version of Windows both old and new error messages are now
considered as valid.

Fixes https://github.com/containers/podman/issues/26056

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2025-05-21 18:40:52 +02:00
af495e1aa9 Replace alpine_nginx with TESTIMAGE in e2e tests
The image quay.io/libpod/alpine_nginx doesn't have a `linux/arm64` version
and the test "Single character volume mount" on Windows ARM64 was
failing. Changing it to TESTIMAGE (quay.io/libpod/testimage) fixes it.

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2025-05-21 18:40:52 +02:00
265ca77276 Be explicit about ssh configs suitable only for localhost
... and warn loudly against generalization.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2025-05-15 23:04:49 +02:00
637c264e2e fix issues found by nilness
The conditions are always true so they can be removed. And in the case
of exportCheckpoint() the scope means addToTarFiles was overwritten and
thus when it looped over it later the slice was always empty.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-05-13 17:20:10 +02:00
b6eeaea7f3 Take path for wsl instead of forcing through WindowsApps
Signed-off-by: Matheus Cunha <matheusvflor@hotmail.com>
2025-05-08 16:39:03 +02:00
e3df077f0a Merge pull request #26029 from Luap99/machine-tz
pkg/machine: more timezone fixes
2025-05-05 21:00:35 +00:00
400a9a528b Merge pull request #25722 from l0rd/fix-hyperv-volumes-with-space
Fix machines failing to start when a volume's path contains spaces
2025-05-02 14:03:15 +00:00
5e8e829d7b Merge pull request #25945 from ninja-quokka/podman_machine_swap
feat: Add support for configuring swap in Podman machine
2025-05-02 13:21:48 +00:00
ac6080bea9 pkg/machinie: use TZ env for reading local timezone
The TZ var can be commonly used to overwrite the timezone so we should
honour that one as well.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-05-02 11:56:47 +02:00
a90fad3fc8 pkg/machine: rework getLocalTimeZone on linux
Get the timezone off the localtime symlink like systemd does it.
It is more efficient then fork/exec another command for it that may or
may not exits and the /etc/timezone files doesn't exist on most distros
so that is not a great fallback.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-05-02 11:56:47 +02:00
193d7b8202 pkg/machine: properly setup zoneinfo symlink
If you run timedatectl inside it will not show the correct timezone, it
seems systemd really wants a relative link which is also documented by
coreos[1]. Also we can just use path.Join() directly and don't have to
convert the path again on windows.

[1] https://docs.fedoraproject.org/en-US/fedora-coreos/time-zone/#_setting_the_time_zone_via_ignition

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-05-02 11:56:46 +02:00
b431f06e64 pkg/machine: do not add broken localtime symlink
The timezone might be empty so the zoneinfo link would then be invalid.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-05-02 11:56:46 +02:00
9ce708774e Merge pull request #26026 from baude/issue25950
Do not error on tz detection
2025-04-30 16:04:13 +00:00
d7eaf42727 Do not error on tz detection
In cases where systemd was not available, podman machine was erroring
out using timedatectl (it requires systemd).  on other providers like
windows, we don't do any timezone detection so it seems valid to return
a "" for timezone.  This fixes the first problem described #25950.

Fixes: https://github.com/containers/podman/issues/25950

Signed-off-by: Brent Baude <bbaude@redhat.com>
2025-04-30 08:03:34 -05:00
c9b1bd1cf3 Stop setting btrfs_noversion build tag
c/storage no longer uses this tag after
https://github.com/containers/storage/pull/2308.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-04-30 14:22:25 +02:00
8e6ecb97c9 Fix running machines with volumes containing spaces
Machines configured to mount local paths containing
spaces failed to start on Hyper-V and silently failed
to mount the folder on macOS/Linux.

On Windows/hyperv, where local paths are mounted
running a 9p client inside the VM, the local host
path needs to be surrounding with quotation marks
before using in a `podman machine ssh ...` command.

A similar behavior happened on Linux/QEMU where the
path was used in a SSH command to mount the folder
using virtiofs. Quoting the path when buidling the
command arguments fixed the problem.

On macOS/libkit,applehv the path was written as is
in a systemd unit name to instruct how to mount it.
Escaping space chars so that they are are parsed
successfully fixed this:
```diff
-- enable path with spaces.mount
++ enable path\x20with\x20spaces.mount
```

Fixes https://github.com/containers/podman/issues/25500

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2025-04-30 08:54:42 +02:00
79a820ac3b Merge pull request #25832 from jakecorrenti/handle-sigint
Handle machine start state when sent a signal
2025-04-29 17:22:13 +00:00
24267452e6 Handle signal preventing Start from completing
In the instance where the user sends a signal, such as SIGINT (Ctl-c)
when a Podman Machine is in the middle of starting, make sure the state
doesn't get stuck in the "Currently Starting" status.

Resolves: #24416

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2025-04-29 10:09:58 -04:00
7b1055a5fb feat: Add support for configuring swap in Podman machine
Add `--swap` argument to `podman machine init` command.

Passing an int64 value to this flag will trigger the Podman machine
ignition file to be generated with a zram-generator.conf file containing
the --swap value as the zram-size argument.

This file is read by the zram-generator systemd service on boot
resulting in a zram swap device being created.

Fixes: https://github.com/containers/podman/issues/15980

Signed-off-by: Lewis Roy <lewis@redhat.com>
2025-04-29 12:20:24 +10:00
2588b96993 Fix logging podman machine server9 output
Command `podman machine init` for Hyper-V machines invokes the command
`podman machine server9` and redirects it's output to a file. But the
file descriptor was closed before beeing used and the output file was
always empty.

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2025-04-28 15:42:43 +00:00
585f046e95 Disable FS mount in volume only test
The test is checking that named volumes could be used. FS mount is not
needed and there is no code testing anything around it.

Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
2025-04-26 13:44:36 +03:00
48423a615d Merge pull request #25701 from danegsta/danegsta/windowsCpPath
Fix windows path handling in `podman cp`
2025-04-10 16:53:23 +00:00
521b2451c7 Correct units in init error message
When trying to initialize a machine with more memory that the system has
we were outputting an error message in the wrong unit.  It should have
been in MB and B. This was found as part of #25803 but is not the
solution for that issue.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2025-04-09 09:50:26 -05:00
9a723ff9f5 Fix windows path handling in podman cp
Fixes: #14862

Signed-off-by: David Negstad <David.Negstad@microsoft.com>
2025-04-08 15:23:08 -07:00
f18c917ef8 ci: run golangci-lint on freebsd
This could have been done by simply running

	GOOS=freebsd ./bin/golangci-lint run [options] ./...

on Linux, but some freebsd code is using cgo (i.e. is linked to C
libraries), so real freebsd environment is required.

This also fixes the issue of ignoring linter errors for Windows and
Darwin (exit 0), introduced by commit c9b108d5b38.

Fixes: c9b108d5b38 ("Bump golangci-lint to v2.0.2")
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-03 09:24:58 -07:00
18fdbaee80 pkg/machine/qemu: fix ST1016 linter warning on freebsd
> pkg/machine/qemu/stubber.go:92:23: ST1016: methods on the same type should have the same receiver name (seen 1x "v", 25x "q") (staticcheck)
> func (q *QEMUStubber) CreateVM(opts define.CreateVMOpts, mc *vmconfigs.MachineConfig, builder *ignition.IgnitionBuilder) error {
>                       ^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-31 12:30:43 -07:00
8bd73b7d2c pkg/machine/wsl: rm unused structures
Those are not used since commit 0c587f024 ("refactor(machine,wsl):
improve operations of Windows API").

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-31 12:27:55 -07:00