Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot start machine with podman version 4.1.0 in M1 Mac #14303

Closed
Charizard opened this issue May 20, 2022 · 60 comments · Fixed by #14563
Closed

Cannot start machine with podman version 4.1.0 in M1 Mac #14303

Charizard opened this issue May 20, 2022 · 60 comments · Fixed by #14563
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. machine

Comments

@Charizard
Copy link

/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:

  1. podman machine init

  2. 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.):

@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label May 20, 2022
@phenri00
Copy link

Experiencing similar(?) issue. M1 Mac.

a@M1-Air ~ $ podman machine start
Starting machine "podman-machine-default"
Waiting for VM ...
Error: dial unix /var/folders/1d/ts5cfq0d5sqfx5h9k7vkh2000000gn/T/podman/podman-machine-default_ready.sock: connect: connection refused

a@M1-Air ~ $ podman info --debug
Cannot connect to Podman....
a@M1-Air ~ $ brew info podman
podman: stable 4.1.0 (bottled), HEAD
Tool for managing OCI containers and pods
https://podman.io/
/usr/local/Cellar/podman/HEAD-948c5e9 (174 files, 47.8MB) *
  Built from source on 2022-05-19 at 14:15:13
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

@nycnewman
Copy link

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

@nycnewman
Copy link

Note that it is not possible on MacOS to downgrade to previous podman version as the tap appears to only understand 4.1.0. Was proposing to test to see if that still works as issue appears to be with qemu.

@Luap99 Luap99 added the machine label May 23, 2022
@mheon
Copy link
Member

mheon commented May 23, 2022

@baude @ashley-cui PTAL

@ktram
Copy link

ktram commented May 25, 2022

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.

@lukas-vlcek
Copy link

I am running into the same issue.
@ktram Would you mind sharing your steps to downgrade qemu? I installed it using brew and it seems that downgrading packages in brew is full of magic.

@ashley-cui
Copy link
Member

Hmm, maybe it looks like something changed in qemu 7.0? Taking a look...

@lukas-vlcek
Copy link

I can confirm that after downgrading the qemu to 6.2.0 I was able to start the machine and connect to it.

# =========================
# Versions

% podman --version
podman version 4.1.0

% qemu-system-aarch64 --version
QEMU emulator version 6.2.0

# =========================
# My VMs

% podman machine list           
NAME                     VM TYPE     CREATED      LAST UP      CPUS        MEMORY      DISK SIZE
opensearch               qemu        3 hours ago  3 hours ago  4           34.36GB     107.4GB
podman-machine-default*  qemu        3 hours ago  3 hours ago  1           2.147GB     10.74GB

# =========================
# Starting the machine

% podman machine start opensearch
Starting machine "opensearch"
Waiting for VM ...
Mounting volume... /Users/lukas.vlcek:/Users/lukas.vlcek

This machine is currently configured in rootless mode. If your containers
require root permissions (e.g. ports < 1024), or if you run into compatibility
issues with non-podman clients, you can switch using the following command: 

	podman machine set --rootful opensearch

API forwarding listening on: /Users/lukas.vlcek/.local/share/containers/podman/machine/opensearch/podman.sock

The system helper service is not installed; the default Docker API socket
address can\'t be used by podman. If you would like to install it run the
following commands:

	sudo /opt/homebrew/Cellar/podman/4.1.0/bin/podman-mac-helper install
	podman machine stop opensearch; podman machine start opensearch

You can still connect Docker API clients by setting DOCKER_HOST using the
following command in your terminal session:

	export DOCKER_HOST='unix:///Users/lukas.vlcek/.local/share/containers/podman/machine/opensearch/podman.sock'

Machine "opensearch" started successfully

# =========================
# And finally, SSH into the machine

% podman machine ssh opensearch
Connecting to vm opensearch. To close connection, use `~.` or `exit`
Warning: Permanently added '[localhost]:56046' (ED25519) to the list of known hosts.
Fedora CoreOS 36.20220511.dev.0
Tracker: https://github.com/coreos/fedora-coreos-tracker
Discuss: https://discussion.fedoraproject.org/tag/coreos

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

# At this point I already have podman 4.1.0 installed with qemu 7.0.0

% brew tap-new lukas/local-qemu
% brew extract --version=6.2.0 qemu lukas/local-qemu
% brew uninstall --ignore-dependencies qemu
% brew install lukas/local-qemu/[email protected]

# Done.
# Notice that I did not use the HOMEBREW_NO_AUTO_UPDATE=1 parameter (see the article)
# so the qemu will probably be updated with the next `brew update` command...

@ktram
Copy link

ktram commented May 25, 2022

@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 have [email protected] installed instead of qemu.

@shanesmith
Copy link
Contributor

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 the connection refused error.

✔️ The following works:

podman machine init # default memory is 2048
podman machine start
podman machine init -m 3072
podman machine start
podman machine init
podman machine set -m 3072
podman machine start

✖️ The following results in the connection refused error:

podman machine init -m 3073
podman machine start
podman machine init -m 4096
podman machine start
podman machine init
podman machine set -m 4096
podman machine start

@justin-f-perez
Copy link

justin-f-perez commented May 25, 2022

I am also experiencing this issue on an M1 mac running MacOS 12.4 (21F79) with podman 4.1.0 and qemu 7.0.0 (with qemu being installed automatically by homebrew as a dependency of podman). The comment from @shanesmith allowed me to initialize and start a podman machine but I still receive connection failures if I attempt to actually run anything.

🔧 pm-clean util function

I ran this before each of the below tests

pm-clean() { podman machine ls -q | sed 's/\*$//' | xargs -L1 podman machine rm --force 2>/dev/null; podman machine ls --noheading; }

podman machine init --cpus=4 --disk-size=20 --memory=3072 --timezone=local --rootful=false --now

Confirming @shanesmith comment, rootless works with memory <= 3072

I can initialize and start the machine, but can't actually connect to it.

$ podman machine init \
                --cpus=4 \
                --disk-size=20 \
                --memory=3072 \
                --timezone=local \
                --rootful=false \
                --now

Extracting compressed file
Image resized.
Machine init complete
Waiting for VM ...
Mounting volume... /Users/podman-rootless-user:/Users/podman-rootless-user
Error: exit status 255

$ podman machine ls
NAME                     VM TYPE     CREATED        LAST UP            CPUS        MEMORY      DISK SIZE
podman-machine-default*  qemu        3 minutes ago  Currently running  4           3.221GB     21.47GB

$ podman run ubuntu /bin/bash
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:64227/run/user/1117123858/podman/podman.sock) failed: ssh: handshake failed: ssh: disconnect, reason 2: Too many authentication failures

$ ll ~/.ssh/podman-machine-default 
Permissions Size User    Date Modified Name
.rw-------   411 podman-rootless-user 25 May 17:34  /Users/podman-rootless-user/.ssh/podman-machine-default

$ podman machine ssh
Connecting to vm podman-machine-default. To close connection, use `~.` or `exit`
Warning: Permanently added '[localhost]:64227' (ED25519) to the list of known hosts.
Received disconnect from ::1 port 64227:2: Too many authentication failures
Disconnected from ::1 port 64227
Error: exit status 255

podman machine init --cpus=4 --disk-size=20 --memory=3072 --timezone=local --rootful=true --now --log-level=trace

So does rootful (but only with memory <= 3072)

Same result as attempting rootless above

podman machine init --cpus=4 --disk-size=20 --memory=4096 --timezone=local --rootful=true --now --log-level=trace

time="2022-05-25T15:12:10-05:00" level=info msg="podman filtering at log level trace"
Extracting compressed file
time="2022-05-25T15:12:28-05:00" level=trace msg="Reading configuration file \"/Users/podman-rootful-user/.config/containers/containers.conf\""
time="2022-05-25T15:12:28-05:00" level=trace msg="Reading configuration file \"/Users/podman-rootful-user/.config/containers/containers.conf\""
Image resized.
Machine init complete
time="2022-05-25T15:12:28-05:00" level=debug msg="[/opt/homebrew/bin/qemu-system-aarch64 -m 4096 -smp 4 -fw_cfg name=opt/com.coreos/config,file=/Users/podman-rootful-user/.config/containers/podman/machine/qemu/podman-machine-default.ign -qmp unix://var/folders/8_/_z_4l9jx6214q4ztktdvhg3d19bx8k/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/8_/_z_4l9jx6214q4ztktdvhg3d19bx8k/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/podman-rootful-user/.local/share/containers/podman/machine/qemu/podman-machine-default_ovmf_vars.fd,if=pflash,format=raw -virtfs local,path=/Users/podman-rootful-user,mount_tag=vol0,security_model=mapped-xattr -drive if=virtio,file=/Users/podman-rootful-user/.local/share/containers/podman/machine/qemu/podman-machine-default_fedora-coreos-36.20220511.dev.0-qemu.aarch64.qcow2]"
Waiting for VM ...
Error: dial unix /var/folders/8_/_z_4l9jx6214q4ztktdvhg3d19bx8k/T/podman/podman-machine-default_ready.sock: connect: connection refused

podman machine init --cpus=4 --disk-size=20 --memory=4096 --timezone=local --rootful=false --now --log-level=trace

time="2022-05-25T15:01:24-05:00" level=info msg="podman filtering at log level trace"
Extracting compressed file
time="2022-05-25T15:01:42-05:00" level=trace msg="Reading configuration file \"/Users/podman-rootless-user/.config/containers/containers.conf\""
time="2022-05-25T15:01:42-05:00" level=trace msg="Reading configuration file \"/Users/podman-rootless-user/.config/containers/containers.conf\""
Image resized.
Machine init complete
time="2022-05-25T15:01:42-05:00" level=debug msg="[/opt/homebrew/bin/qemu-system-aarch64 -m 4096 -smp 4 -fw_cfg name=opt/com.coreos/config,file=/Users/podman-rootless-user/.config/containers/podman/machine/qemu/podman-machine-default.ign -qmp unix://var/folders/8_/_z_4l9jx6214q4ztktdvhg3d19bx8k/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/8_/_z_4l9jx6214q4ztktdvhg3d19bx8k/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/podman-rootless-user/.local/share/containers/podman/machine/qemu/podman-machine-default_ovmf_vars.fd,if=pflash,format=raw -virtfs local,path=/Users/podman-rootless-user,mount_tag=vol0,security_model=mapped-xattr -drive if=virtio,file=/Users/podman-rootless-user/.local/share/containers/podman/machine/qemu/podman-machine-default_fedora-coreos-36.20220511.dev.0-qemu.aarch64.qcow2]"
Waiting for VM ...
Error: dial unix /var/folders/8_/_z_4l9jx6214q4ztktdvhg3d19bx8k/T/podman/podman-machine-default_ready.sock: connect: connection refused

@shanesmith
Copy link
Contributor

@justin-f-perez It's probably a different issue, but I've found that the --now flag for podman machine init can be unreliable. If I can't connect to a machine after using --now I can fix it however by stopping it then starting it again.

For this issue, perhaps you could avoid --now and instead manually run a start after the init?

@justin-f-perez
Copy link

justin-f-perez commented May 26, 2022

@shanesmith Thanks for the suggestion! It doesn't seem to matter how I initialize the machine, I get the same meaningless error 😮‍💨

$ podman machine stop && podman machine rm --force && podman machine init && podman machine start --log-level=trace
INFO[0000] podman filtering at log level trace
DEBU[0000] [/opt/homebrew/bin/qemu-system-aarch64 -m 2048 -smp 1 -fw_cfg name=opt/com.coreos/config,file=/Users/podman-is-so-broken/.config/containers/podman/machine/qemu/podman-machine-default.ign -qmp unix://var/folders/8_/_z_4l9jx6214q4ztktdvhg3d19bx8k/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/8_/_z_4l9jx6214q4ztktdvhg3d19bx8k/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/podman-is-so-broken/.local/share/containers/podman/machine/qemu/podman-machine-default_ovmf_vars.fd,if=pflash,format=raw -virtfs local,path=/Users/podman-is-so-broken,mount_tag=vol0,security_model=mapped-xattr -drive if=virtio,file=/Users/podman-is-so-broken/.local/share/containers/podman/machine/qemu/podman-machine-default_fedora-coreos-36.20220511.dev.0-qemu.aarch64.qcow2]
Starting machine "podman-machine-default"
DEBU[0000] [/opt/homebrew/bin/qemu-system-aarch64 -m 2048 -smp 1 -fw_cfg name=opt/com.coreos/config,file=/Users/podman-is-so-broken/.config/containers/podman/machine/qemu/podman-machine-default.ign -qmp unix://var/folders/8_/_z_4l9jx6214q4ztktdvhg3d19bx8k/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/8_/_z_4l9jx6214q4ztktdvhg3d19bx8k/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/podman-is-so-broken/.local/share/containers/podman/machine/qemu/podman-machine-default_ovmf_vars.fd,if=pflash,format=raw -virtfs local,path=/Users/podman-is-so-broken,mount_tag=vol0,security_model=mapped-xattr -drive if=virtio,file=/Users/podman-is-so-broken/.local/share/containers/podman/machine/qemu/podman-machine-default_fedora-coreos-36.20220511.dev.0-qemu.aarch64.qcow2]
Waiting for VM ...
Mounting volume... /Users/podman-is-so-broken:/Users/podman-is-so-broken
DEBU[0013] Executing: ssh [-i /Users/podman-is-so-broken/.ssh/podman-machine-default -p 62930 core@localhost -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -q -- sudo chattr -i / ; sudo mkdir -p /Users/podman-is-so-broken ; sudo chattr +i / ;]
Error: exit status 255

$ echo $?
125

@ktram
Copy link

ktram commented May 26, 2022

@justin-f-perez I don't know if this will help you, but I used the information at the bottom of this to configure podman and minikube on my M1. I've been initializing with

podman machine init --cpus 6 --memory 12288 --disk-size 50 --image-path next

@ashley-cui
Copy link
Member

Hmm, after removing all my VM images and downloading the default, I'm able to reproduce, but before that I was not able to do so. Both times were QEMU 7.0.0, podman 4.1. Taking a further look, but if you know what VM image you're using, let me know.

@justin-f-perez
Copy link

justin-f-perez commented May 26, 2022

@ashley-cui what command should be run to see what VM image is being used?

@ktram many thanks for the suggestion, but this causes the same error as described in the initial issue description. I also tried just using just --image-path next. Finally, since the error occurs right after the message about mounting, I attempted to tell podman machine init not to mount any volumes by passing -v ':', which led to the same error as the initial issue description

podman machine stop && podman machine rm --force && podman machine init --memory 12288 --cpus 6 --disk-size=50 --image-path next && podman machine start

Extracting compressed file
Image resized.
Machine init complete
To start your machine run:

	podman machine start

Starting machine "podman-machine-default"
Waiting for VM ...
Error: dial unix /var/folders/8_/_z_4l9jx6214q4ztktdvhg3d19bx8k/T/podman/podman-machine-default_ready.sock: connect: connection refused

podman machine stop && podman machine rm --force && podman machine init --image-path next && podman machine start

Machine "podman-machine-default" stopped successfully
Extracting compressed file
Image resized.
Machine init complete
To start your machine run:

	podman machine start

Starting machine "podman-machine-default"
Waiting for VM ...
Mounting volume... /Users/jfperez:/Users/jfperez
Error: exit status 255

podman machine stop && podman machine rm --force && podman machine init --image-path next -v ':' && podman machine start

Machine "podman-machine-default" stopped successfully
Extracting compressed file
Image resized.
Machine init complete
To start your machine run:

	podman machine start

Starting machine "podman-machine-default"
Waiting for VM ...
Error: dial unix /var/folders/8_/_z_4l9jx6214q4ztktdvhg3d19bx8k/T/podman/podman-machine-default_ready.sock: connect: connection refused

@ashley-cui
Copy link
Member

@justin-f-perez podman machine inspect

@justin-f-perez
Copy link

@ashley-cui

[
     {
          "ConfigPath": {
               "Path": "/Users/me/.config/containers/podman/machine/qemu/podman-machine-default.json"
          },
          "Created": "2022-05-26T15:06:54.843899-05:00",
          "Image": {
               "IgnitionFilePath": {
                    "Path": "/Users/me/.config/containers/podman/machine/qemu/podman-machine-default.ign"
               },
               "ImageStream": "next",
               "ImagePath": {
                    "Path": "/Users/me/.local/share/containers/podman/machine/qemu/podman-machine-default_fedora-coreos-36.20220511.dev.0-qemu.aarch64.qcow2"
               }
          },
          "LastUp": "0001-01-01T00:00:00Z",
          "Name": "podman-machine-default",
          "Resources": {
               "CPUs": 1,
               "DiskSize": 100,
               "Memory": 2048
          },
          "SSHConfig": {
               "IdentityPath": "/Users/me/.ssh/podman-machine-default",
               "Port": 51642,
               "RemoteUsername": "core"
          },
          "State": ""
     }
]

@raycardillo
Copy link

raycardillo commented May 27, 2022

Just ran into this myself as well. On an M1 Macbook Pro. Ended up being the memory limit for me. All I did that caused this was:

  • typical brew install (4.1.0) + typical default podman machine init/start
  • realized I needed more memory so I rm the initial machine
  • created a new machine with -m 4096
  • pain, pain, pain (Cannot connect to Podman - failed to create sshClient)

After reading through this issue:

  • rm the machine again
  • recreated the machine with -m 3072 instead
  • up and running again (but not with the memory config I wanted)

@cpolizzi
Copy link

I can also confirm that I have the same issue.

@justin-f-perez
Copy link

justin-f-perez commented May 30, 2022

I figured out how to downgrade to 4.0.3 (which is working as expected) and wrote a little helper script

note: I uninstalled 4.1.0 first, but unsure whether that's necessary

#!/bin/zsh
# shellcheck shell=bash
#
# This script creates a homebrew tap for an old version of podman.
# If no version is provided as the first argument, a list of
# versions is either presented for selection via fzf (if installed)
# or printed to stdout.
set -euo pipefail

list_versions() {
  cd "$(brew tap-info homebrew/core | grep '^/' | cut -d' ' -f1)"
  git log -p -G 'url.*podman' -- 'Formula/podman.rb' |
    grep -e "-.*url.*https://github.com/containers/podman/archive/v.*.tar.gz" | sed 's/^.*v\([0-9.]*\)\.tar.gz.*/\1/'
}

create_tap() {
  version="$1"
  brew tap-new "$USER/local-podman" ||:
  brew extract --version="${version}" podman "$USER/local-podman"
}

version="${1:-}"
if [[ -z "${version}" ]]; then
  if command -v fzf; then
    echo "Listing versions (this may take a minute)" && sleep 2
    version="$(list_versions | fzf)"
  else
    echo "Usage: ./poldman.zsh <VERSION>"
    echo "Example:"
    echo "$0 4.0.3"
    echo "Listing versions (this may take a minute)"
    list_versions
  fi
fi


podman machine stop ||:
create_tap "${version}"
brew install "podman@${version}"
brew link "podman@${version}"

Hope this helps!

@arixmkii
Copy link
Contributor

Had the same issue with Qemu from homebrew. Downgraded to 6.2.0_1 and everything is ok. My workaround here Homebrew/homebrew-core#102242 (comment)

@shanesmith
Copy link
Contributor

Potentially related: https://gitlab.com/qemu-project/qemu/-/issues/903

@justin-f-perez
Copy link

justin-f-perez commented May 30, 2022

I realized today that downgrading to [email protected] resolved the other problems I seem to be having that others aren't, but the memory limit issue persists. Notably, I get the following error with Qemu 7.0 and podman 4.0.3:

qemu-system-aarch64: Addressing limited to 32 bits, but memory exceeds it by <NUMBER> bytes

Error: dial unix ... connect: connection refused

It's not clear why podman 4.1.0 seems to supress the Addressing limited to... error message even when log level is set to maximum verbosity but may be related to highmem parameter - the (currently) last comment in the issue @shanesmith linked saw similar mount errors similar to mine when highmem=on and 'Addressing limited' errors when highmem=off

@shanesmith
Copy link
Contributor

shanesmith commented May 30, 2022

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

  • Set -cpu to host
  • Set -M to virt (ie: remove highmem=off)

Tried a handful of other cpus listed by qemu-system-aarch64 -cpu help and of those I tried max 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? =)

@JeroenSchrader
Copy link

JeroenSchrader commented Jun 3, 2022

I've tried running podman with increased memory: podman machine init -m 3072

I've tried to install Qemu 6.2.0 using:

curl -L -H "Authorization: Bearer QQ==" -o qemu-6.2.0_1.monterey.bottle.tar.gz https://ghcr.io/v2/homebrew/core/qemu/blobs/sha256:fcc3b1a8139f70dae57f5449f3856f9b3b67448ee0623e64da1e47dc255b46f6
brew install -f qemu-6.2.0_1.monterey.bottle.tar.gz

But both options did not resolve my errors.

➜  ~ podman machine start
Starting machine "podman-machine-default"
Waiting for VM ...
Error: dial unix /var/folders/l6/8c2s86493qx2w60cj0g846r00000gp/T/podman/podman-machine-default_ready.sock: connect: connection refused
 ~ podman info
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:50159/run/user/502/podman/podman.sock) failed: dial tcp 127.0.0.1:50159: connect: connection refused

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: Homebrew/discussions#417 (comment)

@cpolizzi
Copy link

@shanesmith I have an individual from my customer whom has a 16-inch 2021 Apple M1 Max MacBook Pro on MacOS 12.3.1. He stated that once he made the change discussed here to the QEMU JSON configuration file and started the managed machine caused his MacBook to crash. He said it happened twice.

@tideman
Copy link

tideman commented Jun 15, 2022

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 there

I am on a MacBook Pro (16-inch, 2021) Apple M1 PRO

@cpolizzi
Copy link

@tideman The CPU model has to be changed as well from -cpu cortex-a57 to -cpu host as well as the memory model via the machine type. Machine type is specified via -M and is shorthand for -machine. The machine type remains as virt but the machine backend driver for memory access (highmem=off) needs to either be omitted entirely or specified as being enabled as highmem=on. highmem=on is the default.

Perhaps open a new GitHub issue so that you can provide your specific output and configuration?

@nycnewman
Copy link

@cpolizzi Just an observation. I was experiencing the same issue as @tideman . However it feels like there are two different issues in flight. One is the cpu/highmem issue which you have provided a resolution. The second appears to be related to some process that the podman CLI talks to whilst performing operations. I was getting the same "connection refused" error even for podman commands (podman machine list, podman machine rm, podman ps, etc). Not sure when or how the podman macos helper gets involved but it feels like some other process that podman CLI connects to is failing to start and thus socket is not available. Not sure what I did but eventually this was resolved to me but some combination of reinstalling podman/qemu and /or reinstalling helper.

@cpolizzi
Copy link

@nycnewman I agree with you that these seem to be two different issues. I have experienced this as @tideman mentioned, albeit extremely rarely. It is why I suggested creating a new issue for it. If I recall correctly I resolved it by wiping the temporary directory. So in the output that @tideman shared I would have done:

sudo /var/folders/bh/q062sd9d5yvcjqnv/T/podman*

But, I could be wrong as well. One evening everything was working for this issue and the next day it no longer worked and I received the same results as we are now discussing. It is worth IMHO to open a new issue for this behavior and see what comes.

@wkoszek
Copy link

wkoszek commented Jun 20, 2022

I'm experiencing what I believe is the same issue. I'm on:

  • latest brew upgrade as of 2022-Jun-19
  • MacOS Monterey 12.3.1 (21E258) with all updates except XCode
  • podman version 3.4.1

podman machine init never moves past Waiting for VM which I need to terminate with CTRL+C. Any workarounds are welcome.

Snippet below:

% podman machine start
INFO[0000] waiting for clients...
INFO[0000] listening tcp://0.0.0.0:7777
INFO[0000] new connection from  to /var/folders/c5/ctj1sbjn7gsc2qknql4csdb40000gn/T/podman/qemu_podman-machine-default.sock
Waiting for VM ...
^C
qemu-system-aarch64: terminating on signal 2 from pid 733 (<unknown process>)
% ERRO[0226] cannot receive packets from , disconnecting: cannot read size from socket: EOF
ERRO[0226] signal caught

@rhatdan
Copy link
Member

rhatdan commented Jun 21, 2022

Upgrade the host to 12.4.

@ashley-cui
Copy link
Member

Please upgrade your podman to 4.1.1 and make sure your macos version is 12.4

@carlosgorges
Copy link

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 /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".

            echo "* Podman VM machine for MACOSX is stoped, starting..."
            
            # workaround - initialize qemu before machine start to avoid socket error
            /usr/local/bin/qemu-system-x86_64 -machine q35,accel=hvf:tcg -cpu host -display none INVALID_OPTION >> /dev/null 2>&1

            podman machine start podman-machine-default
            ECODE=$?;if [ $ECODE -ne 0 ];then echo "* Error starting podman linux vm machine: $ECODE";exit $ECODE;fi

I hope help.
Carlos Eduardo Gorges.

@mixpix3ls
Copy link

Please upgrade your podman to 4.1.1 and make sure your macos version is 12.4

👋🏽 @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).

@cpolizzi
Copy link

@mixpix3ls With your host upgraded to macOS 12.4 and using Podman 4.1.1 and ensuring that the linked fix #14563 is applied to your Podman configuration file for the QEMU CmdLine flags as described here and fixed in #14563 then you can run with more than your current VM sizing. Yesterday I confirmed with several folks that have M1 Pro Max SoC's that once they did these things they could size the VM to as the maximum number of performance cores available (8 in their case) and more than 3GB of memory without issue.

@momrak
Copy link

momrak commented Jul 11, 2022

I still have problems getting this to work. First, since I am on Podman v4.1.1 should not -cpu be host and highmem=on be that by default now? I still have to make that change manually here. And also after doing that I am unable to get it running.

What am I missing?

I am using nix as package manager if that is of any help

image

@baude
Copy link
Member

baude commented Jul 11, 2022

we are cutting an 4.2 rc1 today. Any chance you couild build that and try?

@momrak
Copy link

momrak commented Jul 11, 2022

Unfortunately I don't know how to override and specify this with Nix, but I'll keep an eye out for the new version and see if I get it working when it is out

@waikontse
Copy link

waikontse commented Jul 14, 2022

Here is a snippet from my m1 pro on 4.2 rc1. I hope it is useful. Also, I've use podman machine set --rootful
before starting the machine. Removed the old machine with the old settings set up by podman 4.1.1
`
podman --version
podman version 4.2.0-rc1

➜ podman-4.2.0-rc1 podman machine start
Starting machine "podman-machine-default"

Waiting for VM ...
Error: qemu exited unexpectedly with exit code 1, stderr: qemu-system-aarch64: -fw_cfg name=opt/com.coreos/environment,string=bm9fcHJveHk9Ii5pbnRyYW5ldCwuaW5nLm5ldCwxMjcuMC4wLjEsbG9jYWxob3N0LCouZGV2LmF6dXJlLmNvbSx3ZWIud2hhdHNhcHAuY29tInxodHRwX3Byb3h5PSJodHRwOi8vbG9jYWxob3N0OjMxMjgifGh0dHBzX3Byb3h5PSJodHRwOi8vbG9jYWxob3N0OjMxMjgifA==: duplicate fw_cfg file name: opt/com.coreos/environment
`

@JonasJonny
Copy link

Today I had:
podman/podman-machine-default_ready.sock: connect: connection refused

What worked for me:

1. podman machine stop
2. podman machine rm
3. podman machine init
4. podman machine start

@ericcurtin
Copy link
Contributor

ericcurtin commented Aug 3, 2022

My workaround is to delete the VM and start from scratch

$ podman machine stop
$ podman machine rm --force
$ podman machine init --cpus 2 --memory 2048 --disk-size 20
$ podman machine start

version

$ podman --version
podman version 4.1.0
$ qemu-system-aarch64 --version 
QEMU emulator version 7.0.0

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

@mkenigs
Copy link

mkenigs commented Sep 23, 2022

I still have problems getting this to work. First, since I am on Podman v4.1.1 should not -cpu be host and highmem=on be that by default now? I still have to make that change manually here. And also after doing that I am unable to get it running.

I am using nix as package manager if that is of any help

Also using nix, and for some reason I was still running into this until 4.2

@paulatwork
Copy link

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

@justkash
Copy link

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:

  1. Create machine VM with podman machine init ( with -v $HOME:$HOME if you want to be able to mount volumes)
  2. Update -M entry to virt,highmem=off in ~/.config/containers/podman/machine/qemu/podman-machine-default.json
  3. Save file and run podman machine start

@johnhamelink
Copy link

johnhamelink commented Jul 11, 2023

Hi folks,

I'm also attempting to use podman from within a Nix shell on aarch64-darwin (M1 Max).

{
  description = "Example Nix Environment";

  inputs = {
    nixpkgs = { url = "github:NixOS/nixpkgs/nixpkgs-unstable"; };
    flake-utils = { url = "github:numtide/flake-utils"; };
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs {
          inherit system;
        };

        # Configure podman
        podmanSetupScript = let
          registriesConf = pkgs.writeText "registries.conf " ''
          unqualified-search-registries = ["docker.io"]
          [registries.search]
          registries = ['docker.io']

          [registries.block]
          registries = []
          '';
        in pkgs.writeScript "podman-setup" ''
        #!${pkgs.runtimeShell}

        if ! test -f ~/.config/containers/registries.conf; then
           install -Dm555 ${registriesConf} ~/.config/containers/registries.conf
        fi
        '';
      in
        {
          # See: https://gist.github.com/adisbladis/187204cb772800489ee3dac4acdd9947
          packages.default = pkgs.mkShell {
            buildInputs = with pkgs; [
              podman
              podman-compose
            ];

            shellHook = ''
            # Install required configuration
            ${podmanSetupScript}

            # Start the podman machine. We change the default name to
            # VM so we can avoid:
            # TODO: This is only necessary in Darwin
            # https://github.com/containers/podman/issues/13609#issuecomment-1076366318

            podman machine init \
              --timezone=local \
              --rootful=false \
              --log-level=trace \
              -v $HOME:$HOME \
              vm
            '';
          };
        });
}

After entering the shell, and allowing podman to initialise, when I run podman machine start vm, the qmp_<machine-name>.sock file isn't found:

johnhamelink@jh-mbp example % podman --log-level=trace machine start vm                                           ~/code/example
INFO[0000] /nix/store/mfqwvsv33rbvbz7gpljb56rdf0vi41b4-podman-4.5.1/bin/podman filtering at log level trace 
Starting machine "vm"
Error: dial unix /var/folders/9b/_c6ry1bx4yz4w5v61wygygl80000gp/T/nix-shell.jG7OwJ/podman/qmp_vm.sock: connect: no such file or directory
DEBU[0003] Shutting down engines 
johnhamelink@jh-mbp example % podman machine ls                                                                   ~/code/example
NAME        VM TYPE     CREATED        LAST UP        CPUS        MEMORY      DISK SIZE
vm*         qemu        2 minutes ago  2 minutes ago  1           2.147GB     107.4GB
johnhamelink@jh-mbp example % podman machine inspect vm                                                           ~/code/example
[
     {
          "ConfigPath": {
               "Path": "/Users/johnhamelink/.config/containers/podman/machine/qemu/vm.json"
          },
          "ConnectionInfo": {
               "PodmanSocket": {
                    "Path": "/Users/johnhamelink/.local/share/containers/podman/machine/qemu/podman.sock"
               },
               "PodmanPipe": null
          },
          "Created": "2023-07-11T14:05:36.313897+01:00",
          "Image": {
               "IgnitionFilePath": {
                    "Path": "/Users/johnhamelink/.config/containers/podman/machine/qemu/vm.ign"
               },
               "ImageStream": "testing",
               "ImagePath": {
                    "Path": "/Users/johnhamelink/.local/share/containers/podman/machine/qemu/vm_fedora-coreos-38.20230625.2.0-qemu.aarch64.qcow2"
               }
          },
          "LastUp": "2023-07-11T14:05:36.313897+01:00",
          "Name": "vm",
          "Resources": {
               "CPUs": 1,
               "DiskSize": 100,
               "Memory": 2048
          },
          "SSHConfig": {
               "IdentityPath": "/Users/johnhamelink/.ssh/vm",
               "Port": 50070,
               "RemoteUsername": "core"
          },
          "State": ""
     }
]

I've tried adjusting the memory as mentioned by @justkash above, reducing the length of the machine name (down to 'vm'). I've also ensured -cpu=host and highmem=on are set by default as @momrak suggests.

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Oct 10, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. machine
Projects
None yet
Development

Successfully merging a pull request may close this issue.