Commit Graph

48 Commits

Author SHA1 Message Date
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 666d839157
golangci-lint: make windows linting happy
It qemu cannot be compiled anyway so make sure we do not try to compile
parts where the typechecker complains about on windows.
Also all the e2e test files are only used on linux as well.
pkg/machine/wsl also reports some error but to many for me to fix them
now. One minor problem was fixed in pkg/machine/machine_windows.go.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-08-19 11:41:29 +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
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
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
Brent Baude e5a4f00b7d Podman 5 machine config file - Step 1
The following PR is the very first step in what will a series of steps
to apply a "common" machine configuration file to all providers.
Function names, method names, struct names, and field names are all up
for debate.  The purpose of this PR is to offer a glimpse at the
direction we intend to take.

This PR also contains temporary structs (i.e. aThing) that are not
exported.  These are merely placeholders.

The configuration work in this PR is also unused of yet.  But the code
is compiled.  Once merged, we can begin the next step of development.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-12-11 16:26:15 -06:00
Jake Correnti 2b95700bca No longer support deprecated legacy QEMU machine structures
Removes the `MachineVMV1` and `MonitorV1` structures that have been
deprecated for a long enough period of time that it makes sense to no
longer support them.

Results in the removal of deprecated `getSocketAndPid` as well.

The migration code was added in commit
`6e0e1cbddd5e1c5dff51215ad2b41a99d890fad8` and made it into release `v4.1.0`

[NO NEW TESTS NEEDED]

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-11-21 12:04:13 -05:00
Aditya R 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
openshift-merge-bot[bot] 7dd33b307d
Merge pull request #20540 from victortoso/usb-host-passthrough
qemu: add usb host passthrough
2023-11-13 16:03:30 +00:00
Victor Toso 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
Jake Correnti 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
Brent Baude 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
Jake Correnti 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
Brent Baude 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
Jake Correnti 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
Jake Correnti 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
Ashley Cui bcfd9f3403 New machines should show Never as LastUp
After creating a podman machine, and before starting it, the LastUp value for podman machine ls should display Never. Previously, the LastUp value was the same as creation time. This also changes the LastUp value for inspect to ZeroTime instead of creation time.

Signed-off-by: Ashley Cui <acui@redhat.com>
2023-09-28 14:16:26 -04:00
Brent Baude 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
OpenShift Merge Robot bd0fe69cad
Merge pull request #19385 from jakecorrenti/breakup-qemu-config-funcs
Breakup qemu config funcs
2023-07-28 08:37:42 +02:00
Jake Correnti 3523b9b052 Break QEMU `config.go` code into its own functions
Breaks some of the code in QEMU's `VirtProvider` implementation located
at `pkg/machine/qemu/config.go` into its own functions. Aids in
improving the readability of the code.

[NO NEW TESTS NEEDED]

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-27 09:53:21 -04:00
Valentin Rothberg c341a0ffe0 machine: QEMU: lock VM on start
Lock the VM on start.  If the machine is in the "starting" state we know
that a previous start has failed and guide the user into resolving the
issue.

Concurrent starts will busy wait and return the expected "already
running" error.

NOTE: this change is only looking at the start issue (#18662).  Other
commands such as stop and update should also lock and will be updated
in a future change.  I expect the underlying issue to apply to all
machine providers, not only QEMU.  It's desirable to aim for extending
the machine interface to also allow to `Lock()` and `Unlock()`.  After
acquiring the lock, the VM should automatically be reloaded/updated.

[NO NEW TESTS NEEDED]

Fixes: #18662
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-07-27 14:16:02 +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
Brent Baude 43eb35a772 Machine refactor for QEMU/AppleHV
in preparation for adding hyper as a machine option, several common
functions needed to be moved specifically from qemu to a common area in
pkg/machine.  this usually involved functions and variables related to
using fcos as a machine image as well as its compression, artifact, and
image format.

[NO NEW TESTS NEEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-02-22 09:00:24 -06:00
Brent Baude ebb45b5bdd machine refactoring preparations for hyperv
before we can support hyperv as a virtualization option for podman
machine, several areas in machine will require cleanup.  this is the
first pass of these changes to keep the review burden low.  changes
include:

  * convert artifact, format (image format) and compression to enums
    with string methods
  * rename Provider interface to VirtProvider
  * change Provider implementation in QEMU to QEMUVirt
  * change Provider implementation in WSL to WSLVirt

as mentioned earlier, there will be several more of these refactoring
PRs because assumptions were made about associations of platforms and
virt providers as well as compression and image formats.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-02-20 13:43:49 -06:00
Arthur Sengileyev 1788b26c43 Fixes isRootfull check using qemu machine on Windows
Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
2022-08-24 18:17:18 +03:00
Shane Smith 59a7ac210b
Make `podman machine stop` wait for qemu to exit
- New `VMPidFilePath` field in MachineVM config holds the path for the
  qemu PID file

- qemu is now started with the `-pidfile` argument set to `VMPidFilePath`

- Machines created before this won't have the VM PID file configured,
  stopping these VMs will revert back to waiting on the state to change
  away from `Running`, plus an added 2s sleep to give time for the VM to
  exit and to avoid potential issues

- Machines created after this will have a VM PID file configured and
  stopping the machine will wait indefinitely for the VM to exit

[NO NEW TESTS NEEDED]

Signed-off-by: Shane Smith <shane.smith@shopify.com>
2022-06-28 13:28:38 -04:00
Brent Baude 2902d32c49 Refactor machine inspect
I was asked to refactor machine inspect output to represent more common
and basic information.  machine inspect now has information that would
be appropriate for different machines.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-04-28 13:32:21 -05:00
OpenShift Merge Robot e7c30d855f
Merge pull request #13996 from cdoern/machine
machine starting status
2022-04-26 09:08:31 -04:00
cdoern d441a711e5 machine starting status
podman machine was using the file modification time to get the running status
add three new config entries Starting (bool) Created (time) LastUp (time) to actually
keep track of when these events happened. This means we can use the config file
to actually store this data and not mess up the created/last-up time.

This fixes the issues where the machine would report running 15 seconds before it was up.
Also fixes the issue of modifying the file manually and saying the machine is "up"

[NO NEW TESTS NEEDED]

resolves #13711

Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
2022-04-25 14:14:45 -04:00
Ashley Cui 1260bf631f Revert "Switch all rootful to rootfull"
This reverts commit cc3790f332.

We can't change rootful to rootfull because `rootful` is written into the machine config. Changing this will break json unmarshalling, which will break existing machines.

[NO NEW TESTS NEEDED]

Signed-off-by: Ashley Cui <acui@redhat.com>
2022-04-25 09:14:04 -04:00
Paul Holzinger 5b4af0584d
replace golint with revive linter
golint, scopelint and interfacer are deprecated. golint is replaced by
revive. This linter is better because it will also check for our error
style: `error strings should not be capitalized or end with punctuation or a newline`

scopelint is replaced by exportloopref (already endabled)
interfacer has no replacement but I do not think this linter is
important.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-22 15:12:33 +02:00
Daniel J Walsh cc3790f332
Switch all rootful to rootfull
We are inconsistent on the name, we should stick with rootfull.

[NO NEW TESTS NEEDED] Existing tests should handle this and no tests for
machines exists yet.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-04-21 17:05:16 -04:00
Brent Baude 9c72ea3434 machine refactor 3: add symlinks for sockets
to avoid errors on macos, we use symlinks to long socket names.

Fixes: #12751
Fixes: #13609

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

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-04-05 13:14:28 -05:00
Brent Baude a06df4fc1a Machine refactor part 2
This PR further implements a more structured approach to handling the
files needed by machine.  More files are now made as MachineFile which
can then have a symlink (using a shorter path) to them.  Also added Set
and Get methods for many of the files.

The next part of the refactor will implement the use of symlinks on
MacOS.

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

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-03-30 09:22:40 -05:00
Brent Baude 6e0e1cbddd Migrate machine configs
If podman detects a Machinev1 config, it will automatically migrate it
to the new format.

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

[NO NEW TESTS NEEDED]
2022-03-28 14:54:19 -05:00
Brent Baude 2ac897aa0d Machine refactor - part 1
the way machine was written was very adjunct and as such is in dire need
of refactoring to better structures and structure methods where
appropriate.  the weekest part is specifically around all the files that
machine requires and how some are just dynamically built on the fly.

this pr defines a new machinefile type which allows us to work with the
file and also takes into account the use of symlinks which are going to
be needed on macos due to its relatively short file length restriction.

also, added unit tests for new methods as well as anywhere else I saw a
need.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-03-28 09:12:08 -05:00
Valentin Rothberg 6c030cd573 fix a number of `godot` issues
Still an unknown number remains but I am running out of patience.
Adding dots is not the best use of my time.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-22 13:04:35 +01:00
Brent Baude cdb6deb148 MacOS improvements
* Enable support of virtfs in Podman and darwin.  At the time of this writing, it requires a special patch not yet included in upstream qemu.
* Prefer to use a specially built qemu to support virtfs.  The qemu is installed under libexec/podman.

[NO NEW TESTS NEEDED]
Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-03-07 14:05:06 -06:00
Jason T. Greene c74f8f04fd Introduce podman machine init --root=t|f and podman machine set --root=t|f
Switch default to rootless for mac and windows

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-02-16 03:49:17 -06:00
Anders F Björklund a3326e23d8 Check the mount type for future compatibility
There are other mount types available, such as NFS or SMB,
or one could use reverse sshfs for better compatibility.

It could either be a global option, or it could perhaps be
overridden for each volume (like the container volumes).

Refactor the creation of the options string or array.

Allow specifying the volume as read-only, if desired.

[NO NEW TESTS NEEDED]

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
2021-12-30 13:37:34 +01:00
Anders F Björklund 8e7eeaa4dd Implement virtfs volumes for podman machine
Allow using the built-in 9pfs feature of qemu,
mounting host directories into vm mountpoints.

The volumes are generic, the mounts are specific.

Wait for the machine to be "running", otherwise
the SSH function might throw an error instead.

Increase the default msize from 8 KiB to 128 KiB

[NO NEW TESTS NEEDED]

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
2021-12-30 13:36:56 +01:00
Jason T. Greene 803defbe50 Introduce Windows WSL implementation of podman machine
[NO NEW TESTS NEEDED] for now

Signed-off-by: Jason Greene <jason.greene@redhat.com>
2021-12-24 19:28:10 -06:00
Anders F Björklund 864748df5b Record the image stream along with the path
[NO TESTS NEEDED]

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
2021-10-26 21:58:39 +02:00
Anders F Björklund 0baee2cc33 Also show the (initial) disk size
[NO TESTS NEEDED]

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
2021-09-22 17:14:16 +02:00
Maya Rashish 8d9e19b035 Spell "build linux darwin" as "build !windows".
Equivalent for supported platforms, and makes it easier to support
additional unix-like OSes.

[NO TESTS NEEDED]

Signed-off-by: Maya Rashish <maya@NetBSD.org>
2021-09-03 13:38:14 +03:00
Paul Holzinger c3a14103fb Fix build tags for pkg/machine...
Podman machine is only intended for amd64 and arm64 architectures, set
the correct buildtags so that the `pkg/machine`, `pkg/machine/qemu` and
`pkg/machine/libvirt` packages compile correctly.

[NO TESTS NEEDED]

Fixes #10625

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-06-10 10:25:16 +02:00
baude b5f54a9b23 introduce podman machine
podman machine allows podman to create, manage, and interact with a vm
running some form of linux (default is fcos).  podman is then configured
to be able to interact with the vm automatically.

while this is usable on linux, the real push is to get this working on
both current apple architectures in macos.

Ashley Cui contributed to this PR and was a great help.

[NO TESTS NEEDED]

Signed-off-by: baude <bbaude@redhat.com>
2021-03-25 08:43:51 -05:00