509 Commits

Author SHA1 Message Date
d32f61d91b vmtypes names cannot be used as machine names
florent found a bug where he used "applehv" as a machine name.  it turns out when we use a vmtype name, esp. the active type, it really messes up directory structures for configuration and images alike.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-11-17 12:24:21 -06:00
3d88f614f7 [CI:DOCS] Machine test timeout env var
Introduce MACHINE_TEST_TIMEOUT, which sets the timeout for machine tests, in seconds.

Signed-off-by: Ashley Cui <acui@redhat.com>
2023-11-15 16:00:57 -05:00
1d49773bb8 Merge pull request #20683 from baude/applehvsshkeys
Avoid empty SSH keys on applehv
2023-11-14 12:57:27 +00:00
ea89eaa1c1 Avoid empty SSH keys on applehv
[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-11-13 13:07:35 -06:00
33ddd79e26 qemu,parseUSB: minor refactor
Some comments from https://github.com/containers/podman/pull/20540

[NO NEW TESTS NEEDED]

Signed-off-by: Aditya R <arajan@redhat.com>
2023-11-13 22:35:47 +05:30
7dd33b307d Merge pull request #20540 from victortoso/usb-host-passthrough
qemu: add usb host passthrough
2023-11-13 16:03:30 +00:00
79eec47f5f Merge pull request #20626 from jakecorrenti/ignition-builder
Refactor Ignition configuration for virt providers
2023-11-09 19:54:00 +00:00
39d647a2f6 Fix socket mapping socket mapping nits
Fixes nits that were suggested in #20420. The caller of
`ListenAndWaitOnSocket` did not use the value returned by the conn
channel, therefore it was better to just close the conn in the
`ListenAndWaitOnSocket` function instead.

[NO NEW TESTS NEEDED]

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-11-09 10:41:50 -05:00
c23963d7a8 machine: qemu: add usb host passthrough
QEMU usb-host driver which is the one for passthrough, supports two
options for selecting an USB devices in the host to provide it to the
VM:
 - Bus and Device number the device is plugged
 - Vendor and Product information of the USB devices

    https://qemu-project.gitlab.io/qemu/system/devices/usb.html

This commit allows a user to configure podman machine with either of
options, with new --usb command line option for podman machine init.

Examples
  podman machine init tosovm4 --usb vendor=13d3,product=5406
  podman machine init tosovm3 --usb bus=1,devnum=4 --usb bus=1,devnum=3

This commit also allows a user to change the USBs configured with
--usb command line option for podman machine set.

Note that this commit does not handle host device permissions nor
verify that the USB devices exists.

Signed-off-by: Victor Toso <victortoso@redhat.com>
2023-11-08 23:38:53 +01:00
b2c56365b2 Refactor Ignition configuration for virt providers
Creates a common SetIgnitionFile function in pkg/machine/ignition.go which
creates the new VMFile that will represent the machine's ignition file. It
assigns the VMFile to the provided location.

Creates an IgnitionBuilder type to generate the ignition configuration for a
given virt provider.

[NO NEW TESTS NEEDED]

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-11-08 13:39:34 -05:00
78798cab00 Automatic code cleanups - JetBrains
A bunch of cleanups as suggested by linters/etc in JetBrains IDE.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-11-07 14:05:15 -06:00
a45ba06d02 Refactor key machine objects
In #20538, I was asked to consider refactoring the new OCI pull code
from within the generic machine directory.  This is something I had
tried when originally coding it but it became apparent that a much
larger refactor to prevent circular deps was needed.  Because I did not
want to pollute the initial PR with that refactor, I asked for the PR to
merge first.  This is the refactor that needed to be done.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-11-07 08:30:44 -06:00
f47a85f4ff Merge pull request #20612 from baude/applehvvirtiosfsmounts
applehv: allow virtiofs to mount to /
2023-11-07 12:13:47 +00:00
d44f71c13d applehv: allow virtiofs to mount to /
FCOS has a security limitation where new directories cannot be added to the root / directory of its filesystem.  This PR uses the work-around discussed in https://github.com/coreos/rpm-ostree/issues/337#issuecomment-1000923022 to temporarily disable the limitation, perform the mkdir, and then re-enable the limitation.

This PR allows mounts on the applehv to actually work.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-11-06 14:29:57 -06:00
715451f69b Merge pull request #20580 from RiRa12621/main
adjust string to use default machine name instead of helper path in helper message
2023-11-06 09:39:39 +00:00
375b0cc132 fix: adjust helper string in machine_common
[NO NEW TESTS NEEDED]

Signed-off-by: Rick Rackow <rick.rackow@gmail.com>
2023-11-03 21:24:05 +01:00
9e05fb14a4 fix: adjust helper string in machine_common
[NO NEW TESTS NEEDED]

Signed-off-by: Rick Rackow <rick.rackow@gmail.com>
2023-11-03 20:32:20 +01:00
5fc7585334 Merge pull request #20420 from jakecorrenti/refactor-socket-mapping
Refactor machine socket mapping
2023-11-03 18:33:54 +00:00
b5f854458d fix: adjust helper string in machine_common
[NO NEW TESTS NEEDED]

Signed-off-by: Rick Rackow <rick.rackow@gmail.com>
2023-11-03 15:42:00 +01:00
48b8b372a6 Merge pull request #20417 from baude/checkforsystemconnection
check system connections before machine init
2023-11-02 21:49:33 +00:00
613f50c7ad check system connections before machine init
we should exit early if a system connection name exists with the name of
the proposed podman machine (i.e. podman-machine-default).

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-11-02 10:31:49 -05:00
ea4775ec9e Consume OCI images for machine image
allow podman machine to extract its disk image from an oci registry or
oci-dir locally.  for now, the image must be relatively inflexible. it
must have 1 layer.  the layer must possess one image. so a dockerfile
like:

FROM scratch
COPY ./myimage.xz /myimage.xz

when using an oci dir, the directory structure must adhere to the
typical directory structure of a an oci image (with one layer).

── blobs
│   └── sha256
│       ├── 53735773573b3853bb1cae16dd21061beb416239ceb78d4ef1f2a0609f7e843b
│       ├── 80577866ec13c041693e17de61444b4696137623803c3d87f92e4f28a1f4e87b
│       └── af57637ac1ab12f833e3cfa886027cc9834a755a437d0e1cf48b5d4778af7a4e
├── index.json
└── oci-layout

in order to identify this new input, you must use a transport/schema to
differentiate from current podman machine init --image-path behavior. we
will support `oci-dir://` and `docker://` as transports.

when using the docker transport, you can only use an empty transport for
input.  for example, `podman machine init --image-path docker://`.  A
fully quailified image name will be supported in the next iteration.

the transport absent anything means, i want to pull the default fcos
image stored in a registry.  podman will determine its current version
and then look for its correlating manifest.  in this default use case,
it would look for:

quay.io/libpod/podman-machine-images:<version>

that manifest would then point to specific images that contain the
correct arch and provider disk image. i.e.

quay.io/libpod/podman-machine-images:4.6-qcow2

this PR does not enable something like
docker://quay.io/mycorp/myimage:latest yet.

names, addresses, andf schema/transports are all subject to change. the
plan is to keep this all undocumented until things firm up.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-11-02 10:23:14 -05:00
ce9c1b9b86 Refactor machine socket mapping
Refactors machine socket mapping to prevent using similar/the same code
paths. Moves the shared code to `pkg/machine/sockets.go`.

[NO NEW TESTS NEEDED]

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-11-01 23:09:17 -04:00
f6ec210f3b AppleHV: Fix machine rm error message
Fix machine not found error message on rm to be consistent with qemu.

Signed-off-by: Ashley Cui <acui@redhat.com>
2023-11-01 15:02:30 -04:00
7153124f97 Log gvproxy and server9 to file on log-level=debug
Logging to os.Stdout and os.Stderr does not seem to work in
Powershell. I am not entirely certain why.

Logfiles are the best alternative I can think of.

Signed-off-by: Matt Heon <mheon@redhat.com>
2023-10-31 10:14:06 -04:00
d9c388e2fe Change to using gopsutil for cross-OS process ops
Instead of trying to write out own code to do basic process
operations (e.g. checking if a PID is still running in a multi-OS
friendly manner), use shirou/gopsutil, a multi-platform library
that should abstract all the complexity away. Unlike our previous
approach on Windows, this one should actually work.

Signed-off-by: Matt Heon <mheon@redhat.com>
2023-10-31 10:14:06 -04:00
642fa98976 Initial addition of 9p code to Podman
This includes two new hidden commands: a 9p server,
`podman machine server9p`, and a 9p client,
`podman machine client9p` with `server9p` currently only
configured to run on Windows and serve 9p via HyperV vsock, and
`client9p` only configured to run on Linux. The server is run by
`podman machine start` and has the same lifespan as gvproxy
(waits for the gvproxy PID to die before shutting down). The
client is run inside the VM, also by `podman machine start`, and
mounts uses kernel 9p mount code to complete the mount. It's
unfortunately not possible to use mount directly without the
wrapper; we need to set up the vsock and pass it to mount as an
FD.

In theory this can be generalized so that the server can run
anywhere and over almost any transport, but I haven't done this
here as I don't think we have a usecase other than HyperV right
now.

[NO NEW TESTS NEEDED] This requires changes to Podman in the VM,
so we need to wait until a build with this lands in FCOS to test.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2023-10-31 10:14:02 -04:00
95a5ad258b Small fixes for wacko CI environments
In the unusual case where the `runtimeDir` is not already created, we
should do so on `machine init`.

When starting gvproxy from podman, we now ensure it is running (for
applehv) but waiting for the unixgram socket to appear in the filesystem
before moving on.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-10-27 10:33:39 -05:00
1850670f1e Fix typo
Signed-off-by: Alan Cha <Alan.cha1@ibm.com>
2023-10-23 23:21:55 -04:00
3661c87d3c Merge pull request #20412 from ashley-cui/lastup
hyperV: Update lastUp time
2023-10-21 18:05:48 +00:00
d6f44d956d hyperV: Update lastUp time
LastUp now correctly reports the lastUp time for podman machine on
hyperv, for both inspect and list.

Signed-off-by: Ashley Cui <acui@redhat.com>
2023-10-20 15:00:48 -04:00
64f43fed4d lint: fix warnings found by inamedparam
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-10-20 16:27:41 +02:00
9a29eb05ef Merge pull request #20400 from baude/issue20361
Fix path for omvf vars on Darwin/arm64
2023-10-18 20:07:53 +00:00
d4d76479c1 Kill gvproxy when machine rm -f
In applehv, we were not killing gvproxy when stopping via podman machine rm with force.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-10-18 12:12:23 -05:00
cad4d0ee9f Fix path for omvf vars on Darwin/arm64
On darwin arm64, we need to set the location of the ovmf vars. It should be put into the imageDir (also known as as dataDir).  But because qemu determines the image path late in Init(), the image path is set something like a stream marker.

Fixes #20361

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-10-18 10:40:08 -05:00
aa0e96e781 Merge pull request #20274 from ashley-cui/cleanup
Machine: Teardown on init failure
2023-10-13 14:22:46 +00:00
5afa949a43 Merge pull request #20322 from jakecorrenti/set-lock
Implement SetLock for all virt providers
2023-10-12 23:15:40 +00:00
cb53bcf23f Run codespell
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-10-12 12:45:44 -04:00
987dc2b8bb SetLock for all virt providers
Implements a shared `GetLock` function for virtualization providers. Returns
a pointer to a lockfile used for serializing write operations.

[NO NEW TESTS NEEDED]

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-10-12 12:06:31 -04:00
61e0b64b91 Machine: Teardown on init failure
If init fails, or if a SIGINT is sent during init, podman machine should remove all files and configs
created during the init. This includes config jsons, image files, ssh
id's, and system connections. On Windows, the VM instances are also
unregistered.

Signed-off-by: Ashley Cui <acui@redhat.com>
2023-10-12 09:26:06 -04:00
158b11a10d Merge pull request #20245 from jakecorrenti/qemu-wrapper
Create Qemu command wrapper
2023-10-05 12:38:30 +00:00
516a03a6f2 Merge pull request #20266 from n1hility/fix-resolved-disable
Adjust to path name change for resolved unit on WSL backend
2023-10-05 08:21:30 +00:00
0414f88b3a Create Qemu command wrapper
Creates a wrapper around the Qemu command line implementation to prevent
the need to hard-code the different command line options in Init and
Start.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-10-04 23:17:15 -04:00
df6a000263 Adjust to path name change for resolved unit
Leave the legacy name around for now

[NO NEW TESTS NEEDED]

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2023-10-04 17:12:03 -05:00
2a38f30b6c Revert "Fix WSL systemd detection"
This reverts commit 5b990c3835ac167cc7f5b51fae3f719edf031965.
PR #19994

Causes wsl nsenter script to infinitely loop in standard operation

[NO NEW TESTS NEEDED]

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2023-10-04 16:25:47 -05:00
e78e76c237 Merge pull request #20205 from jakecorrenti/build-applehv-intel
Build applehv for Intel Macs
2023-10-04 12:55:04 +00:00
cbca395291 Fix locale issues with WSL version detection
Since wsl --version triggers help, which triggers an error code,
use that instead of text detection.

[NO NEW TESTS NEEDED]

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2023-10-03 08:37:27 -05:00
85ed9eddef Build applehv for Intel Macs
Changes build tags to allow the applehv code to be built for Intel Macs

[NO NEW TESTS NEEDED]

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-09-29 22:42:22 -04:00
59e0919bc7 update vfkit vendored code
upstream reversed width and height and now we get an unusable gui

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-09-29 12:46:58 -05:00
cc8c28eb7c Merge pull request #20198 from jakecorrenti/remove-extra-files-line
Remove `c.ExtraFiles` line in machine
2023-09-29 06:41:02 -04:00