Commit Graph

750 Commits

Author SHA1 Message Date
Nalin Dahyabhai 8afa06ee89 Use a defined constant instead of a hard-coded magic value
Use specV1.AnnotationTitle instead of hard-coding its value when we go
looking for podman-machine images.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-05-16 15:50:12 -04:00
openshift-merge-bot[bot] 1afeb13d0b
Merge pull request #22362 from tnk4on/e2e-macos-tmpdir
Change tmpDir when running e2e localmachine test on macOS
2024-05-16 18:11:55 +00:00
openshift-merge-bot[bot] 87bd77538e
Merge pull request #22587 from gmpify/main
Fix updating connection when SSH port conflict happens
2024-05-14 17:30:26 +00:00
Gabriel Parreiras 277312d282
Fix updating connection when SSH port conflict happens
Signed-off-by: Gabriel Parreiras <gabriel.parreiras@shopify.com>
2024-05-14 16:15:56 +01:00
Jake Correnti ee5153c545 machine: Add LibKrun provider detection
Adds provider detection for LibKrun in `pkg/provider/platform_darwin.go`.

Changes the macOS version check to 13 instead of 11, and now uses the `semver`
package to verify current version.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2024-05-07 21:16:46 -04:00
Jake Correnti 431cbffab6 machine: Add provider detection API
Extends the `pkg/machine/provider` package to add an API which includes
provider detection based on the host operating system.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2024-05-06 09:42:02 -04:00
Shion Tanaka 590fec7a78 Change tmpDir for macOS
Signed-off-by: Shion Tanaka <shtanaka@redhat.com>
2024-05-03 15:01:43 +09:00
Ashley Cui a140c74ba4 Fix machine volumes with long path and paths with dashes
AppleHV accepts a max 36 bytes for mount tags. Instead of using the fully qualified path for the mount tag, SHA256 the path, and truncate the shasum to 36 bytes.
Also correctly escape dashes in mounted paths.

Signed-off-by: Ashley Cui <acui@redhat.com>
2024-04-30 11:25:45 -04:00
openshift-merge-bot[bot] 02cfd71fe8
Merge pull request #22507 from ashley-cui/cache
Clean machine pull cache
2024-04-26 18:13:34 +00:00
Ashley Cui e412eff33f Clean machine pull cache
Cache cleanups only happen if there is a cache miss, and we need to pull a new image

For quay.io/podman/machine-os, we remove all old images from the cache dir. This means we will delete any file that exists in the cache dir; this should be safe to do since the machine pull code should be the only thing touching this cache dir. OCI machine images will always have a different manifest, and won’t be updated with the same manifest, so if the version moves on, there isn’t a reason to keep the old version in the cache, it really doesn’t change.

For Fedora (WSL), we use the cache, so we go through the cache dir and remove any old cached images, on a cache miss. We also switch to using ~/.local/share/containers/podman/machine/wsl/cache as the cache dir rather than ~/.local/share/containers/podman/machine/wsl. Both these behaviors existed in v4.9, but are now added back into 5.x.

For generic files pulled from a URL or a non-default OCI image, we shouldn’t actually cache, so we delete the pulled file immediately after creating a machine image. This restores the behavior from v4.9.

For generic files from a local path, the original file will never be cleaned up

Unsure how to test, so:
[NO NEW TESTS NEEDED]

Signed-off-by: Ashley Cui <acui@redhat.com>
2024-04-26 12:31:42 -04:00
Brent Baude d2c1de5993 Add krun support to podman machine
This PR adds libkrun support to podman machine.  This is an experimental feature and should not be marketed yet.  Before we unmark the experimental status on this function, we will need to have full CI support and a full podman point release has pased.

This work relies on the fact that vfkit and libkrun share a reasonably (if not perfectly) same API.  The --log-level debug option will not show a GUI screen for boots as krun is not capable of this.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-04-26 08:58:38 -05:00
Paul Holzinger 83dbbc3a51
Replace golang.org/x/exp/slices with slices from std
Use "slices" from the standard library, this package was added in go
1.21 so we can use it now.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-04-23 11:16:40 +02:00
Giuseppe Scrivano af24326133
pkg/machine: use fileutils.(Le|E)xists
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-04-19 09:52:14 +02:00
fanqiaojun 1600cfffa5 Fix some comments
Signed-off-by: fanqiaojun <fanqiaojun@yeah.net>
2024-04-13 15:20:19 +08:00
Jason T. Greene 0b36126e92 Fix relabeling failures with Z/z volumes on Mac
Non-Linux systems, such as BSD kernels, constrain xatter updates
according to file permissions. This is in contrast to Linux selinux
attr writes, which are governed by an selinux policy. By dafault this
policy apllows users to relabel files owned by themselves even if file
perms would otherwise disallow write.

This results in robust container relabeling results on Linux, and
fragile results everywhere else. Therefore, change the mac policy to
force the nfs_t context on all files, and ignore all relabel
events.

As a side-effect, this will disallow any ability to store custom
selinux constants on files. However, this is of limited use in
a machine context, since files in these volumes are externally
managed on systems which do not support SELinux.

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2024-04-08 10:06:44 -05:00
Christophe Fergeau d305e70af8
applehv: Print vfkit logs in --log-level debug
There has been various issues with vfkit exiting with
"Error: vfkit exited unexpectedly with exit code 1"

Among other reasons, this can be caused by vfkit being
built without the com.apple.security.virtualization
entitlement, and this can also happen when running
vfkit.x86_64 on Apple silicon hardware.

At the moment, the vfkit logs are not available, so there is no easy way
to know what's happening. This PR redirects vfkit stdout/stderr to
podman's log when --log-level debug is used.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2024-03-27 09:59:31 +01:00
openshift-merge-bot[bot] 5c39ddca5d
Merge pull request #22140 from baude/hypervrmf
hyperv: fix machine rm -r
2024-03-26 14:03:24 +00:00
openshift-merge-bot[bot] ecdc3d255b
Merge pull request #22161 from baude/hypervrequireadmin
hyperv: error if not admin
2024-03-26 12:27:09 +00:00
Brent Baude c62c74970f hyperv: error if not admin
creating vsocks in windows requires admin privileges.  there could be
some workarounds made in the future,but the general deal has
always been, you need to be admin.  lets enforce this with an error
until those work-arounds can be implemented.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-03-25 10:47:57 -05:00
Jason T. Greene 11415b3e74 Use built-in ssh impl for all non-pty operations
Windows is not guaranteed to have the SSH feature installed, so prefer the use
of the built-in ssh client for all operations other than podman machine ssh,
which requires terminal pty logic. This restores previous behavior in 4.x.

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2024-03-24 21:25:22 -05:00
Brent Baude a6ffb5656f hyperv: fix machine rm -r
this pr fixes two hyperv bugs.  previous podman 5 versions of hyperv
failed to actually remove the vm from hyperv when machine rm -f was
called.

also fixes an annoying bug where removal of the hyperv ignition entries
were failing because this can only be done (with the current api) when
the vm is running.  new api in latest libhvee fixes this.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-03-22 11:09:17 -05:00
Paul Holzinger 493179be45
fix remote build isolation when server runs as root
I am really not sure why the caller even should have the option to set
this. We should always use the correct isolation type based on the
privileges the server runs under never the client. podman-remote build
seems to send the default based on its local privs which was wrong as
well. To fix this I also changed the client to send the default if the
isolation flag is not set.

Fixes #22109

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-21 14:17:55 +01:00
Jason T. Greene 3f2b8bb314 Use correct extension in suite
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2024-03-19 13:07:45 -05:00
Jason T. Greene 7fbdd9e6e2 Adjust to the standard location of gvforwarder used in new images
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2024-03-16 14:03:40 -05:00
Jason T. Greene fdad9ab1ff Switch to 5.x WSL machine os stream using new automation
Includes a switch from XZ to ZSTD for significantly improved fetch performance

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2024-03-15 23:27:38 -05:00
Paul Holzinger e82d196269
pkg/machine: make checkExclusiveActiveVM race free
We need to take another lock to prevent concurrent starts from different
machines.

I manually tested it by starting three VM in parallel with:
podman machine start & podman machine start test1 & podman machine start test2

I also added a CI test that seems to work as expected (failed with the
old binary, worked with the new)

Before this patch I was able to start more than VM, with this patch it
now only starts one of them and the other ones will fail to start with
a proper error.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-14 11:13:08 +01:00
Paul Holzinger b238303a40
pkg/machine/wsl: remove unused CheckExclusiveActiveVM()
This function is not used, it has been refactored in the general
starting good higher up the stack.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-14 11:08:16 +01:00
Paul Holzinger c9a5c4b943
pkg/machine: CheckExclusiveActiveVM should also check for starting
Also make the error message there better.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-14 11:07:56 +01:00
Paul Holzinger 1dfd3d3d12
pkg/machine: refresh config after we hold lock
Currently we first read the conf and then lock, this is racy because
while we wait for the lock another process might change the state so
the only way to have the actual current state is to read the file
while holding the lock.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-14 11:06:04 +01:00
openshift-merge-bot[bot] 358ac20a1e
Merge pull request #22028 from n1hility/fix-api-socket
Change API socket to be machine name isolated
2024-03-13 19:36:56 +00:00
Jason T. Greene e58cb97de1 Change API socket to be machine name isolated
- Fixes conflicts such as removal of second machine deleting a socket of a
  the first machine while it's running
- Move API socket into runtime directory for consistency
- Add API and gvproxy sockets to removal list
- Cleanup related logic

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2024-03-13 13:28:14 -05:00
openshift-merge-bot[bot] c25bfe1c8c
Merge pull request #21864 from l0rd/compress-refactoring-v5-plus-plus
Machine decompress.go refactoring follow-up
2024-03-13 16:49:17 +00:00
Brent Baude d7bc7b7b41 do not require policy.json
we are having second thoughts about *requiring* a policy.json on podman
machine hosts.  we are concerned that we need to work out some more use
cases to be sure we do not make choices now that limit us in the near
term future. for example, should the policy files be the same for
container images and machine images? And should one live on the host
machine and the other live in the machine?

therefore, if a policy.json *is* present in the correct location, we will use and honor it; however, if it does not, we will allow the machine image to be pulled without a policy.

Signed-off-by: Brent Baude <baude@redhat.com>
Co-authored-by: Paul Holzinger <45212748+Luap99@users.noreply.github.com>
Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-03-13 09:07:51 -05:00
Mario Loriedo 82597144b6 Machine decompress.go refactoring follow-up
1. Added the xz decompression unit tests

2. Removed the xz implementation to use the one from c/images

3. Removed the specific macos gzip, zstd compressor and use
   the generic compressor but with SparseWriter if GOOS == darwin

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2024-03-13 00:58:50 +01:00
Brent Baude 4c5d26f6f9 Add final machine endpoint
Adding the final machine endpoint as quay.io/podman/machine-os in the
Podman code.  As a reminder, we decided we would set this in containers
conf once things settle down and this code would then be removed.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-03-12 09:37:57 -05:00
openshift-merge-bot[bot] 4541f0c4ed
Merge pull request #21980 from Luap99/machine-locking-fixes
more machine locking fixes
2024-03-07 16:51:37 +00:00
openshift-merge-bot[bot] 15e508a639
Merge pull request #21936 from l0rd/vmfile-peek
Don't read full VM File before decompressing
2024-03-07 16:40:09 +00:00
openshift-merge-bot[bot] 49f290685f
Merge pull request #21977 from mtrmac/close-error-handling
Close error handling
2024-03-07 15:36:36 +00:00
Paul Holzinger 25f3a8ce77
podman machine start/stop do not write config unlocked
Move the writes into the shim level to make sure they happen while we
hold the machine lock to prevent any race conditions reading/writing the
file.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-07 15:11:41 +01:00
Paul Holzinger 7a75914921
podman machine init: do not write config unlocked
First make sure we check that a given VM exist when holding the VM lock
for it. The check in cmd/podman/machine/init.go is a nice quick out but
not enough to ensure that 2 processes to not create the same VM at the
same time. The only way to ensure this is by holding the lock and
checking if the VM config file exists.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-07 14:58:25 +01:00
Miloslav Trmač 7bfe5e700f Fail on failures to close the file descriptors, and especially the SparseWriter
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-03-07 14:46:17 +01:00
Miloslav Trmač 5e0b7e54c0 Avoid reliance on fs.ErrClosed in SparseWriter users
Neither of the SparseWriter users actually _wants_ the underlying
WriteSeeker to be closed; so, don't.

That makes it clear where the responsibility for closing the file
lies, and allows us to remove the reliance on the destinations
reliably returning ErrClosed.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-03-07 14:46:12 +01:00
Miloslav Trmač 4c6505be5f Fix the logic for detecting an unexpected close error
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-03-07 14:32:43 +01:00
Paul Holzinger 3c9c5be7da
podman machine set: change options only locked
Make sure we only update the machine config when we are locked.
While it doesn't make a functional differnce for cpu and memory it was a
problem for disk size. The disk size must be larger than the previous
one so we must have accurate data on the previous value.

Thus change the settings only while locked and refresh the config so we
have the current up to date values.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-07 14:19:06 +01:00
Miloslav Trmač a65b546c61 Remove copySparseFile
It is unused, and it clearly doesn't work (it closes dest
before writing anything to it).

Just drop it, it can always be re-added.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-03-07 14:08:54 +01:00
Paul Holzinger 2ba3a2d56d
pkg/machine: fix relative DefaultPolicyJSONPath
When we set a relative path (i.e. ".") it should be resolved next to
binary so we need to get the base dir. If we join it directly like it
did before you get a path like .../podman/policy.json where podman is the
podman executable so it is not a directory and thus could not contain the
policy.json file.

ref #21964

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-07 12:22:48 +01:00
Mario Loriedo 724c5a06ba Don't read full VM File before decompressing
While working on #21592 we figured out that the
the full VM File was loaded in memory when detecting
the file format, but only a few bytes are needed.
This commit address that.

[NO NEW TESTS NEEDED]

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2024-03-07 10:11:11 +01:00
Paul Holzinger 4d2fc293c0
machine: make more use of strongunits
To make it very clear in the code what unit the uint represents.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-06 16:14:30 +01:00
openshift-merge-bot[bot] 5ad1f2e43b
Merge pull request #21918 from tnk4on/fix-wrong-units-size-return
Fix problem with `podman machine list` returning wrong units for Memory and Disk size
2024-03-06 13:55:56 +00:00
Shion Tanaka 92b67a69ae Fix wrong units size return
Signed-off-by: Shion Tanaka <shtanaka@redhat.com>
2024-03-06 19:41:11 +09:00