Commit Graph

614 Commits

Author SHA1 Message Date
Jason T. Greene d23dd35dc1 Correct VM existance check on WSL
Replaces GetHyperVisorVMs() with Exists() to better abstract the underlying
use-case and slightly imrpove efficiency.

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2024-02-14 15:27:56 -06:00
Brent Baude 001824b9f3 Windows uses USERPROFILE not HOME
When dealing with environment variables that set $HOME, we do not get
the desired result.  Windows will honor USERPROFILE.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-02-13 13:20:06 -06:00
openshift-merge-bot[bot] c88c689584
Merge pull request #21602 from baude/ociartdisk
Allow podman machine to download from oci registry
2024-02-13 12:51:28 +00:00
Matt Heon 66e292ebb9 Fix build on Main
Signed-off-by: Matt Heon <mheon@redhat.com>
2024-02-12 18:02:07 -05:00
openshift-merge-bot[bot] fcd69c997e
Merge pull request #21542 from jakecorrenti/bump-gvproxy
Enable passing logfile to gvproxy
2024-02-12 21:49:41 +00:00
Brent Baude 2430fc71a0 Allow podman machine to download from oci registry
this pr represents a shift in how we download podman machine images.
these images will now be stored in oci registry and will replace the
default method of downloading an image.  you can still use a reference
to a disk image as a path or url too with the --image-path switch.

the final registry and location of the images has not been determined;
and will need to be updated in podman as well.

i dont think we need to allow --image-path to accept a registry/image
for the podman 5.0 release.  i do think there will be demand for this.

upgrades also need to be plumbed.  for example, updating from an oci
registry.

once we make decisions on final image locations/registrties as well as
some behaviors of init and the oci pull, we must update the machine-init
documentation.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-02-12 15:19:34 -06:00
Matt Heon f7f4d1064d Fix the build on main
[NO NEW TESTS NEEDED]

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-02-12 14:34:46 -05:00
openshift-merge-bot[bot] 49aba43234
Merge pull request #21573 from baude/nofail
Don't panic on podman4 machine configs
2024-02-12 18:10:55 +00:00
openshift-merge-bot[bot] c524da252e
Merge pull request #21597 from n1hility/wsl-refactor
Complete WSL implementation in Podman 5
2024-02-12 18:05:45 +00:00
Jason T. Greene f8847ea047 Improve comments on waitOnProcess
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2024-02-12 09:17:56 -06:00
Brent Baude d3328d4f32 Don't panic on podman4 machine configs
we should not panic podman when it has to deal with a podman4 machine
config.  instead, we throw a soft error for `machine ls` and in all
other cases, we throw a hard error stating that the machine config is
incompatible.

a future PR will provide instructions on how to recover from this.
current idea is something like `podman machine reset` which blows
everything away machine-wise.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-02-12 09:10:46 -06:00
openshift-merge-bot[bot] 6d107a26fb
Merge pull request #21604 from baude/springclean
Minor cleanup from podman 4
2024-02-12 09:06:34 +00:00
Brent Baude bb7d8fdc41 Workaround connection hangups in start/stop racing
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2024-02-11 17:04:15 -06:00
Jason T. Greene 09b86e26d1 Improve robustness of pipe checks
Improve error reporting on ssh readiness check

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2024-02-11 17:04:09 -06:00
Jason T. Greene 487219d809 Complete WSL implementation, refactor a few areas
Also addresses a number of issues:
- StopHostNetworking isn't plumbed, win-sshproxy leaks on hyperv
- Wait api and print output doesn't work properly on Windows
- API forwarding doesn't work on WSL
- Terminal corruption with after start/stop on Windows
- Gvproxy is forcefully killed vs gracefully quit
- Switching rootful/rootless does not update /var/run/docker.sock on the guest
- File already closed error on init
- HyperV backend is publishing Unix sockets when it should be named pipes
- User-mode networking doesn't always work
- Stop state outside of lock boundaries
- WSL blocks parallel machined (should be supported)

[NO NEW TESTS NEEDED]

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2024-02-11 12:58:11 -06:00
Brent Baude d7cb66492b wsl - wip
Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-02-11 12:58:11 -06:00
Brent Baude e74d268bf2 Minor cleanup from podman 4
This PR is only a few cleanup items where code is no longer used.  More
to come I'm sure

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-02-11 09:29:13 -06:00
Brent Baude 2a61998f07 Fail if vm exists in hyperv already
Fix a bug where if a vm exists, created by some other process/user, and
you attempt to make a podman machine with the same name.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-02-10 14:49:34 -06:00
openshift-merge-bot[bot] 4ff00f46b2
Merge pull request #21591 from l0rd/crc-copysparse-vendoring
Get CopySparse from github.com/crc-org/crc/
2024-02-09 20:44:41 +00:00
Mario Loriedo 7ecc414678 Vendor crc CopySparse
Added the module github.com/crc-org/crc/ as a dependency.

Updated `decompress.go` and `copy_test.go` in compression
so that `CopySparse` from crc-org/crc/v2/pkg/os is used instead
of the local version in `copy.go`.

Deleted `copy.go` that is not used anymore.

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2024-02-09 19:33:56 +01:00
openshift-merge-bot[bot] da5bab6257
Merge pull request #21577 from jakecorrenti/get-default-devices-machineconfig
machine: change getDefaultDevices signature
2024-02-09 16:59:04 +00:00
Jake Correnti 7be6cd4b09 machine: USB passthrough
Sets up USB passthrough for machine. Additionally moves `SetOptions` out
from `pkg/machine/config.go` to its own file in
`pkg/machine/define/setopts.go`.

[NO NEW TESTS NEEDED]

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2024-02-08 20:30:43 -05:00
Jake Correnti 02eb907db0 machine: change getDefaultDevices signature
Changes the signature for `getDefaultDevices` to take
a `vmconfigs.MachineConfig`.

[NO NEW TESTS NEEDED]

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2024-02-08 20:27:33 -05:00
Paul Holzinger 9f38b22152
pkg/machine: make it build for freebsd
This is completely untested as I do not have access to a freebsd system
but it compiles and changes look simple enough to assume it works.

[NO NEW TESTS NEEDED]

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-02-08 17:43:50 +01:00
Matt Heon 72f1617fac Bump Go module to v5
Moving from Go module v4 to v5 prepares us for public releases.

Move done using gomove [1] as with the v3 and v4 moves.

[1] https://github.com/KSubedi/gomove

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-02-08 09:35:39 -05:00
Jake Correnti c023b789f2 Re-enable passing a logfile to gvproxy
Re-enable the commented-out code that passed the path to a logfile to
gvproxy when the user passes `--log-level=debug`

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2024-02-08 08:32:01 -05:00
Jake Correnti 90c938737a Add functionality for `podman machine set --rootful`
Adds the functionality for `podman machine set --rootful` for AppleHV,
QEMU, and HyperV. Abstracts the functionality out to a method of
`MachineConfig`. WSL currently uses a function `SetRootful` that is
provided by the `machine` package, which will eventually get changed
when WSL moves to the refactored structure.

Re-enables the "set rootful with docker sock change" test.

[NO NEW TESTS NEEDED]

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-02-07 13:24:18 -06:00
Brent Baude f23b144c60 Podman Machine AppleHV CI fixes
This PR contains several fixes that allow the applehv podman tests run
to completion.

Signed-off-by: Brent Baude <baude@redhat.com>
2024-02-07 09:19:16 -06:00
Brent Baude d5eb8f3b71 AppleHV - make gz ops sparse
gz by definition is not able to preserve the sparse nature of files.  using some code from the crc project and gluing it together with our decompression code, we can re-create the sparseness of a file.  one downside is the operation is a little bit slower, but i think the gains from the sparse file are well worth it in IO alone.

there are a number of todo's in this PR that would be ripe for quick hitting fixes.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <baude@redhat.com>
2024-02-07 09:19:09 -06:00
Brent Baude 85d8281484 create machine dirs at discovery
in various use cases, the required machine dirs are not created.  the
machine dirs are runtimedir, datadir, and configdir.  Example in Linux
would be:

configDir /<HOME>/.config/containers/podman/machine/<provider>
dataDir /<HOME>/.local/share/containers/podman/machine/<provider>
runtimeDir /run/user/1000/podman/machine

now we blindly create them without checking for their existence (because
it is faster).

this fixes a bug where runtimedir does not exist on macos after a reboot

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <baude@redhat.com>
2024-02-07 09:19:00 -06:00
Brent Baude b1ce6ef9a8 podman machine 5 - hyperv
this pr represents the podman 5 maching refactoring for HyperV.  with
the exception of already skipped tests, all local tests pass.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-02-07 09:18:51 -06:00
Brent Baude 6b02c4894b Podman 5 machine refactor - applehv
this is the second provider done (qemu first).  all tests pass on arm64 hardware locally ... the hybrid pull from oci registries limit this to arm64 only.

calling gvproxy, waiting for it, and then vfkit seems to still be problematic.  this would be an area that should be cleaned up once all providers are implemented.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-02-07 09:18:45 -06:00
Brent Baude e8501ca991 Implement generic providers
The intial refactor used specifically qemu for testing and infra bring
up.  But the whole point was to have things interfaced.  This PR results
in an interface experience like podman 4 using the same term `provider`
to generically represent 'a provider' like qemu/applehv/etc.

This PR is required to move forward with new providers.

Also renamed pkg/machine/p5 to pkg/machine/shim.

[NO NEW TESTS REQUIRED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-02-07 09:18:38 -06:00
Brent Baude 9bb191df51 [CI:MACHINE]Podman5 QEMU refactor
The following PR is the leading PR for refactoring podman machine with
the following goals:

* less duplication/more re-use
* common configuration file between providers
* more consistentency in how machines are handled by providers

The goal of this PR is the rough refactor.  There are still rough spots
for sure, specifically around the podman socket and pipe.  This
implemention is only for Linux. All other providers are still present
but will not compile or work.  This is why tests for them have been
temporarily suspended.

The ready socket code is another area that needs to be smoothed over.
Right now, the ready socket code is still in QEMU.  Preferably it would
be moved to a generic spot where all three approaches to readiness
socket use can be defined.

It should also be noted:

* all machine related tests pass.
* make validate for Linux passes
* Apple QEMU was largely removed
* More code pruning is possible; will become clearer when other
  providers are complete.

the dir pkg/machine/p5 is not permanent.  i had to seperate this from
machine initially due to circular import problems.  i think when all
providers are done (or nearly done), it can be placed and named
properly.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-02-07 09:18:36 -06:00
Brent Baude b9bcfa4749 podman5 machine reconfig 1
this is a logical place to get changes upstream before they grow out of
control.  this pr is the first in an effort to deduplicate machine code
and streamline code flow.

a lot of code is simply moved to eliminate circular imports.  names and
specific paths can ultimately be changed.  i dont like some of the
descriptive interface names, etc.  ultimately, i think once we have the
"old" code sanitized, we can re-use some of those.

clearly some of what is in here is temporary and will either be deleted,
changed, or moved again as this effort comes to a close.

right now, the machine code does not use any of the "new" code.  you
will see in `init` and `rm` some commented out code that hooks it. i'm
afraid things will get worse before they get better (way worse).

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-02-07 08:17:43 -06:00
Paul Holzinger 46fe7ef3bb
use pkg/strongunits from c/common
The code has been moved to c/common so it can be shared with libhvee.

[NO NEW TESTS NEEDED]

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-02-06 16:39:16 +01:00
Paul Holzinger 74454bf59c
rework system connection and farm storage
We now no longer write containers.conf, instead system connections and
farms are written to a new file called podman-connections.conf.

This is a major rework and I had to change a lot of things to get this
to compile again with my c/common changes.

It is a breaking change for users as connections/farms added before this
commit can now no longer be removed or modified directly. However because
the logic keeps reading from containers.conf the old connections can
still be used to connect to a remote host.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-01-31 15:08:41 +01:00
Daniel J Walsh 8d14d41555
Run codespell on code
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-01-28 07:30:52 -05:00
Shion Tanaka 0e64e107ba Fix Mount Unit Option
Signed-off-by: Shion Tanaka <shtanaka@redhat.com>
2024-01-22 02:41:48 +09:00
openshift-merge-bot[bot] e37752d5a6
Merge pull request #21297 from rhatdan/apple
Label host volume mounted content in machine as nfs_t
2024-01-20 12:35:23 +00:00
Daniel J Walsh 75790b42b4
Label host volume mounted content in machine as nfs_t
While this is potentially a security problem, it solves the issues of
users sharing content from the host into containers and attempting to
relabel it. From a security point of view this means all content volume
mounted from the host into the podman machine on apple hypervisor is
read/write from an SELinux point of view if it is volume mounted into
the container. If the user attempts to use :Z or :z it will work and
relabel the content to be only usable bu the specify container.

Helps Fix: https://github.com/containers/podman/issues/21269

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-01-18 12:43:16 -05:00
kaorihinata 7472bdb161 Ensure podman temp directory is created on Start as well.
`getRuntimeDir()` (which is also responsible for creating TMPDIR if it doesn't exist) was being called on `Init()` but not on `Start()` which meant that after the host was restarted and TMPDIR was wiped, `startHostNetworking()` would try to start gvproxy and immediately bail.

Signed-off-by: kaorihinata <kaori.hinata@gmail.com>
2024-01-18 12:37:13 -05:00
openshift-merge-bot[bot] 597ff52352
Merge pull request #21264 from cfergeau/applehv
applehv: return socket path from setupAPIForwarding
2024-01-18 02:47:12 +00:00
Brent Baude 1964dbd406 Set up podman machine remote user correctly
The remote user functionality was not quite correct.  This PR breaks out
the accumulation of user descriptions into a separate function.  One
odditiy is ignition must be told to NOT create the core user (or it will
by default) by "adding" the core user with a set bool.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-01-17 08:57:46 -06:00
openshift-merge-bot[bot] e293ca8916
Merge pull request #21262 from n1hility/net-recovery
Add a net health recovery service to qemu machines
2024-01-17 13:22:39 +00:00
Jason T. Greene 79fad91dbb Add a net health recovery service to Qemu machines
There is a network stability issue in qemu + virtio, affecting
some users after long periods of usage, which can lead to
suspended queue delivery. Until the issue is resolved, add a
temporary recovery service which restarts networking when host
communication becomes inoperable.

[NO NEW TESTS NEEDED]

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2024-01-16 16:39:47 -06:00
Christophe Fergeau 3fef531d96 applehv: return socket path from setupAPIForwarding
When starting podman machine with applehv, this warning is printed:
WARN[0025] API socket failed ping test

This is due to a bug in applehv.setupAPIForwarding which is not
returning the path to the socket, which causes `WaitAndPingAPI` to be
called with `""` as the socket path, triggering the warning.

This commit changes setupAPIForwarding to be similar to the
implementation in the other machine implementations.

I don't know how to add a test for this, but this can be handled in
podman-machine end to end tests by making sure that there are no
warnings when running `podman machine start` with applehv.

[NO NEW TESTS NEEDED]

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2024-01-16 17:06:22 +01:00
Christophe Fergeau 90f69891d7 applehv: Remove unneeded cmd.ExtraFiles assignment
`applehv.Start()` has this line of code:
```
cmd.ExtraFiles = []*os.File{ioEater, ioEater, ioEater}
```
whose purpose is not clear.

The intent may have been to redirect stdin/stdout/stderr to /dev/null in
the child process.
This should be done by setting cmd.Stdin/cmd.Stdout/cmd/Stderr to nil,
which is the case by default.

The way it's done could also cause issues as
`Vfkit.VirtualMachine.Cmd()` sometimes adds files it needs to keep open
to `ExtraFiles`, so at the very least this should be an `append()`

This commit removes this code.

[NO NEW TESTS NEEDED]

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2024-01-16 17:06:10 +01:00
openshift-merge-bot[bot] a2fcca4066
Merge pull request #21161 from cgwalters/machine-autologin-console
machine: Enable console autologin by default
2024-01-13 03:45:38 +00:00
Colin Walters 992e83d203 machine: Enable console autologin by default
There are no security concerns here; this is a convenience
for people debugging things.  Some podman-machine developers
were manually setting a password over SSH for example,
but this is just better than that.

[NO NEW TESTS NEEDED]

Signed-off-by: Colin Walters <walters@verbum.org>
2024-01-12 15:02:32 -05:00