podman: Cannot start machine with podman version 4.1.0 in M1 Mac
/kind bug
Description
In a M1 Mac, Downloaded the VM via podman machine init
and then when trying to start it via podman machine start
I get thew following error:
Starting machine "podman-machine-default"
Waiting for VM ...
Error: dial unix /var/folders/kk/vvrx0k6x2b54wnnhc0zt6rv00000gr/T/podman/podman-machine-default_ready.sock: connect: connection refused
Tried to download the arch specific VM via podman machine init --image-path=https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/35.20220424.3.0/aarch64/fedora-coreos-35.20220424.3.0-qemu.aarch64.qcow2.xz
and starting it again with the same error.
Steps to reproduce the issue:
-
podman machine init
-
podman machine start
Describe the results you received:
Error when trying to start the machine.
Describe the results you expected:
Expected the machine to start successfully.
Additional information you deem important (e.g. issue happens only occasionally):
Output of podman version
:
Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM
Error: unable to connect to Podman. failed to create sshClient: connection to bastion host (ssh://core@localhost:56180/run/user/504/podman/podman.sock) failed: dial tcp [::1]:56180: connect: connection refused
Output of podman info --debug
:
Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM
Error: unable to connect to Podman. failed to create sshClient: connection to bastion host (ssh://core@localhost:56180/run/user/504/podman/podman.sock) failed: dial tcp [::1]:56180: connect: connection refused
Package info (e.g. output of rpm -q podman
or apt list podman
):
podman: stable 4.1.0 (bottled), HEAD
Tool for managing OCI containers and pods
https://podman.io/
/usr/local/Cellar/podman/4.1.0 (174 files, 48.2MB) *
Poured from bottle on 2022-05-19 at 17:51:55
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/podman.rb
License: Apache-2.0
==> Dependencies
Build: go ✘, go-md2man ✘
Required: qemu ✔
==> Options
--HEAD
Install HEAD version
==> Caveats
zsh completions have been installed to:
/usr/local/share/zsh/site-functions
==> Analytics
install: 20,290 (30 days), 55,705 (90 days), 143,980 (365 days)
install-on-request: 20,245 (30 days), 55,655 (90 days), 143,917 (365 days)
build-error: 0 (30 days)
Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)
Yes
Additional environment details (AWS, VirtualBox, physical, etc.):
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 18
- Comments: 60 (18 by maintainers)
In case it’s of any use, I’m finding that the max memory I’m able to set on a machine is
3072
, otherwise I see theconnection refused
error.✔️ The following works:
✖️ The following results in the
connection refused
error:I’m able to start the machine with memory greater than 3072 with the following changes to
CmdLine
in~/.config/containers/podman/machine/qemu/<name>.json
-cpu
tohost
-M
tovirt
(ie: removehighmem=off
)Tried a handful of other cpus listed by
qemu-system-aarch64 -cpu help
and of those I triedmax
also works.This workaround is verified on macOS 12.4 but does result in a crash on macOS 12.3. Have not investigated what might work on these older versions.
I really don’t know what the implications of these changes are otherwise, any
qemu
savants in the house? =)Highly recommend this solution if you are happy to throw away everything by the way… Although I do tend to do “–cpus $(sysctl -n hw.ncpu)”, to get all my CPUs in
For me the workaround by changing the memory size has no effect. I keep getting
Error: dial unix /var/folders/bh/q062sd9d5yvcjqnv/T/podman/podman-machine-default_ready.sock: connect: connection refused
I also tried to downgrade qemu to 6.2.0 Also tried to find the settings in the json but they are not thereI am on a MacBook Pro (16-inch, 2021) Apple M1 PRO
CPU setting of
cortex-a57
is wrong. It should behost
. Memory model should behimem=on
and nothighmem=off
.Podman managed machine JSON configuration file needs to be this:
Instead of this:
Sorry, but it’s not QEMU that is the problem. It is the way that Podman is instructing QEMU what both the CPU architecture model and memory availability model looks like. Both of which are incorrect.
I can confirm that after downgrading the qemu to
6.2.0
I was able to start the machine and connect to it.Note: But this is not to say that podman 4.1.0 will work correctly with qemu 6.2.0 !!!
Now, just a quick notes about how I downgraded the qemu. A great help was this article by @sandipb
My workaround is to delete the VM and start from scratch
version
I’ve tried running podman with increased memory:
podman machine init -m 3072
I’ve tried to install Qemu 6.2.0 using:
But both options did not resolve my errors.
Mac info: MacBook Pro (16-inch, 2021) Chip: Apple M1 Pro MacOS version: Monterey 12.4
Edit Okay, solved it. I had an x86 version of Homebrew installed on my Mac with a M1 chip, that caused a x86 version of Qemu to be installed. This happened because of me transferring my files from my old Mac (Intel chip) to my new one (M1 chip).
Run this bash script to migrate your Homebrew from Intel to ARM architecture: https://github.com/Homebrew/discussions/discussions/417#discussioncomment-2556937
Had the same issue with Qemu from homebrew. Downgraded to 6.2.0_1 and everything is ok. My workaround here https://github.com/Homebrew/homebrew-core/issues/102242#issuecomment-1137108389
EXCELLENT fix from Carlos Eduardo Gorges, on stackoverflow. Caused due to qemu 7.0.0 startup latency (3-5s). To fix … execute qemu, to initialize, before call “podman machine start”. Works for me … https://stackoverflow.com/questions/72404926/cant-get-podman-to-run-on-an-mac-m1-monterey
@shanesmith My hardware is an M1 Mac Mini with a mere 8GB of memory.
Total Cores:
Performance Cores:
Efficiency Cores:
It is seeming more like of an M1 Pro specific issue for some odd reason.
With just
virt
and nohimem
. Diff of ~/.config/containers/podman/machine/qemu/podman-machine-default.json:The VM starts up just fine:
Listing verifies this:
And further confirmed by connectivity:
Thanks @cpolizzi @shanesmith! I’ll open up a fix for this now.
@shanesmith legend!
editing
~/.config/containers/podman/machine/qemu/<podman machine name>.json
upon machine creation, in the way described above, made things functional for me again on MacOS 12.4 with any desired amount of memory.hope this gets addressed soon in a way which would make things work out of the box for everyone.
Hmm, maybe it looks like something changed in qemu 7.0? Taking a look…
Getting same issue. If I run in debug mode the following command is run which produces the error if run standalone:
/opt/homebrew/bin/qemu-system-aarch64 -m 27000 -smp 10 -fw_cfg name=opt/com.coreos/config,file=/Users/edwardnewman/.config/containers/podman/machine/qemu/podman-machine-default.ign -qmp unix://var/folders/tz/4n8rgr6n6wj5cgqzjx1dh0_80000gq/T/podman/qmp_podman-machine-default.sock,server=on,wait=off -netdev socket,id=vlan,fd=3 -device virtio-net-pci,netdev=vlan,mac=5a:94:ef:e4:0c:ee -device virtio-serial -chardev socket,path=/var/folders/tz/4n8rgr6n6wj5cgqzjx1dh0_80000gq/T/podman/podman-machine-default_ready.sock,server=on,wait=off,id=podman-machine-default_ready -device virtserialport,chardev=podman-machine-default_ready,name=org.fedoraproject.port.0 -accel hvf -accel tcg -cpu cortex-a57 -M virt,highmem=off -drive file=/opt/homebrew/share/qemu/edk2-aarch64-code.fd,if=pflash,format=raw,readonly=on -drive file=/Users/edwardnewman/.local/share/containers/podman/machine/qemu/podman-machine-default_ovmf_vars.fd,if=pflash,format=raw -virtfs local,path=/Users/edwardnewman,mount_tag=vol0,security_model=mapped-xattr -drive if=virtio,file=/Users/edwardnewman/.local/share/containers/podman/machine/qemu/podman-machine-default_fedora-coreos-36.20220511.dev.0-qemu.aarch64.qcow2 qemu-system-aarch64: -netdev socket,id=vlan,fd=3: can’t get socket option SO_TYPE
This is a problem with virtualizing memory in newer versions of Qemu (7.0+) on aarch64 machines. I resolved the issue by updating the
~/.config/containers/podman/machine/qemu/podman-machine-default.json
file before starting the podman machine VM. Here are the steps that worked for me:podman machine init
( with-v $HOME:$HOME
if you want to be able to mount volumes)-M
entry tovirt,highmem=off
in~/.config/containers/podman/machine/qemu/podman-machine-default.json
podman machine start
Today I had:
podman/podman-machine-default_ready.sock: connect: connection refused
What worked for me:
👋🏽 @ashley-cui and all, thanks for looking into this. I’m able to start the machine (albeit after a long time given I used 2 vCPUs, 2GB of memory and 20GB disk specs for the VM).
After some time debugging, I found the cause of this problem.
This problem is caused due to qemu 7.0.0 startup latency (3-5s) that occour in every first qemu execution after Mac Machine machine boots.
Podman has some bug that doesn’t expect that the creation of socks files, done by the qemu call, can be delayed some seconds, and when podman tries to access the socks files, the qemu is not created them yet, showing the error “Error: dial unix <TEMPDIR>/podman/podman-machine-default_ready.sock: connect: connection refused”.
To avoid this problem, just execute qemu, even with invalid options (just to initialize), before call “podman machine start”.
I hope help. Carlos Eduardo Gorges.
Please upgrade your podman to 4.1.1 and make sure your macos version is 12.4
@e-minguez worked for me with json file editing
Pointing to the source, where these defaults are defined https://github.com/containers/podman/blob/3c75c4a54cba6a1949e53c4386447120b7ddb5a9/pkg/machine/qemu/options_darwin_arm64.go#L18
@lukas-vlcek I followed the same steps to downgrade (used this article). I think your qemu will not update on the next
brew update
, because you haveqemu@6.20
installed instead ofqemu
.Also running into this, and I saw the same
qemu-system-aarch64: -netdev socket,id=vlan,fd=3: can't get socket option SO_TYPE
error message as @nycnewman. After downgrading qemu, I was able to run podman.Experiencing similar(?) issue. M1 Mac.