79 Commits

Author SHA1 Message Date
f838333b7e Merge pull request #13798 from n1hility/fix-docker-sock
Fix mac docker socket handling
2022-04-07 07:17:35 -04:00
356d534344 Fix docker socket handling
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-04-06 23:06:57 -05:00
90ac1ba2a6 Prevent set command from updating a running instance
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-04-06 20:39:59 -05:00
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
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
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
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
d106b294b4 Switch all calls to filepath.Walk to filepath.WalkDir
WalkDir should be faster the Walk, since we often do
not need to stat files.

[NO NEW TESTS NEEDED] Existing tests should find errors.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-03-27 07:18:25 -04:00
7680211ede Remove error stutter
When podman gets an error it prints out "Error: " before
printing the error string.  If the error message starts with
error, we end up with

Error: error ...

This PR Removes all of these stutters.

logrus.Error() also prints out that this is an error, so no need for the
error stutter.

[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-03-25 21:47:04 -04:00
c61b06c46c Merge pull request #13620 from Luap99/qemu-path
podman machine start: lookup qemu path again if not found
2022-03-24 18:11:45 +01:00
da58911306 fix podman machine start log level detection
Use logrus.IsLevelEnabled because this will cover all levels below it as
well. Currently this condition would fail for the trace log level.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-03-23 19:10:58 +01:00
59dc70bb42 podman machine start: lookup qemu path again if not found
We store the full path to qemu in the machine config. When the path
changes on the host the machine can longer be started. To fix it we get
the path again when we fail to start the machine due the missing binary.

We want to store and use the full path first because otherwise existing
machines can break when the qemu version changed.

[NO NEW TESTS NEEDED] We still have no machine tests.

Fixes #13394

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-03-23 19:10:51 +01:00
cdda1924a0 Explicitly use IPv4 to check if podman-machine VM is listening
When starting a VM that has been configured with volume mounts, the
podman client attempts to connect via TCP to localhost, which runs
gvproxy to proxy an ephemeral port to the VM's ssh port.  Previously,
gvproxy was listening on all interfaces and IP addresses, but this
behavior has changed to listening only on the IPv4 loopback address.

Without this change, if a newer build of gvproxy is used, a podman
machine configured with volume mounts will hang forever after "podman
machine start" with "Waiting for VM ...".

[NO NEW TESTS NEEDED]

Signed-off-by: Burt Holzman <burt@fnal.gov>
2022-03-23 12:48:17 -05:00
06dd9136a2 fix a number of errcheck issues
Numerous issues remain, especially in tests/e2e.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-22 13:15:28 +01:00
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
0f12b6fe55 linter: enable nilerr
A number of cases looked suspicious, so I marked them with `FIXME`s to
leave some breadcrumbs.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-22 13:04:35 +01:00
026bd9b205 bump golangci-lint to v1.45.0
* supports Go 1.18
* disable a number of new linters
* fix minor stylecheck issues

[NO NEW TESTS NEEDED]

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-21 10:42:53 +01:00
3c968c3d22 Handle incompatible machines
Start in a reduced mode for recovery, warn, and provide instructions to recreate them

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-03-18 01:16:34 -05:00
41e2c9943e Merge pull request #13465 from n1hility/improve-install-msg
Improve agent install message to add restart instructions
2022-03-09 09:25:57 -05:00
a7c4691bff Improve agent install message to add restart instructions
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-03-08 21:54:48 -06:00
5b51b42cc8 machine rm -f stops and removes machine
If you want to remove a running machine, you can now pass the --force/-f
to podman machine rm and the machine will be stopped and removed without
confirmations.

Fixes: #13448

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-03-08 15:47:32 -06:00
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
01514f33ba Fixes: #13301 ("machine rm removes the mounted socket file on macos")
[NO NEW TESTS NEEDED]
Signed-off-by: Thibault Gagnaux <tgagnaux@gmail.com>
2022-03-06 16:24:56 +01:00
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
8f5ba05ec4 Initial implementation of mac forwarding using a privileged docker sock claim helper
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-02-16 03:49:17 -06:00
a8928a3caa ignition: propagate proxy settings from a host into a vm
Set proxy settings (such as `HTTP_PROXY`, and others)
for the whole guest OS with setting up `DefaultEnvironment`
with a `systemd` configuration file `default-env.conf`,
a `profile.d` scenario file - `default-env.sh` and
a `environment.d` configuration file `default-env.conf`

The **actual** environment variables are read by podman
at a start, then they are encrypted with base64 into
a single string and after are provided into a VM through
QEMU Firmware Configuration (fw_cfg) Device

Inside a VM a systemd service `envset-fwcfg.service`
reads the providead encrypted string from fw_cfg, decrypts
and then adds to the files
 - `/etc/systemd/system.conf.d/default-env.conf`
 - `/etc/profile.d/default-env.sh`
 - `/etc/environment.d/default-env.conf`
At the end this service execute  `systemctl daemon-reload`
to propagate new variables for systemd manager

[NO NEW TESTS NEEDED]

Closes #13168

Signed-off-by: esendjer <esendjer@gmail.com>
2022-02-12 21:24:15 +05:00
e834297b39 Restore machine start logic that was hanging
After refactoring Stop(), mounting volumes was hanging in Start().

Restore the conditional, and add error reporting from isListening.

[NO NEW TESTS NEEDED]

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
2022-01-21 16:43:48 +01:00
bd09b7aa79 bump go module to version 4
Automated for .go files via gomove [1]:
`gomove github.com/containers/podman/v3 github.com/containers/podman/v4`

Remaining files via vgrep [2]:
`vgrep github.com/containers/podman/v3`

[1] https://github.com/KSubedi/gomove
[2] https://github.com/vrothberg/vgrep

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2022-01-18 12:47:07 +01:00
cb06133d42 Merge pull request #12835 from baude/issue12815
Wait for podman stop to complete
2022-01-13 00:34:19 +01:00
b7fe25dc28 Wait for podman stop to complete
if users run podman machine stop && podman machine ls, the status of the
machine in the subsequent ls command would running.  now we wait for
everything to complete for stop so that scripting is more accurate.

Fixes: #12815

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-01-12 14:51:25 -06:00
6e208c2226 add additional fields to podman machine ls --json
[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-01-11 16:42:56 -05:00
6630e5cf66 Make it possible to select the volume driver
Use the same type of mounts for all the machine volumes.

The default could change in the future, depending on OS.

[NO NEW TESTS NEEDED]

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
2021-12-30 13:47:16 +01:00
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
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
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
a86495ea6f Set machine timezone
Added an option to podman machine init to declare the timezone of the
resulting machine.  the default is to use the value of the host name or
else a given timezone name like America/Chicago.

Fixes: #11895

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

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2021-12-16 12:40:20 -06:00
295d87bb0b podman machine improve port forwarding
This commits adds port forwarding logic directly into podman. The
podman-machine cni plugin is no longer needed.

The following new features are supported:
 - works with cni, netavark and slirp4netns
 - ports can use the hostIP to bind instead of hard coding 0.0.0.0
 - gvproxy no longer listens on 0.0.0.0:7777 (requires a new gvproxy
   version)
 - support the udp protocol

With this we no longer need podman-machine-cni and should remove it from
the packaging. There is also a change to make sure we are backwards
compatible with old config which include this plugin.

Fixes #11528
Fixes #11728

[NO NEW TESTS NEEDED] We have no podman machine test at the moment.
Please test this manually on your system.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-11-15 15:20:47 +01:00
6e6388eac4 Make stop message more similar to start
[NO TESTS NEEDED]

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
2021-11-02 22:26:04 +01:00
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
324871d451 Merge pull request #11802 from flouthoc/podman-machine-rm-cleanup
machine: silently cleanup dangling sockets before `rm` if possible
2021-10-01 10:21:13 -04:00
642d682998 machine: silently cleanup dangling sockets before rm if possible
Try to cleanup dandling pid and machine socket if possible silently
before `rm`.

[NO TESTS NEEDED]

Signed-off-by: Aditya Rajan <arajan@redhat.com>
2021-09-30 22:38:13 +05:30
5a33b7aef8 machine: Info on successfully stopping qemu machine
Spit info log whenever we successfully stop qemu machine for ack.
Closes: https://github.com/containers/podman/issues/11542

[NO TESTS NEEDED]

Signed-off-by: Aditya Rajan <arajan@redhat.com>
2021-09-30 16:16:07 +05:30
1dba601b56 Merge pull request #11691 from afbjorklund/machine-list
Add more information about the VM to podman machine list
2021-09-22 18:47:48 -04:00
f342784ce5 Merge pull request #11701 from ashley-cui/stream
Fix machine image
2021-09-22 18:44:47 -04:00
1c4e6d8624 standardize logrus messages to upper case
Remove ERROR: Error stutter from logrus messages also.

[ NO TESTS NEEDED] This is just code cleanup.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-09-22 15:29:34 -04:00
f5f95d722f Fix machine image
Make sure setting machine image to `testing` pulls down the testing
stream, and not the next stream

Signed-off-by: Ashley Cui <acui@redhat.com>
2021-09-22 14:38:24 -04:00
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
911298252a Show cpus and memory in machine list
[NO TESTS NEEDED]

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
2021-09-22 17:14:07 +02:00
072b061b4e Search gvproxy with config.FindHelperBinary()
Closes #11531

[NO TESTS NEEDED]

Signed-off-by: Hyeon Kim <simnalamburt@gmail.com>
2021-09-14 17:14:55 +09:00
f07a2bfbec Merge pull request #11440 from ashley-cui/ssh
Use default username for podman machine ssh
2021-09-13 14:34:29 -04:00