Commit Graph

32 Commits

Author SHA1 Message Date
Miloslav Trmač 265ca77276 Be explicit about ssh configs suitable only for localhost
... and warn loudly against generalization.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2025-05-15 23:04:49 +02:00
Mario Loriedo 8e6ecb97c9 Fix running machines with volumes containing spaces
Machines configured to mount local paths containing
spaces failed to start on Hyper-V and silently failed
to mount the folder on macOS/Linux.

On Windows/hyperv, where local paths are mounted
running a 9p client inside the VM, the local host
path needs to be surrounding with quotation marks
before using in a `podman machine ssh ...` command.

A similar behavior happened on Linux/QEMU where the
path was used in a SSH command to mount the folder
using virtiofs. Quoting the path when buidling the
command arguments fixed the problem.

On macOS/libkit,applehv the path was written as is
in a systemd unit name to instruct how to mount it.
Escaping space chars so that they are are parsed
successfully fixed this:
```diff
-- enable path with spaces.mount
++ enable path\x20with\x20spaces.mount
```

Fixes https://github.com/containers/podman/issues/25500

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2025-04-30 08:54:42 +02:00
Arthur Sengileyev 7f6a203558 Fix compilation issues in QEMU machine files (Windows platform)
Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
2024-11-27 17:23:08 +02:00
Paul Holzinger 9eca92d625
update golangci-lint to v1.62.0
- fix issues found by recvcheck
- skip k8s files from recvcheck
- remove two removed linters gomnd and execinquery

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-11-11 14:21:17 +01:00
Mario Loriedo b2e6d53265 Get WSL disk as an OCI artifact
[Since a few days][1] WSL disk releases are also pushed
to [quay.io/podman/machine-os-wsl][2]. This PR updates
`podman machine init` mechanism to download WSL disk
images. The WSL disk images are now pulled from quay.io
as for the rest of the providers.

Fixes [#22927][3] and [RUN-2177][4]

[1]: https://github.com/containers/podman-machine-wsl-os/pull/6
[2]: https://quay.io/repository/podman/machine-os-wsl?tab=tags
[3]: https://github.com/containers/podman/issues/22927
[4]: https://issues.redhat.com/browse/RUN-2177

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2024-09-16 14:36:50 +02: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
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
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
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
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
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
Jason T. Greene 6272abbbb8 Resurrect auto-port reassignment, but for all providers
- Updates common to pull in new locked edit

[NO NEW TESTS NEEDED]

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2024-03-04 23:55:36 -06:00
Ashley Cui 35133c8424 Move locks to shim layer
Previously, the locks were on the provider layer, which doesn't make a vm operation with a config file update atomic. Move them up a layer, so the entire function locks while doing provider and config operations.

This adds a Remove and a Set function to the shim layer.

[NO NEW TESTS NEEDED] Unsure how to test this

Signed-off-by: Ashley Cui <acui@redhat.com>
2024-02-29 00:12:04 -05:00
Arthur Sengileyev 656bf7b764 Change QEMU netdev to Unix domain socket
This change migrates to new QEMU stream netdev added in 7.2.0.
It also unifies how gvproxy is used in QEMU and AppleHV.

Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
2024-02-26 20:02:46 +02:00
Paul Holzinger f218f8430a
machine: implement http proxy logic for all providers
Copy all proxy envs into the VM on each start, this allows for updates
without having to recrate the VM. This is implemented via shell script
that is passed via ssh to the VM after it is started.

With that we now use the same logic for all providers the old fw_cfg
logic for qemu has been removed and the WSL code as well which keeps the
behavior the same.

There is a small risk now because we only update the env via ssh that
processes started before will have the old incorrect env but it should
really only effect core system processes which likely do not need them
anyway. The podman system service should not be started at this point
so it should be good enough.

It also fixes the broken behavior with SSL_CERT_FILE/SSL_CERT_DIR which
were updated on each start which is not correct as the files are only
copied with ignition so these should not be updated and just set
statically when the VM was created.

e2e test has been added to ensure the behavior works as expected.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-02-22 11:23:45 +01:00
openshift-merge-bot[bot] 89587a5d59
Merge pull request #21638 from ashley-cui/buildtag
Build tag out QEMU for Darwin
2024-02-19 13:31:58 +00:00
Arthur Sengileyev e0a7668547 Improve cross platform support in QEMU machine sources
Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
2024-02-16 12:49:54 +02:00
Ashley Cui a9401deadd Build tag out QEMU for Darwin
Macs no longer support QEMU as a provider, build tag it out.

Signed-off-by: Ashley Cui <acui@redhat.com>
2024-02-15 15:53:06 -05:00
openshift-merge-bot[bot] bed619ca3d
Merge pull request #21664 from n1hility/wsl-fix-conflict
Fixes VM name conflict checking with WSL
2024-02-15 20:24:22 +00:00
Paul Holzinger 9ee17d4222
machine/qemu: use extra gvproxy socket
Right now the code used the same socket for gvproxy and the qemu qmp
socket, this was racy and no correct as the later overwrote the former.
The correct thing is to use to separate socket paths, just use the
GVProxySocket() helper like applehv does.

[NO NEW TESTS NEEDED]

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-02-15 16:25:38 +01:00
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
Jake Correnti 0e9d867555 machine: `machine set` only when machine's stopped
Requires that the specified machine's state is `define.Stopped` in order
to set settings.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2024-02-13 16:50:22 -05: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
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
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 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