Commit graph

1080 commits

Author SHA1 Message Date
Danish Prakash
e121ed6264
Merge pull request #28687 from jaitjacob/add-podman-machine-restart-command
Add `podman machine restart` subcommand
2026-07-22 09:53:10 +05:30
Jait Jacob
eb26516dba
make return explicit so CleanIfErr runs as expectd
Signed-off-by: Jait Jacob <jai8.jacob@gmail.com>
2026-07-21 23:30:29 +05:30
Jait Jacob
2ad3a79631
Add podman machine restart subcommand
Signed-off-by: Jait Jacob <jai8.jacob@gmail.com>
2026-07-16 21:51:11 +05:30
Mario Loriedo
452c40a1b6 Add machine e2e test for host.containers.internal
Add one more test to the basic podman commands e2e tests:
- starts an HTTP server on the host
- verify HTTP requests from a container, using
`host.containers.internal` or `host.docker.internal`, are routed
successfully to the server running on the host

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>

test

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-07-16 14:33:18 +02:00
Mario Loriedo
48f21de496 Fixing machine e2e gvproxy test
The lookup for the gvproxy process was broken on Windows:
- We looked for gvproxy, not gvproxy.exe, and `tasklist` was always
failing
- But `pgrep` wasn't failing because we looked for the wrong `tasklist`
error message (the correct error message on my laptop is "INFO: No tasks
are running which match the specified criteria.")
- WSL uses win-sshproxy.exe, not gvproxy.exe

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-07-15 11:42:11 +02:00
Mario Loriedo
d20b363e02 Always unprovision if the WSL machine init fail
Remove the just provisioned WSL distribution if one of the post install
scripts fail.

Fixes #27036

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-07-13 14:07:17 +02:00
Mario Loriedo
bec840d716 Fix lookup of HyperV VMs with matching name
Fixes https://github.com/podman-container-tools/podman/issues/29138

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-07-07 23:40:18 +02:00
Brent Baude
9ac9834a50
Merge pull request #29100 from afbjorklund/machine-cache
Restore caching of the default machine image
2026-07-02 10:05:27 -05:00
Brent Baude
4d5435f47e
Merge pull request #29103 from Luap99/wsl-config-mount
machine/wsl: fix config mount logic
2026-07-02 10:05:04 -05:00
Paul Holzinger
114bb1efa7
machine/wsl: fix config mount logic
The current systemd service to mount /etc/containers is not working
right. The Before=podman.socket causes a ordering conflict which causes
the socket to be disabled and thus all podman remote connections fail.

The problem is the unit is wanted by the default.target while the socket
is wanted by sockets.target which can be before the default.target is
triggered. That means that the Before= line cannot be fulfilled and
sometimes systemd thus seems to not start the socket. It is unclear to
me why this is racy as it is sometimes also works.

This was reported by Vladimir Lazar from the PD team, our CI did not
caught this as we use rootless machines by default and the problem only
happens for the rootful socket so we do not see connection failures.
To fix this add at least one rootful socket check.

We do however have a different CI flake that was also caused by the
incorrect mount dependencies. The mount could happen after sshd or other
programs run. So to fix this we must hook the podman-mnt-config.service
into the local-fs.target which runs much earlier and is used for all the
mounts.

Fixes: #29003

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-07-02 14:01:43 +02:00
Anders F Björklund
d4a1efbe9b Restore caching of the default machine image
It was removed, with the hardcoded image reference.

So cache was always off, even for the default image.

Fixes: #29090

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
2026-07-01 18:09:21 +02:00
Paul Holzinger
838fc24d3e
machine: simplify ssh debug output logging
When the command output is logged we do not need an extra pipe and
scanner to read the output line by line, we can just log it directly via
a writer.

Now this of course does loose the line by line parsing of the scanner
but IMO this is better as it is simpler and less code to worry about.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-06-30 10:32:32 +02:00
Paul Holzinger
278068ef18
fix some missing scanner error checks
Found by scannererr:
https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/scannererr

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-06-30 10:32:32 +02:00
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