Commit Graph

1067 Commits

Author SHA1 Message Date
Paul Holzinger
4cbae8b6a7 Merge pull request #28991 from l0rd/fix-machine-start-signal-handling
Fix signal handling during machine start on macOS
2026-06-29 18:50:09 +02:00
Mario Loriedo
80203302f9 Fix lookup of WSL VMs with matching name
When WSL wasn't installed, the lookup erroneously reported that
a VM with the same name existed. Instead, in this case, the lookup
should return zero matching VMs.

Fixes https://github.com/podman-container-tools/podman/issues/29053

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-06-27 10:52:26 +02:00
Mario Loriedo
697f91164a Fix WSL check: assume not installed when --status returns an error
Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-06-27 00:43:33 +02:00
Mario Loriedo
12ea195526 Add new machine test that covers interrupted start command
Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-06-24 18:52:15 +02:00
Mario Loriedo
f5d51593ca Fix cleanup callbacks registration in machines Start() function
Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-06-24 18:52:15 +02:00
Mario Loriedo
2f3e645b58 Reap completed gvproxy process if machine start fails on Unix
Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-06-24 18:52:15 +02:00
Mario Loriedo
37c8dea92a Machine: extend lock to ensure cleanup callbacks completion
Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-06-24 18:52:15 +02:00
Mario Loriedo
c6945741e4 Propagate SIGTERM to the VM process during machine start on macOS
Related to https://github.com/podman-container-tools/podman/issues/28318

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-06-24 18:52:12 +02:00
Paul Holzinger
81fd1e6e85 machine/wsl: drop cgroup_manager cgroupfs
I think this should work fine with the defaults. Since we mount the
/etc/containers dir always we should no longer write to /etc/containers.
If we still need this it should be moved into the image and not done at
init time.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-06-23 13:07:34 +02:00
Mario Loriedo
835c8f2d1d Merge pull request #28871 from Luap99/hyperv-flake
machine/hyperV: move ssh mounts to after the ready check
2026-06-19 12:05:58 +02:00
Ashley Cui
66a082ed1b Merge pull request #28915 from chanhyeokseo/fix-machine-virtiofs-fcos-home-28911
machine: fix virtiofs mount targets on FCOS
2026-06-17 10:36:51 -04:00
Chanhyeok Seo
61dea3749f machine: fix virtiofs mount targets on FCOS
FCOS symlinks /home to var/home. systemd rejects a mount unit whose
Where= path traverses a symlink, breaking default home dir mounts.

Resolve known FCOS symlinks before writing the ignition unit.

Fixes: #28911
Signed-off-by: Chanhyeok Seo <chanhyeok.seo@datadoghq.com>
2026-06-16 22:52:33 +09:00
Jan Rodák
f1d0ded43c Convert if/else to switch for transport name comparison
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2026-06-12 10:12:49 +02:00
Jan Rodák
b294a92a25 Add reasons to all staticcheck suppressions
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2026-06-12 10:12:40 +02:00
crawfordxx
d0f97989ad machine: escape % as %% in proxy values written to systemd unit conf
systemd interprets % as specifier characters in unit configuration files
(e.g. %H, %u, %40). Proxy environment variable values that contain
percent-encoded URL characters (such as %40 for @ in usernames) cause
systemd to emit warnings and fail to parse the generated
/etc/systemd/system.conf.d/default-env.conf:

  system.conf.d/default-env.conf:2: Failed to resolve specifiers in
  HTTP_PROXY=http://user%40example.com@proxy:3128

Fix by adding a bash variable substitution that doubles every % to %%
before writing to the systemd unit conf files. The profile.d and
environment.d destinations do not need this escaping and continue to
use the original value.

Fixes #28698

Signed-off-by: crawfordxx <crawfordxx@users.noreply.github.com>
2026-06-06 12:04:48 +08:00
Paul Holzinger
8472bf223e machine/hyperV: move ssh mounts to after the ready check
We are seeing frequent flakes in hyperV machine tests. The machine start
fails with an ssh handshake failure:

ssh: handshake failed: read tcp 127.0.0.1:56425->127.0.0.1:56377:
wsarecv: An existing connection was forcibly closed by the remote host.

Normally we do the ssh probe in conductVMReadinessCheck() with a retry
mechanism, however because the hyperV mount code already used ssh in
PostStartNetworking() we never got there and failed early.

PostStartNetworking seems the wrong place to mount anyway so move this
to MountVolumesToVM() instead which is placed after the ready check
already so it should have a working ssh by then.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-06-05 18:34:44 +02:00
Nicola Sella
d6cf6e8495 machine: share virtiofs systemd unit generation
Make GenerateSystemDFilesForVirtiofsMounts an agnostic function
and move the code from apple to pkg/machine/volume_systemd.go

MountVolumesToVM  is now a no-op matching the AppleHV and
LibKrun behaviour.

Continues from PR: https://github.com/podman-container-tools/podman/pull/28736

Fixes: https://redhat.atlassian.net/browse/RUN-4742

Signed-off-by: Nicola Sella <nsella@redhat.com>
2026-06-02 14:47:08 +02:00
Brent Baude
e581ddc253 Merge pull request #28731 from lstocchi/hyperv_enhancements
Fixes for Hyper-V user experience
2026-05-26 10:30:18 -05:00
Paul Holzinger
22c5f3fa55 Merge pull request #28527 from vyasgun/pr/krunkit-timesync
machine: add vfkit timesync device for Apple VMs
2026-05-26 12:23:04 +02:00
lstocchi
f96cbda1b0 hyperv: propagate detailed error from Hyper-V permission checks
Change isHyperVAdminMember from returning a bool to returning an error so that callers surface the specific failure reason — particularly distinguishing "not in the group" from "in the group but session not updated" (new ErrHypervUserSessionNotUpdated sentinel). This gives users actionable guidance instead of a generic permission error.

Signed-off-by: lstocchi <lstocchi@redhat.com>
2026-05-25 00:10:18 +02:00
Kir Kolyshkin
d4f60b5826 libpod: some modernize fixes for freebsd and darwin
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-05-22 14:15:49 -07:00
Gunjan Vyas
250e5f9914 use constant for timesync port and update mac_env.sh to print krunkit version
Signed-off-by: Gunjan Vyas <vyasgun20@gmail.com>
2026-05-20 12:56:50 +05:30
Gunjan Vyas
e5bef8b124 machine: add vfkit timesync device for Apple VMs
Fixes: #28345

Signed-off-by: Gunjan Vyas <vyasgun20@gmail.com>
2026-05-19 13:23:01 +05:30
Sebastien Tardif
846d1a1b05 Close leaked file handles in container config, CRIU stats, and playbook read
Add missing defer Close() calls in four locations:

- libpod/container.go: specFromState() opens the container config file
  but never closes it after reading, leaking one fd per call.

- libpod/container_internal_common.go: checkpoint() and restore() each
  open the bundle directory for CRIU statistics but never close it,
  leaking one fd per checkpoint/restore operation.

- pkg/machine/shim/host.go: Init() opens the playbook file but never
  closes it after ReadAll, leaking one fd per machine init.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
2026-05-17 16:09:56 -07:00
Maya Chen
2f17614d0e fix: duplicated words in decompress.go log message and annotations.go comment
Signed-off-by: Maya Chen <275405107+otjdiepluong@users.noreply.github.com>
2026-05-14 05:08:45 +00:00
Paul Holzinger
a6e58ea101 wsl: remove custom registries.conf
This is already part of the base machine image, also with the overmount
of /etc/containers this would no loner be read anyway.

The machine-os update for this is here:
https://github.com/containers/podman-machine-os/pull/239

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-05-11 15:58:03 +02:00
Paul Holzinger
93b615c1f2 machine: move marker file to /etc/podman-machine
Matches changes from https://github.com/containers/container-libs/pull/779

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-05-11 15:58:03 +02:00
Paul Holzinger
e34f3bce0c machine: remove SSL_CERT_DIR/SSL_CERT_FILE copy
With podman 6 we have a --import-native-ca option that handles the
copying of certs much better.

As such remove our old legacy way of copying files these envs and also
the static certs.d dir. Since we now mount the full containers config
dir the certs from the cert.d are mounted already.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-05-11 15:58:03 +02:00
Paul Holzinger
b14e833ef6 machine: add test to check config mount
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-05-11 15:58:03 +02:00
Paul Holzinger
5e193ce96a wsl: mount config home dir like on other providers
The other providers use the volume mounts from containers.conf which
should take care of it. But because WSL is not using this we need to
hard code this ourselves.

Add a new custom unit to make systemd mount the path like we do for
podman socket mounts.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-05-11 15:58:03 +02:00
Paul Holzinger
41adad8ce9 machine test: combine three test cases
Each machine init boot takes a while, we can easily do this as part of
one test run to speed the overall machine test time up.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-05-11 15:58:03 +02:00
Paul Holzinger
d54f1eb6fe machine/wsl: remove some dead code
The config.go file has a build tag that was never used. Also remove
unused functions from other files.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-05-07 13:34:06 +02:00
Paul Holzinger
8c9f530cb3 Merge pull request #28621 from l0rd/import-certs-darwin-linux
Import host trusted certificates into the guest machine - macOS and Linux
2026-05-05 13:10:57 +02:00
Mario Loriedo
3f883706ba Import local certificates to machines on macOS and Linux
This is a follow up of https://github.com/containers/podman/pull/28336 where we
implemented the import of the certificates on Windows. This PR implements the
same feature on macOS and Linux.

Fixes https://redhat.atlassian.net/browse/RUN-4552

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-05-01 00:42:52 +02:00
Mario Loriedo
15c9ca130f Add command podman system hyperv-prep
Introducing a new `podmand system` subcommand to prepare a Windows host
to run Hyper-V based Podman machines: `hyperv-prep`.

When executed it:
- creates of the registry keys for VSocks
- adds the current user to the Hyper-V administrators group

This command requires an administrator terminal.

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-04-29 23:00:29 +02:00
Mario Loriedo
92d186f20d Hyperv machine init/rm: skip win registry operations when possible
Hyper-V VMs require some specific Windows registry keys to allow the
communication between the host and the guest. Creating these registry
keys require elevated privileges.

These keys were created during the first Podman `machine init` and
removed when the last Podman machine is removed.

In this commit we skip the creation of the keys if they already exist in
the registry. So that admin privileges aren't required anymore, even for
the creation of the first Podman machine.

In other words, if the keys are pre-created by an administrator, user
will be able to create and remove machines without requiring to run any
elevated command. Even for the first podman machine.

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-04-29 23:00:29 +02:00
Mario Loriedo
f6b6bce745 Minor hyperv stubber.go and vsock.go refactoring
Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-04-29 23:00:29 +02:00
jait jacob
efc6ddfcc4 cleanup: run go fix on pkg/machine for windows
Signed-off-by: jait jacob <jai8.jacob@gmail.com>
2026-04-29 13:56:01 +05:30
Brent Baude
2cc3be7332 RUN-4539: Change podman module paths
The podman module paths are moving from github.com/containers/podman to
go.podman.io/podman.  This will help with future mobility.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2026-04-22 14:02:25 -05:00
Matt Heon
3279767614 Merge pull request #28336 from l0rd/import_native_ca
Import host trusted certificates into the guest machine - Windows part
2026-04-22 13:04:55 -04:00
Brent Baude
9ac300c6af Merge pull request #28535 from lstocchi/i25037
auto-add user to Hyper-V Administrators group
2026-04-22 10:31:55 -05:00
lstocchi
57eeb47143 auto-add user to Hyper-V Administrators group
Currently, running Podman on Hyper-V as a non-administrator requires the user to be a member of the "Hyper-V Administrators" local group. If they are not, various WMI calls fail with access denied.

This commit automates the permission setup.
1. During podman machine init, if Podman is running with elevated privileges (required for registry/networking setup anyway), it will now automatically add the current user to the localized "Hyper-V Administrators" group
2. If a user is added to the group, the change is not reflected until the next login. We now detect this state and explicitly instruct the user to log out and back in.
3. Modified the Hyper-V stubber to handle permission checks at the method level rather than the provider selection level (GetAll). This allows init to continue far enough to perform the elevation and setting.

Signed-off-by: lstocchi <lstocchi@redhat.com>
2026-04-22 11:03:37 +02:00
Brent Baude
2e6f29a2df RUN-4538: Fix buildah vendoring
This PR reflects the upstream change of moving the buildah module from
github.com/containers/buildah to go.podman.io/buildah.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2026-04-21 14:27:58 -05:00
Jan Kaluza
54d61c2f02 trust: switch policy.json lookup to configfile
Use shared configfile instead of custom policy.json path handling.
This updates ocipull to rely on signature.DefaultPolicy(), removes
explicit SignaturePolicyPath, and replaces trust's custom default-policy
path logic with common configfile code.

Replace hidden `--policypath` with --signature-policy` and require
it for `trust set` command instead of path resolution based on
configfile.

For `trust get`, the `--signature-policy` is optional.

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
2026-04-20 15:11:22 +02:00
Matthew Heon
5e94c95ad0 Move to deterministic network setup order
This was implemented by containers/netavark #1369; this commit
completes the process by wiring it into Podman. We now respect
the CLI order for configured networks - if a user passes
`--net net1,net2` we guarantee that net1 will be configured
before net2.

For containers created before this patch, we don't retain enough
information to configure networks in CLI order, so we use
alphabetical order instead to still guarantee consistency.

No breaking API changes have been made, but we do add a new
field to supplement the existing map to (optionally) provide
ordering information. The Podman CLI will always pass this.
Existing applications that do not will, again, receive]
deterministic ordering based on an alphabetical sort of network
names.

This requires the latest version of Netavark to work properly.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2026-04-17 10:00:32 -04:00
Mario Loriedo
f7dd6156d3 Import host certificates at machine startup on Windows
Implements the feature introduced in the design
document added with commit 4bdc1d37

Fixes https://redhat.atlassian.net/browse/RUN-4260

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-04-16 13:35:40 +02:00
Paul Holzinger
571c842bd3 hyperV: fix powershell path escape
To avoid special chars from being interpreted.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-04-13 19:01:49 +02:00
lstocchi
a9a9eda883 rename ErrRelaunchAttempt to ErrRelaunchSucceeded and fix elevated error handling
The old ErrRelaunchAttempt name was ambiguous — it reads as though the
relaunch attempt failed, when it actually signals success. Rename to
ErrRelaunchSucceeded and update comments at every call site to clarify
that this is not a real error but a sentinel indicating the elevated
child process completed the operation successfully.

Also fix a bug in WSL's launchElevate where a failed elevated process
was incorrectly wrapped with the sentinel, causing callers to treat the
failure as success and print "Machine init complete."

Signed-off-by: lstocchi <lstocchi@redhat.com>
2026-04-03 18:37:24 +02:00
lstocchi
8e5fde01c6 propose running init/rm command on hyperv machine in elevated mode
This commit adds automatic UAC elevation prompts for HyperV machine
init/rm actions when administrator privileges are required.
Previously, users had to manually run Podman as administrator
when creating the first machine or removing the last machine, which
requires Windows Registry modifications.

When the HyperV command gets relaunched as elevated, the error of the
elevated process is saved on a file to be displayed by the caller. The
implementation is the same as that used by WSL.

Signed-off-by: lstocchi <lstocchi@redhat.com>
2026-04-03 18:37:08 +02:00
lstocchi
5b0ec91c54 move wsl' util_windows to windows package so it can be reused by hyperv
Signed-off-by: lstocchi <lstocchi@redhat.com>
2026-04-03 14:32:09 +02:00