406 Commits

Author SHA1 Message Date
fe7bafb83c Add port forwarding and gvproxy machine test
Added a test that checks that gvproxy properly starts and stops when running podman machine, and that containers properly forward ports to the host when running podman using machine.

Signed-off-by: Ashley Cui <acui@redhat.com>
2023-08-31 10:19:35 -04:00
1085177fee hyperv ignition: use gvforwarder instead of vm
in gvisor-vsock-tap upstream, there is a binary called 'vm' which is
used for routing traffic from a tap over something like vsock.  In
Fedora, the binary is named 'gvforwarder'.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-08-29 09:34:40 -05:00
2a8e6acecb Set remote username earlier for hyperv
the remote username was being set too "late" for hyperv and the username
for ssh connections was blank.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-08-29 09:34:40 -05:00
b6b300c798 Update machine init/set tests
Init/Set with --rootful
Init/Set  with --user-mode-networking

Signed-off-by: Ashley Cui <acui@redhat.com>
2023-08-25 11:28:07 -04:00
da81bc13a1 Add rootful status to machine inspect
Podman machine inspect now shows if the machine is rootful

Signed-off-by: Ashley Cui <acui@redhat.com>
2023-08-25 11:27:08 -04:00
c3ac109f17 Merge pull request #19734 from baude/acquireimage
Dedup and refactor image acquisition
2023-08-25 15:00:47 +02:00
d3618719b1 Dedup and refactor image acquisition
As promised in #19596, this pr deduplicates and refactors image
acquisition.  All virt providers that use FCOS as its default now use
the same code.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-08-24 20:52:03 -05:00
adf34cbd79 Share podman sock bindings with other WSL distros
Registers a rootless and rootful socket underneath /mnt/wsl/podman-sockets/[machine name]/
This allows podman remote clients on other Linux distributions to access podman.

This also registers the podman root socket under the wheel group, to allow for rootful
linking against /var/run/docker.sock, a use case expected by some clients and APIs.
While this is not recommended practice on a Linux host, a WSL guest is user-isolated
and already enables escalation trivially.

[NO NEW TESTS NEEDED]

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2023-08-24 16:23:50 -05:00
db95e678ad Fix user-mode validation check
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2023-08-24 16:23:50 -05:00
a9c98770e6 Merge pull request #19557 from n1hility/automatic-ports
Implement automatic port reassignment on Windows
2023-08-23 06:49:11 -02:30
9e680cbc63 Fixups for stopping gvproxy
Paul found logic errors in my earlier code for finding processes and
sending signals.  Some of the logic errors are associated with how
methods behave on different operating systems.  Created a darwin and
linux approach and a windows approach.

Signed-off-by: Brent Baude <bbaude@redhat.com>

[NO NEW TESTS NEEDED]
2023-08-22 16:00:15 -05:00
63a8926e96 Implement automatic port reassignment on Windows
While only leveraged by the WSL backend, this commit also adds core
infrastructure for all other backends for future enhancement.

- Adds a common port cross backend allocation registry to prevent duplicate
  assignment across multiple machine instances
- Introduces logic in Start() that detects OS port conflicts and scans for a
  viable replacement port
- Updates connection definitions and server configuration accordingly
- Utilizes a coordinated file lock strategy to prevent racing overwrites of port
  and connection registries
- WSL backend coordinates locking for containers.conf until a future common
  enhancement exists to replace it

[NO NEW TESTS NEEDED]

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2023-08-21 07:23:31 -05:00
bdc3040586 Validate current generation of WSL2 with user-mode-networking
Fail with a helpful message when older version is present.

[NO NEW TESTS NEEDED]

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2023-08-18 23:33:30 -05:00
20f28e538d Merge pull request #19516 from baude/stopgvproxy
Stop gvproxy on hyperv machine stop
2023-08-18 06:45:39 -02:30
884e5f6934 Merge pull request #19668 from ashley-cui/teststart
Update machine start tests
2023-08-18 06:40:32 -02:30
a161e8b7d8 Merge pull request #19667 from ashley-cui/testrm
Update machine rm tests
2023-08-18 06:37:55 -02:30
0772d8ddb0 Stop gvproxy on hyperv machine stop
when we stop a machine, we need to also stop the gvproxy process that is
running.

JIRA: RUN-1828

also, remove unused applehv function for ssh

Signed-off-by: Brent Baude <bbaude@redhat.com>

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-08-17 15:21:06 -05:00
36e09f18bb Update machine list test
check if --format json returns valid json

Signed-off-by: Ashley Cui <acui@redhat.com>
2023-08-17 15:05:48 -04:00
8b29901316 Update machine start tests
Start machine that is already running
Start bad name

Signed-off-by: Ashley Cui <acui@redhat.com>
2023-08-17 15:04:18 -04:00
c3dbfa9a1e Update machine rm tests
Remove with --save-ignition, --save-image, --save-keys
Removing a running machine should result in error

Signed-off-by: Ashley Cui <acui@redhat.com>
2023-08-17 15:00:35 -04:00
9cd4286922 Merge pull request #19596 from baude/allowdownload
enabled hyperv image downloads
2023-08-16 09:52:18 -02:30
252f51de84 GetFcosArch add riscv64 arch
[NO NEW TESTS NEEDED]

Signed-off-by: Michal Biesek <michalbiesek@gmail.com>
2023-08-15 15:29:24 +02:00
98e7d7af01 Update WSL backend to be compat with FCOS defaults
container/common Config was recently updated to use FCOS
default names, since Windows HyperV backend needs them,
and these are common with other providers.

Map this to values the WSL backend expects.

[NO NEW TESTS NEEDED]

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2023-08-15 07:48:59 -05:00
9e14e3ebe5 enabled hyperv image downloads
now that we have public hypverv fcos artifacts, we can download them
instead of requiring a special build.

Signed-off-by: Brent Baude <bbaude@redhat.com>

[NO NEW TESTS NEEDED]
2023-08-15 07:45:29 -05:00
38b20bda29 Merge pull request #19510 from baude/errorifkeyexists
Fail if ssh key exists
2023-08-05 12:27:14 +02:00
1304162b1c Merge pull request #19512 from baude/userkeyswitch
Fix regression for hyperv
2023-08-04 19:13:50 +02:00
fc7c6efd3b Fail if ssh key exists
when init'ing a machine, if the ssh key already exists, then we get a
somewhat oblique error.  here we make it clear what the problem was and
early return.

Signed-off-by: Brent Baude <bbaude@redhat.com>

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-08-04 09:13:50 -05:00
69e883493b Fix regression for hyperv
the method caller for creating the ignition file was accidently
misordered for hyperv.  this regression was caused by aa6827a6.

Signed-off-by: Brent Baude <bbaude@redhat.com>

[NO NEW TESTS NEEDED]
2023-08-04 09:10:10 -05:00
1a63c1b23e Fix nits in #19480
Fixes non-blocking nits that were in the PR that consolidated some of
the machine code into common areas.

Fixes a capitalization error in documentation, inverts the logic in
`AddSSHConnectionsToPodmanSocket`, and uses raw strings in
`WaitAPIAndPrintInfo` instead of printing the messages line-by-line.

[NO NEW TESTS NEEDED]

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-08-04 09:28:20 -04:00
62a22c5d60 Run codespell on code
Also cleanup --rm=true to be just --rm

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-08-03 07:00:30 -04:00
8b7701f522 machine: QEMU: recover from failed start
After a failed start, we can run into (somehow inconsistent) states
where the machine won't start because a previous QEMU process is still
running and the PID file is being used.  Stop didn't resolve the issue
as this state wasn't detected.

Allow to recover from this state by a) detecting it during start and
error out with a more helpful message than the error QEMU would
otherwise spit out, and b) by enabling stop to kill the dangling QEMU
process - even after a failed stop.

With the changes, a recovery may look as follows:
```
_  podman git:(main) _ ./bin/darwin/podman machine start
Starting machine "podman-machine-default"
Error: cannot start VM "podman-machine-default": another instance of "/opt/homebrew/bin/qemu-system-aarch64" is already running with process ID 970: please stop and restart the VM
_  podman git:(main) _ ./bin/darwin/podman machine stop
Machine "podman-machine-default" stopped successfully
_  podman git:(main) _ ./bin/darwin/podman machine start
Starting machine "podman-machine-default"
Waiting for VM ...
```

Please note that this change does not prevent us from running into such
inconsistent states but only allows for recovering from them.

[NO NEW TESTS NEEDED] - there is no reliable reproducer.

Fixes: #16054
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-08-02 11:08:26 +02:00
21ebe0e90a Move writeConfig logic to shared function
Moves the shared logic from `writeConfig` into a shared function in
`pkg/machine/machine_common.go`

[NO NEW TESTS NEEDED]

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-08-01 21:40:14 -04:00
597ccff0bc Move some logic of setRootful to a common file
Moves most of the logic of `setRootful` to the common file
`pkg/machine/machine_common.go`.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-08-01 21:40:06 -04:00
98cf8462ad move removeFilesAndConnections to a common file
Moves `removeFilesAndConnections` to the common file
`pkg/machine/connections.go` to be reused by multiple hypervisors.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-08-01 21:13:58 -04:00
75a8f13c4a Move waitAPIAndPrintInfo to common file
Moves `waitAPIAndPrintInfo` into the common file
`pkg/machine/machine_common.go` allowing applehv and qemu to share the
code.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-08-01 21:13:58 -04:00
55c7b5ceca Move addSSHConnectionsToPodmanSocket code to shared file
Moves the implementation of `addSSHConnectionsToPodmanSocket` into the
common file `pkg/machine/machine_common.go`. The implementation was
shared between the hypervisors and does not need to be implemented
multiple times.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-08-01 21:13:52 -04:00
850482b314 Move alternate image acquisition to separate function
Moves acquisition of an alternate image provided by the user out of
`acquireVMImage` in `pkg/machine/<hypervisor>/machine.go` and into
`pkg/machine/pull.go` as its own function.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-08-01 09:53:38 -04:00
906af5bbc6 Move getDevNullFiles into a common file
Moves `getDevNullFiles` into a new common file,
`pkg/machine/machine_common.go`, preventing the re-implementation of the
function across the different hypervisor implementations.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-08-01 08:52:23 -04:00
a9948dafc9 Merge pull request #19455 from jakecorrenti/qemu-machine-funcs-to-methods
Convert new QEMU functions to methods with documentation
2023-08-01 09:43:17 +02:00
0ecda592c9 Merge pull request #19350 from jakecorrenti/breakup-applehv-machine-funcs
Breakup applehv machine funcs
2023-08-01 09:22:20 +02:00
d6847b19c8 Convert QEMU functions to methods with documentation
Converts new functions added in #19311 to methods and adds
documentation.

[NO NEW TESTS NEEDED]

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-31 15:55:47 -04:00
ff7d287fc0 Breakup AppleHV machine funcs
The functions for AppleHV's VM interface implementation (machine.go) had
quite large functions. Pulls out some code that could be moved to its
own function for easier readability and maintainability.

[NO NEW TESTS NEEDED]

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-31 10:41:18 -04:00
330e51960e Merge pull request #19364 from jakecorrenti/breakup-hyperv-machine-funcs
Breakup hyperv machine funcs
2023-07-31 16:25:03 +02:00
19deb6a346 Adds documentation to new functions that were added
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-30 19:58:03 -04:00
481143e584 startHostNetworking: get DevNull files
[NO NEW TESTS NEEDED]

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-30 18:39:45 -04:00
13da82466a Remove: remove network and ready sockets from registry
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-30 18:39:41 -04:00
d896431b28 Remove: remove files and connections
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-30 18:31:30 -04:00
32265e1f64 Remove: collect files to destroy
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-30 18:24:13 -04:00
381b103dd1 Init: read and split ign file
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-30 18:22:49 -04:00
aa6827a67a Init: write ign config
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-30 18:21:48 -04:00