Commit Graph

29 Commits

Author SHA1 Message Date
Jake Correnti 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
Jake Correnti 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
OpenShift Merge Robot 330e51960e
Merge pull request #19364 from jakecorrenti/breakup-hyperv-machine-funcs
Breakup hyperv machine funcs
2023-07-31 16:25:03 +02:00
Jake Correnti 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
Jake Correnti 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
Jake Correnti 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
Jake Correnti d896431b28 `Remove`: remove files and connections
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-30 18:31:30 -04:00
Jake Correnti 32265e1f64 `Remove`: collect files to destroy
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-30 18:24:13 -04:00
Jake Correnti 381b103dd1 `Init`: read and split ign file
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-30 18:22:49 -04:00
Jake Correnti aa6827a67a `Init`: write ign config
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-30 18:21:48 -04:00
Jake Correnti cc30639d7b `Init`: add network and registry socks to registry
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-30 18:19:34 -04:00
Jake Correnti 78d3b549cd `Init`: add SSH conns to podman sock
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-30 18:16:32 -04:00
Jake Correnti 837bc25681 Fix HyperV loadMachineFromJSON function name
Re-names HyperV function that was copied from the applehv
implementation and not changed. Makes the function a method of
`HyperVMachine`.

[NO NEW TESTS NEEDED]

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-28 11:14:13 -04:00
Valentin Rothberg 9fb2f8e100 podman machine start: fix ready service
When debugging #17403, the logs of sshd indicates that Podman tried to
ssh into the machine too soon as the `core` user has not yet been fully
set up:

 > error: kex_exchange_identification: Connection closed by remote host
 > fatal: Access denied for user core by PAM account configuration [preauth]

@dustymabe found that the we may have to wait for systemd-user sessions
to be up.  Doing that reduces the flake rate on my M2 machine but does
not entirely fix the issue.

Since I have seen multiple symptoms of flakiness, I think it does not
hurt to add the systemd-user sessions to the dependencies of the ready
service and continue investigating.

[NO NEW TESTS NEEDED] - once we have a fix out, I want to exercise
frequent stop/start in the machine tests but they won't pass now.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-06-30 10:50:30 +02:00
Jake Correnti 516034215f Re-organize hypervisor implementations
Ensures that for each hypervisor implementation, their `config.go` file
deals with implementing the `VirtProvider` interface while the
`machine.go` file is for implementing the `VM` interface.

Moves the `Virtualization` type into a common file and
created wrappers for the individual hypervisors. Allows for shared
functions that are exactly the same while providing the flexibility to
create hypervisor-specific implementations of the functions.

[NO NEW TESTS NEEDED]

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-06-23 11:33:19 -04:00
Black-Hole1 c7a8d29f12
refactor: improve get ssh path duplicate code
Signed-off-by: Black-Hole1 <bh@bugs.cc>
2023-06-07 09:03:35 +08:00
Paul Holzinger ce07860a1c
machine: fix default connection URL to use 127.0.0.1
gvproxy listens on 127.0.0.1, using localhost as hostname can result in
the client trying to connect to the ipv6 localhost (`::1`). This will
fail as shown in the issue. This switches the hostname in the system
connection to 127.0.0.1 to fix this problem.
I switched the qemu, hyperV and WSL backend. I haven't touched the
applehv code because it uses two different ips and I am not sure what is
the correct thing there. I leave this to Brent to figure out.

[NO NEW TESTS NEEDED]

[1] https://github.com/containers/gvisor-tap-vsock/blob/main/cmd/gvproxy/main.go#L197-L199

Fixes #16470

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-16 10:55:31 +02:00
Jason T. Greene 5a176f09c2 Set machine docker.sock according to rootful flag
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2023-05-14 23:56:15 -05:00
OpenShift Merge Robot cf29dad400
Merge pull request #18402 from baude/applehvpass1
MVP for Podman Machine with AppleHV
2023-05-03 10:17:51 -04:00
Brent Baude dc7515dc32 MVP for Podman Machine with AppleHV
this pr is the first pass at enabling podman machine to use the apple hypervisor. there are still several TODO
areas like host networking.  once the decision is handled on what host networking should look like, these TODOs
should be fairly quick to resolve.  they also will impact the remove methods.

you must also have vfkit (https://github.com/crc-org/vfkit)

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

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-05-02 13:09:56 -05:00
Paul Holzinger 64959b744f
pkg/machine: rework RemoveConnection()
It really does not make sense to call RemoveConnection() twice and then
update the config file a third time in updateDefaultMachineinConfig().
This results in unnecessary reads/writes and more code.

Simplyfy this into one function that is only called once and do all
updates at once.

[NO NEW TESTS NEEDED]

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-04-26 16:57:22 +02:00
Brent Baude 8019dc9e60 hyperv: add podman socket mapping
on machine start, create a socket representing the machine's podman
service socket so local (to the host) applications can take advanatge of
it.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-04-19 16:41:34 -05:00
Brent Baude 4b8230119e HyperV: wait on stop
When using podman machine with hyperv, stop was releasing the terminal
back top the user prematurely.  This resulted in users being able to run
subsequent commands while the vm was still stopped.  Commands like
machine stop were prone to failing.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-04-18 08:02:48 -05:00
Brent Baude 3222545ad5 Enabled network over vsock
podman machine with Microsoft HyperV will use hvsock on the guest and
vsock on the guest for its networking.  this pr enables the basics for
this to happen as well as changes to ignition to automatically set this
up with network manager.

the vm binary referenced in this pr is in containers/gvisor-tap-vsock
and will need to be added to distributions.

[NO NEW TESTS NEEDED]
Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-04-17 12:34:37 -05:00
Brent Baude f488d9890c Add support for HVSOCK on hyperv
Windows HyperV uses HVSocks (Windows adaptation of vsock) for
communicating between vms and the host.  Podman machine in Qemu uses a
virtual UDS to signal the host that the machine is booted.  In HyperV,
we can use a HVSOCK for the same purpose.

One of the big aspects of using HVSOCK on Windows is that the HVSOCK
must be entered into the Windows registry.  So now part of init and rm
of a podman machine, entries must be added and removed respectively.
Also duplicates are a no-no.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-04-14 13:53:25 -05:00
OpenShift Merge Robot ac2efdb862
Merge pull request #17949 from baude/hypervset
implement podman machine set for hyperv
2023-03-28 17:41:40 +02:00
Brent Baude 51d068ecc7 implement podman machine set for hyperv
add the ability to set cpu and processor counts on an existing vm.

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

[NO NEW TESTS NEEDED]
2023-03-27 16:11:24 -05:00
Brent Baude 518eafaa34 hyperv: lookup machine on local filesystem first
when looking for a machine, look it up locally first to prevent
accidental collision with non-podman machine vms.  in the cast of
`podman machine ls`, only list podman machines found by json files

Enabled remove with force.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-03-27 10:17:06 -05:00
Brent Baude 0dac214f56 basic hypverv machine implementation
with libhvee, we are able to do the basics of podman machine management
on hyperv.  The basic functions like init, rm, stop, and start are all
functional.  Start and stop will periodically throw a benign error
processing the hyperv message being returned from the action.  The error
is described in the todo's below.

notable items:

* no podman commands will work (like ps, images, etc)
* the machine must be initialized with --image-path and fed a custom image.
* disk size is set to 100GB statically.
* the vm joins the default hyperv network which is TCP/IP network based.
* podman machine ssh does not work
* podman machine set does not work
* you can grab the ip address from hyperv and fake a machine connection
  with `podman system connection`.
* when booting, use the hyperv console to know the boot is complete.

TODOs:
* podman machine ssh
* podman machine set
* podman machine rm needs force bool
* disk size in NewMachine is set to 100GB
* podman start needs to wait until fully booted
* establish a boot complete signal from guest
* implement gvproxy like user networking
* fix benign failures in stop/start -> Error: error 2147749890 (FormatMessage failed with: The system cannot find message text for message number 0x%1 in the message file for %2.)

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-03-17 16:02:28 -05:00