Commit Graph

859 Commits

Author SHA1 Message Date
Arthur Sengileyev 1732338630 Implement publishing API UNIX socket on Windows platforms
gvproxy and win-sshproxy have capabilities to serve this type of enpoint.
This change only adds one additional API enpoint publishing by appending
proxy command lines.

Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
2024-08-31 17:27:05 +03:00
openshift-merge-bot[bot] ef905ef8d0
Merge pull request #23726 from ashley-cui/machlist
machine: Add -all-providers flag to machine list
2024-08-30 16:52:31 +00:00
Ashley Cui 41f945fc24 machine: Add -all-providers flag to machine list
Podman machine list now supports a new option, --all-providers, which lists all machines from all providers.

Signed-off-by: Ashley Cui <acui@redhat.com>
2024-08-28 13:40:50 -04:00
Mario Loriedo 4f4ebdce5b Stop skipping machine volume test on Hyper-V
Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2024-08-27 15:31:38 +02:00
Philippe Martin 3e58e04d3e Quote systemd DefaultEnvironment Proxy values, as documented in systemd.conf man page:
Example:
DefaultEnvironment="VAR1=word1 word2" VAR2=word3 "VAR3=word 5 6"
Sets three variables "VAR1", "VAR2", "VAR3".

Double quote is not escaped, as there is no chance it appears in a proxy value. User can still espace it if really necessary

Signed-off-by: Philippe Martin <phmartin@redhat.com>
2024-08-26 13:12:47 +02:00
Daniel J Walsh fc30620cdb
Do not segfault on hard stop
Podman machine on MAC can segfault on hard stop.

Fixes: 23654

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-08-19 11:14:30 -04:00
Paul Holzinger 84a85319e1
golangci-lint: make darwin linting happy
Fix one minor issue with vfkit error handling. First checking if err !=
nil OR errors.Is() is pointless as the err != is already true.
Second nilerr complains because we return nil when we hit an error
branch, in this case this is correct because an error means VM is
stopped.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-08-19 11:41:29 +02:00
Paul Holzinger 666d839157
golangci-lint: make windows linting happy
It qemu cannot be compiled anyway so make sure we do not try to compile
parts where the typechecker complains about on windows.
Also all the e2e test files are only used on linux as well.
pkg/machine/wsl also reports some error but to many for me to fix them
now. One minor problem was fixed in pkg/machine/machine_windows.go.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-08-19 11:41:29 +02:00
Paul Holzinger c17daf2b09
update golangci-lint to 1.60.1
Fixes new spotted issues around printf() formats and using os.Setenv()
in tests.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-08-19 11:41:28 +02:00
Nicola Sella 6b1c7de3d5 Fix known_hosts file clogging and remote host id
By enabling UserKnownHostsFile=/dev/null, and CheckHostIP=no
options to the defaults we prevent the user from adding the host key
multiple times and from flakes that can raise Remote Host Id change.

Resolves: https://github.com/containers/podman/issues/23505

Signed-off-by: Nicola Sella <nsella@redhat.com>
2024-08-14 15:53:11 +02:00
Ashley Cui 0177f74dc6 pkg/machine: Read stderr from ssh-keygen correctly
Read stderr from ssh-keygen before calling wait(), since cmd.Wait() closes cmd.StderrPipe() after it exits, causing a read-on-closed-pipe error.

Signed-off-by: Ashley Cui <acui@redhat.com>
2024-08-12 14:09:16 -04:00
Brent Baude 81003f2d08 Ignore ERROR_SHARING_VIOLATION error on windows
When removing the gvproxy pid file, under CI conditions we could hit a
case where the PID file being removed seemed to have an open handle on
it still.  I could not find anything in podman that left an open handle
and gvproxy would have quit before this, so we think it is likely
another process holding it.  I could not find root cause with CI because
I could not trip the flake.

this new code allows windows (specifically hyperv bc WSL does not use
GVProxy) to ignore an ERROR_SHARING_VIOLATION.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-08-06 14:09:36 -05:00
Paul Holzinger 029f9b38cc
CI: fix broken libkrun test
Same issues as in the volume ops test, the libkrun volume is not working
properly (#23296).

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-08-06 14:45:52 +02:00
openshift-merge-bot[bot] b1d111c770
Merge pull request #23391 from l0rd/build-contexts
Convert additional build context paths on Windows
2024-08-06 10:18:41 +00:00
Chris Evich 457c64564a
Temp. disable PM basic Volume ops test
Issue 23296

Signed-off-by: Chris Evich <cevich@redhat.com>
2024-08-01 15:01:46 -04:00
Mario Loriedo bf3f207a49 Convert additional build context paths on Windows
Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2024-07-29 17:43:36 +02:00
openshift-merge-bot[bot] 2015137eee
Merge pull request #23367 from rhatdan/codespell
Run codespell on source
2024-07-23 23:11:32 +00:00
Arthur Sengileyev 71d6e2fbaf Add utility to convert VMFile to URL for UNIX sockets
This adds generic utility to convert file system path into URL structure.
Instead of string manipulation it uses URL parsing and building routines.
Appending absolute path to `unix:///` URL out of the box correctly
handles URL format on Windows platform, where filepath should be prepended
by additional `/` before drive letter.

Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
2024-07-23 16:41:24 +03:00
Daniel J Walsh 7768cf235e
Run codespell on source
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-07-23 07:28:23 -04:00
openshift-merge-bot[bot] 003527fedc
Merge pull request #23254 from arixmkii/disable-mounts
Implement disable default mounts via command line
2024-07-21 10:49:17 +00:00
Paul Holzinger f630eebcfa
pkg/machine/compression: skip decompress bar for empty file
When the file is empty it is possible our code panics as bar.ProxyReader
returns nil when the bar is finished which is the case for 0 size as it
doesn't have to read anything from there. However as this happens on
different goroutines it is race and most of the time still works.

To fix this simply skip the progress bar setup for empty files.

While at it fix the deprecated argument in the tests.

Fixes #23281

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-07-18 13:23:00 +02:00
openshift-merge-bot[bot] e225cae781
Merge pull request #23145 from afbjorklund/remove-machine-volume-driver
Remove the unused machine volume-driver
2024-07-15 20:36:19 +00:00
Arthur Sengileyev d26f0ca90f Implement disable default mounts via command line
Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
2024-07-15 15:27:19 +03:00
openshift-merge-bot[bot] dad2d17e1c
Merge pull request #23223 from baude/libkrundoc
add libkrun test docs
2024-07-09 14:45:51 +00:00
Brent Baude 6f6e0e7126 add libkrun test docs
add how to run the machine tests on macos with libkrun to the quick test readme.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-07-09 08:54:09 -05:00
Paul Holzinger 336c45f68e
pkg/machine/e2e: run debug command only for macos
The commands only make sense on macos so do not clutter the logs on
linux/windows with the output.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-07-09 13:14:42 +02:00
Paul Holzinger 5e3d821814
pkg/machine/e2e: print tests timings at the end
Makes it easier to see which tests are slow.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-07-05 15:28:33 +02:00
Paul Holzinger 527c0f0bfa
pkg/machine/e2e: run debug commands after init
To debug the slow machine init command. Let's see the disk image size.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-07-05 15:28:33 +02:00
Paul Holzinger ada4e1a8c1
pkg/machine/e2e: improve timeout handling
In case of timeouts actually log the command again and make sure to send
SIGABRT to the process as go will create a useful stack strace where we
can see where things are hanging. It also kill the process unlike the
default Eventually().Should(Exit()) call the leaves the process around.

The output will be captured by default in the log so we just see the
stack trace there.

And while at it bump the timout up to 10 mins, we are hitting hard
flakes in CI where machine init takes longer than 5 mins for unknown
reasons but this seems to be good enough.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-07-05 15:28:33 +02:00
openshift-merge-bot[bot] 3b07ae4557
Merge pull request #23123 from baude/libkruntest
Small fixes for testing libkrun
2024-07-02 13:28:27 +00:00
openshift-merge-bot[bot] f5d50a68bc
Merge pull request #23154 from Luap99/machine-test-connection
pkg/machine/e2e: fix broken cleanup
2024-07-02 12:14:10 +00:00
openshift-merge-bot[bot] 3a41bccf7d
Merge pull request #22941 from ashley-cui/machreset
Podman machine resets all providers
2024-07-01 19:24:18 +00:00
Paul Holzinger 3c0176b2d0
pkg/machine/e2e: fix broken cleanup
Currently all podman machine rm errors in AfterEach were ignored.
This means some leaked and caused issues later on, see #22844.

To fix it first rework the logic to only remove machines when needed at
the place were they are created using DeferCleanup(), however
DeferCleanup() does not work well together with AfterEach() as it always
run AfterEach() before DeferCleanup(). As AfterEach() deletes the dir
the podman machine rm call can not be done afterwards.

As such migrate all cleanup to use DeferCleanup() and while I have to
touch this fix the code to remove the per file duplciation and define
the setup/cleanup once in the global scope.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-07-01 14:23:11 +02:00
Paul Holzinger f84f4a9cce
pkg/machine/e2e: use tmp file for connections
On linux and macos the connections are stored under the home dir by
default so it is not a problem there but on windows we first check
the APPDATA env and use this dir as config storage. This has the problem
that it is not cleaned up after each test as such connections might leak
into the following test causing failues there.

Fixes #22844

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-07-01 13:04:03 +02:00
openshift-merge-bot[bot] 94ebb12bcf
Merge pull request #23126 from baude/checkmem
Error when machine memory exceeds system memory
2024-07-01 10:05:14 +00:00
Anders F Björklund fa75599569 Remove the unused machine volume-driver
The driver is now hardcoded again, and there can only be
one type of mounts at a time (which one changes over time)

Revert "Make it possible to select the volume driver"
This reverts commit 6630e5cf66.

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
2024-06-30 20:25:59 +02:00
Brent Baude 786ea01a64 Error when machine memory exceeds system memory
Close loophole that would allow you to assign more memory than the
system has to a podman machine

Fixes: #18206

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-06-28 10:02:11 -05:00
Christophe Fergeau 0d0418a5bf machine: Always use --log-file with gvproxy
The logs are not verbose if `--debug` is not set, and very useful to
have if gvproxy exits unexpectedly.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2024-06-28 16:05:21 +02:00
Brent Baude d2ca2058c6 Small fixes for testing libkrun
This PR is a couple of small fixes so that our CI would be capable of running the machine test suite on the libkrun provider.

RUN-2172

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-06-27 13:41:39 -05:00
Ashley Cui 069eace84b Podman machine resets all providers
Podman machine reset now removes and resets machines from all providers availabe on the platform.

On windows, if the user is does not have admin privs, machine will only reset WSL, but will emit a warning that it is unable to remove hyperV machines without elevated privs.

Signed-off-by: Ashley Cui <acui@redhat.com>
2024-06-27 13:14:29 -04:00
openshift-merge-bot[bot] d367d55d33
Merge pull request #23118 from Luap99/machine-flake
apple virtiofs: fix racy mount setup
2024-06-27 15:41:55 +00:00
openshift-merge-bot[bot] b91d0faf6e
Merge pull request #22922 from BlackHole1/improve-windows
refactor(machine,wsl): improve operations of Windows API
2024-06-27 12:49:35 +00:00
Paul Holzinger fdb736d282
apple virtiofs: fix racy mount setup
One problem on FCOS is that the root directory is immutable, as such in
order to mount arbitrary paths from the host we must make it mutable
again and create these dir on boot in order to be able to mount there.

The current logic was racy as it used one unit for each path and they
all did chattr -i /; mkdir -p $path; chattr -i / and systemd can run
these units in parallel. That means it was possible for another unit to
make / immutable before the unit could do the mkdir. I pointed this out
on the original PR[1] but we never followed up on it...

Now this here changes several things. First have one unit that does the
chattr -i / (immutable-root-off.service), it is hooked into
remote-fs-pre.target which means it is executed before the network
mounts (virtiofs) are done.

Then we have another unit that does chattr +i /
(immutable-root-on.service) which turn the immutable root back on after
remote-fs.target which means all mount are done at this point.

Additionally the automount unit is removed because it does not add any
value for us and it was borken anyway as it used the virtiofs tag as
path so systemd just ignored it.

[1] https://github.com/containers/podman/pull/20612#discussion_r1384846241

Fixes #22569

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-06-27 14:24:07 +02:00
Paul Holzinger 7562f4ccdb
pkg/machine/apple: machine stop timeout
The current timeout was not long enough. Systemd default is 90s so we
should wait for at least that long. Also it really doesn't make sense to
throw an error we saying we failed waiting for stop. We should hard
terminate the VM in case a graceful shutdown did not happen.

Fixes #22515

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-06-25 15:54:13 +02:00
openshift-merge-bot[bot] 0563fb4217
Merge pull request #22920 from cgwalters/virtiofsd-machine
machine/linux: Switch to virtiofs by default
2024-06-24 17:58:08 +00:00
Ashley Cui 4dc98e3a5a pkg/machine/e2e: Remove unnecessary copy of machine image.
Stop copying the pre-pulled uncompressed machine disk into the individual test dir. The machine pull code already makes a copy of the disk into the test's HOMEDIR/.local/share/containers/podman/machine, and works off that copy.

Before the change: TESTDIR/<image> is copied to TESTDIR/podman_test/<image> by the test, and then podman machine copies the image to TESTDIR/podman_test/.local/share/containers/podman/machine/provider/<image>

After the change: TESTDIR/<image> is copied to TESTDIR/podman_test/.local/share/containers/podman/machine/provider/<image> by podman machine

The image that is actually run is at TESTDIR/podman_test/.local/share/containers/podman/machine/provider/<image> in both instances.

Signed-off-by: Ashley Cui <acui@redhat.com>
2024-06-21 12:54:24 -04:00
Paul Holzinger 5c1e5cd026
pkg/machine/wsl: force terminate wsl instance
We do a soft stop via systemd to allow graceful shutdown behavior.
Hoewever for unknown reason we are hitting such a case in CI right now.
Regardless of the CI issue we should always to the hard terminate in
such case so only log the timeout as warning.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-06-17 17:52:01 +02:00
Paul Holzinger bd906cb314
pkg/machine/wsl: wrap command errors
First of some commands ignored cmd.Wait() error which means it was
impossible to notice any command errors. And others only returned
the wait error as it which when a command fails is just
`exit status <code>` which is not helpful at all.

This commit should add proper error wrapping with stderr to get useful
strings back hopefully.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-06-17 17:46:23 +02:00
openshift-merge-bot[bot] 009a2441de
Merge pull request #22759 from slp/krun-debug
Enable libkrun provider to open a debug console
2024-06-12 06:30:04 +00:00
Kevin Cui 0c587f0246
refactor(machine,wsl): improve operations of Windows API
1. Prefer using the built-in functions of `golang.org/x/sys/windows` rather than using `syscall` to directly call system APIs
2. Reduce bitwise operations to improve code maintainability
3. Minimize defining your own Flags, and prioritize using those already defined in `golang.org/x/sys/windows`

Signed-off-by: Kevin Cui <bh@bugs.cc>
2024-06-11 09:44:43 +08:00
Paul Holzinger fa4f11facc
update golangci-lint to v1.59.1
Includes fixes for new lint warnings from unparam and usestdlibvars.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-06-10 14:57:45 +02:00
Colin Walters 4b29c9dd73 machine/linux: Switch to virtiofs by default
Switch to using virtiofs by default, and delete the 9p code.
This is structured as a separate patch to make it easier
to revert if need be.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-06-07 10:03:06 -04:00
Colin Walters bf541c6740 machine/linux: Support virtiofs mounts (retain 9p default)
I'm hitting a bug with 9p when trying to transfer large files.
In RHEL at least 9p isn't supported because it's known to have a
lot of design flaws; virtiofsd is the supported and recommended
way to share files between a host and guest.

Add a new hidden `PODMAN_MACHINE_VIRTFS` environment
variable  that can be set to `virtiofs` to switch to virtiofsd.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-06-07 10:03:06 -04:00
Colin Walters 406f130590 machine/linux: Use memory-backend-memfd by default
This is prep for using virtiofsd; it has no real
impact otherwise.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-06-07 10:03:06 -04:00
Sergio Lopez 550cb07fc0 Enable libkrun provider to open a debug console
When running with "log-level=debug" and libkrun as machine provider,
spawn a Terminal to execute "krunkit" to enable users to have full
access to the VMs console for debugging purposes.

Users obtain an interactive, text console with scrollback. It's possible
to interact with both the kernel and GRUB2. To obtain even additional
debugging information, users can add "console=hvc0" to the linux kernel
command line through GRUB2 (it may be worth considering extending the
initial configuration of the VM to add that argument by default).

Signed-off-by: Sergio Lopez <slp@redhat.com>
2024-06-06 15:20:56 +02:00
Chris Evich 74e8f98772
Mac PM test: Require pre-installed rosetta
Previously, the mac podman-machine tests installed rosetta before
executing any tests.  As a best-practice (and because the Macs in CI are
shared) tests should never permanently modify the system.  As of this
commit, the system setup script used for the CI Macs does the rosetta
installation.  Remove the test setup code that installed rosetta and
add a CI-level confirmation that it's been pre-installed.

Signed-off-by: Chris Evich <cevich@redhat.com>
2024-05-23 10:23:06 -04:00
Sergio Lopez 3ab9e864f6 Check AppleHypervisor before accessing it
In GetDefaultDevices(), make sure MachineConfig has an AppleHypervisor
instance before attempting to access it. This fixes a SIGSEGV when
running with libkrun as machine provider.

Signed-off-by: Sergio Lopez <slp@redhat.com>
2024-05-20 16:17:59 +02:00
openshift-merge-bot[bot] 34d2d20d46
Merge pull request #21670 from tnk4on/rosetta-support
applehv: Rosetta support
2024-05-17 20:39:40 +00:00
Shion Tanaka fe7cc67ef4 Add Rosetta support for Apple Silicon mac
Signed-off-by: Shion Tanaka <shtanaka@redhat.com>
2024-05-17 17:53:28 +09:00
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