Commit Graph

590 Commits

Author SHA1 Message Date
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 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
Ashley Cui f374e07fb0 AppleHV: update LastUp time
LastUp now correctly reports the lastUp time for podman machine on
AppleHV, for both inspect and list.

[NO NEW TESTS NEEDED]
since this fixes an existing failing test.

Signed-off-by: Ashley Cui <acui@redhat.com>
2024-01-12 12:04:57 -05:00
openshift-merge-bot[bot] e06abd1840
Merge pull request #21232 from ashley-cui/vfkitport
Assign separate ports for each appleHV machine
2024-01-12 02:05:53 +00:00
openshift-merge-bot[bot] a193eaf16e
Merge pull request #21230 from jakecorrenti/applehv-set-rootful
Fix `podman machine set --rootful` for applehv
2024-01-11 21:19:35 +00:00
Ashley Cui f6107f6319 Assign separate ports for each appleHV machine
Previously, every machine created using appleHV interacted with VFKit using port 8081. This meant that if multiple machines existed on the machine, starting one would start all the machines. This patch assigns a separate random port for each machine, so machine commands interact with just the specified machine.

Signed-off-by: Ashley Cui <acui@redhat.com>
2024-01-11 12:19:04 -05:00
Ashley Cui eeff3d2de8 Fix machine inspect test config
Signed-off-by: Ashley Cui <acui@redhat.com>
2024-01-11 11:42:54 -05:00
Jake Correnti 7bd5dd42c9 Fix `podman machine set --rootful` for applehv
Fixes a bug where a user would be unable to change
a rootless machine to rootful. Also makes sure that
the podman/docker socket service is updated if the
UID or Rootful status of the host user has been
updated.

[NO NEW TESTS NEEDED]

Fixes: #21195

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2024-01-11 11:09:09 -05:00
Philip Dubé 522934d5cf Replace strings.SplitN with strings.Cut
Cut is a cleaner & more performant api relative to SplitN(_, _, 2) added in go 1.18

Previously applied this refactoring to buildah:
https://github.com/containers/buildah/pull/5239

Signed-off-by: Philip Dubé <philip@peerdb.io>
2024-01-11 13:50:15 +00:00
openshift-merge-bot[bot] cb473e8883
Merge pull request #21061 from benoitf/DESKTOP-5282
feat: disable pid max in the podman machine
2024-01-10 11:02:01 +00:00
openshift-merge-bot[bot] 3b18c77712
Merge pull request #20878 from ashley-cui/winapiforwarding
Add API forwarding support for HyperV
2024-01-08 20:07:23 +00:00
Florent Benoit 3b881d4ecc feat: disable pid max in the podman machine
fix https://github.com/containers/podman-desktop/issues/5282

With FCOS we have a limit of 2048 files
But when launching containers like kind containers, we're reaching
easily the limit.
AFAIK as it's inside a dedicated machine, limit should be max
Limit should be only at the container level.

Signed-off-by: Florent Benoit <fbenoit@redhat.com>
2024-01-08 10:16:10 -05:00
openshift-merge-bot[bot] 1697a8bfcf
Merge pull request #21175 from baude/consolidateIgnitionReadySocket
consolidate ignition ready socket unit
2024-01-06 11:18:57 +00:00
openshift-merge-bot[bot] 8b6d2a6d93
Merge pull request #21172 from cgwalters/machine-use-datadir
machine: use GlobalDataDir helper
2024-01-05 17:52:15 +00:00
openshift-merge-bot[bot] 0a316fa7d4
Merge pull request #21171 from alexandear/refactor-slices-contains
Refactor: replace StringInSlice with slices.Contains
2024-01-05 17:49:26 +00:00
Ashley Cui e3f167f770 Add API forwarding support for HyperV
Provides Docker API client access, allowing compose to work by default
for HyperV. Basically the HyperV equiv of the work done here by #12916.

[NO NEW TESTS NEEDED]

Signed-off-by: Ashley Cui <acui@redhat.com>
2024-01-05 11:45:28 -05:00
Brent Baude a0a541351d consolidate ignition ready socket unit
consolidated ignition ready unit file content into one function.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-01-05 10:11:43 -06:00
Colin Walters 06064150ea machine: use GlobalDataDir helper
We shouldn't hardcode `~/.local` - we should use the internal
config helper APIs which honor the XDG_DATA_DIR etc. standard
environment variables.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-01-05 10:29:36 -05:00
Oleksandr Redko 8bdf77aa20 Refactor: replace StringInSlice with slices.Contains
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-05 16:25:56 +02:00
Jake Correnti 3bfdd79150 Fix init teardown on bad ignition path
Fixes a bug where if a machine failed during init due to a bad ignition path, it would not be properly torn down.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2024-01-04 23:47:59 -05:00
Jake Correnti b01a330d37 Use single persistent ssh key for all machines
Changes SSH key behavior such that there is a single persisted key for all
machines across all providers. If there is no key that is located at
`.local/share/containers/podman/machine/` then it is created. The keys are
not deleted when the last machine on the host is removed.

The main motivation for this change is it leads to fewer files created on the
host as a result of vm configuration. Having `n` machines on your system doesn't
result in `2n` machine-related files in `.ssh` on your system anymore.

As a result of ssh keys being persisted by default, the `--save-keys` flag
on `podman machine rm` will no longer be supported.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2024-01-04 23:47:49 -05:00
Jake Correnti 98f332d482 Use parser.UnitFile
Uses the systemd unit file parser to build unit files instead of having
them be just blocks of hard-coded strings.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2024-01-04 08:51:35 -05:00
Jake Correnti c728eeb39e Create `pkg/machine/ignition` package
Moves all of the ignitionfiles out of the `machine` package and into
its own called `ignition`. This required `VMType` to get moved out of
the `machine` package and into the `define` package in order to prevent
a circular dependency.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2024-01-04 08:51:35 -05:00
openshift-merge-bot[bot] 94da6397e7
Merge pull request #21149 from cgwalters/machine-debugging
machine/qemu: A few debugging prints
2024-01-04 11:50:49 +00:00
Oleksandr Redko 2a2d0b0e18 chore: delete obsolete // +build lines
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-04 11:53:38 +02:00
Colin Walters 92f3bacc65 machine/qemu: A few debugging prints
I was trying to debug a failure which was seemingly related
to gvproxy failing which I now can't reproduce,
and added these while working on it.  Maybe they're useful in
the future.

[NO NEW TESTS NEEDED]

Signed-off-by: Colin Walters <walters@verbum.org>
2024-01-03 17:06:34 -05:00