Open Manfred73 opened 3 months ago
@Manfred73 Hi, If I understood correctly you are trying to run crc on a ubuntu VM which is running on windows machine. Why can't you directly use crc on that windows machine ? In past we also issue which raised by users are using nested virt (check the label) and in your case also it is same. We don't perform nested virtualization so not even sure why it is happen, Also we recently did 2.40.0 release try that and see if that works (it fixes one of the issue https://github.com/crc-org/machine-driver-libvirt/pull/122 if underlying hardware is AMD one)
I want to use an Ubuntu/Linux image with crc and other tooling pre installed for training purposes, so I can easily share the image. Some users will have macOS, some Linux and some Windows. First I tried Virtual Box, but understood that doesn't work at all with nested virt and crc. I understood QEMU did supporr this.
Are there workarounds for this, or assigning IP manually. I will try the newer version also.
Update: I tried version 2.40.0. Unfortunately still the same issue.
Check the logs under /var/log/libvirt/qemu/crc.log
and see if there is any error, otherwise VM should able to get the IP automatic. Also you can try following if that help
$ crc delete
$ crc cleanup
$ crc config set network-mode user
$ crc setup
$ crc start
I do see one error related to libvirtd in the crc.log
(see log attached):
crc.log
libvirt: error : libvirtd quit during handshake: Input/output error
2024-08-08 22:07:04.951+0000: shutting down, reason=failed
2024-08-09 05:21:30.494+0000: Starting external device: virtiofsd
I also followed the steps you mentioned before, but without the crc config set network-mode user
. I have tried them again, including this option which seems to do something.
I did crc delete
followed by crc cleanup
:
$ crc config set network-mode user
Network mode changed. Please run `crc cleanup` and `crc setup`.
It suggests I do crc cleanup
again, which results in an error (unexpected AppArmor template file /etc/apparmor.d/libvirt/TEMPLATE.qemu, cannot configure it automatically):
$ crc cleanup
INFO Removing vsock configuration
INFO Removing 'crc' network from libvirt
INFO Removing /etc/NetworkManager/dispatcher.d/99-crc.sh file
INFO Cleaning up AppArmor configuration
INFO Removing crc daemon systemd socket units
INFO Removing crc daemon systemd service
INFO Removing crc's virtual machine
INFO Removing crc libvirt storage pool
INFO Removing CRC Specific entries from user's known_hosts file
INFO Removing hosts file records added by CRC
INFO Removing pull secret from the keyring
INFO Removing older logs
unexpected AppArmor template file /etc/apparmor.d/libvirt/TEMPLATE.qemu, cannot configure it automatically
Network mode changed. Please run `crc cleanup` and `crc setup`.
Then crc setup
:
$ crc setup
INFO Using bundle path /home/itsme/.crc/cache/crc_libvirt_4.16.4_amd64.crcbundle
INFO Checking if running as non-root
INFO Checking if running inside WSL2
INFO Checking if crc-admin-helper executable is cached
INFO Checking if running on a supported CPU architecture
INFO Checking if crc executable symlink exists
INFO Creating symlink for crc executable
INFO Checking minimum RAM requirements
INFO Check if Podman binary exists in: /home/itsme/.crc/bin/oc
INFO Checking if Virtualization is enabled
INFO Checking if KVM is enabled
INFO Checking if libvirt is installed
INFO Checking if user is part of libvirt group
INFO Checking if active user/process is currently part of the libvirt group
INFO Checking if libvirt daemon is running
WARN No active (running) libvirtd systemd unit could be found - make sure one of libvirt systemd units is enabled so that it's autostarted at boot time.
INFO Starting libvirt service
INFO Using root access: Executing systemctl daemon-reload command
INFO Using root access: Executing systemctl start libvirtd
INFO Checking if a supported libvirt version is installed
INFO Checking if crc-driver-libvirt is installed
INFO Checking crc daemon systemd service
INFO Setting up crc daemon systemd service
INFO Checking crc daemon systemd socket units
INFO Setting up crc daemon systemd socket units
INFO Checking if AppArmor is configured
INFO Updating AppArmor configuration
INFO Using root access: Updating AppArmor configuration
INFO Using root access: Changing permissions for /etc/apparmor.d/libvirt/TEMPLATE.qemu to 644
INFO Checking if vsock is correctly configured
INFO Setting up vsock support
INFO Using root access: Setting CAP_NET_BIND_SERVICE capability for /home/itsme/bin/crc executable
INFO Using root access: Creating udev rule for /dev/vsock
INFO Using root access: Changing permissions for /etc/udev/rules.d/99-crc-vsock.rules to 644
INFO Using root access: Reloading udev rules database
INFO Using root access: Loading vhost_vsock kernel module
INFO Using root access: Creating file /etc/modules-load.d/vhost_vsock.conf
INFO Using root access: Changing permissions for /etc/modules-load.d/vhost_vsock.conf to 644
INFO Checking if CRC bundle is extracted in '$HOME/.crc'
INFO Checking if /home/itsme/.crc/cache/crc_libvirt_4.16.4_amd64.crcbundle exists
Your system is correctly setup for using CRC. Use 'crc start' to start the instance
Now, doing a crc start
gives the following error (failed to expose port 127.0.0.1:2222 -> 192.168.127.2:22: listen tcp 127.0.0.1:2222: bind: address already in use):
I have github locally installed on Ubuntu guest as docker, using ports 2222:22.
$ crc start -p ~/bin/pull-secret.txt --log-level debug
DEBU CRC version: 2.40.0+a14925
DEBU OpenShift version: 4.16.4
DEBU MicroShift version: 4.16.4
DEBU Running 'crc start'
DEBU Total memory of system is 33655652352 bytes
DEBU No new version available. The latest version is 2.40.0
DEBU Checking file: /home/itsme/.crc/machines/crc/.crc-exist
INFO Using bundle path /home/itsme/.crc/cache/crc_libvirt_4.16.4_amd64.crcbundle
DEBU resolv.conf file path: /run/systemd/resolve/stub-resolv.conf
DEBU Checking if systemd-resolved.service is running
DEBU Running 'systemctl status systemd-resolved.service'
DEBU systemd-resolved.service is already running
INFO Checking if running as non-root
INFO Checking if running inside WSL2
INFO Checking if crc-admin-helper executable is cached
DEBU Running '/home/itsme/.crc/bin/crc-admin-helper-linux-amd64 --version'
DEBU Found crc-admin-helper-linux-amd64 version 0.5.4
DEBU crc-admin-helper executable already cached
INFO Checking if running on a supported CPU architecture
DEBU GOARCH is amd64 GOOS is linux
INFO Checking if crc executable symlink exists
INFO Checking minimum RAM requirements
DEBU Total memory of system is 33655652352 bytes
INFO Check if Podman binary exists in: /home/itsme/.crc/bin/oc
INFO Checking if Virtualization is enabled
DEBU Checking if the vmx/svm flags are present in /proc/cpuinfo
DEBU CPU virtualization flags are good
INFO Checking if KVM is enabled
DEBU Checking if /dev/kvm exists
DEBU /dev/kvm was found
INFO Checking if libvirt is installed
DEBU Checking if 'virsh' is available
DEBU 'virsh' was found in /usr/bin/virsh
DEBU Checking 'virsh capabilities' for libvirtd/qemu availability
DEBU Running 'virsh --readonly --connect qemu:///system capabilities'
DEBU Found x86_64 hypervisor with 'hvm' capabilities
INFO Checking if user is part of libvirt group
DEBU Checking if current user is part of the libvirt group
DEBU Current user is already in the libvirt group
INFO Checking if active user/process is currently part of the libvirt group
DEBU libvirt group is active for the current user/process
INFO Checking if libvirt daemon is running
DEBU Checking if libvirtd service is running
DEBU Running 'systemctl status virtqemud.socket'
DEBU Command failed: exit status 4
DEBU stdout:
DEBU stderr: Unit virtqemud.socket could not be found.
DEBU virtqemud.socket is neither running nor listening
DEBU Running 'systemctl status libvirtd.socket'
DEBU libvirtd.socket is running
INFO Checking if a supported libvirt version is installed
DEBU Checking if libvirt version is >=8.0.0
DEBU Running 'virsh -v'
INFO Checking if crc-driver-libvirt is installed
DEBU Checking if crc-driver-libvirt-amd64 is installed
DEBU Running '/home/itsme/.crc/bin/crc-driver-libvirt-amd64 version'
DEBU Found crc-driver-libvirt-amd64 version 0.13.9
DEBU crc-driver-libvirt-amd64 is already installed
INFO Checking crc daemon systemd socket units
DEBU Checking crc daemon systemd socket units
DEBU Checking if crc-http.socket is running
DEBU Running 'systemctl --user status crc-http.socket'
DEBU crc-http.socket is running
DEBU Checking if crc-http.socket has the expected content
DEBU Checking if crc-vsock.socket is running
DEBU Running 'systemctl --user status crc-vsock.socket'
DEBU crc-vsock.socket is running
DEBU Checking if crc-vsock.socket has the expected content
INFO Checking if AppArmor is configured
INFO Checking if vsock is correctly configured
DEBU Running 'getcap /home/itsme/bin/crc'
DEBU Checking file: /home/itsme/.crc/machines/crc/.crc-exist
INFO Loading bundle: crc_libvirt_4.16.4_amd64...
DEBU Using secret from configuration
INFO Creating CRC VM for OpenShift 4.16.4...
DEBU Found binary path at /home/itsme/.crc/bin/crc-driver-libvirt-amd64
DEBU Launching plugin server for driver libvirt
DEBU Plugin server listening at address 127.0.0.1:36177
DEBU () Calling .GetVersion
DEBU Using API Version 1
DEBU () Calling .SetConfigRaw
DEBU () Calling .GetMachineName
DEBU (crc) Calling .GetMachineName
DEBU (crc) Calling .DriverName
DEBU Running pre-create checks...
DEBU (crc) Calling .PreCreateCheck
DEBU (crc) DBG | time="2024-08-12T22:20:55+02:00" level=debug msg="About to check libvirt version"
DEBU (crc) DBG | time="2024-08-12T22:20:55+02:00" level=debug msg="Validating storage pool"
DEBU (crc) Calling .GetConfigRaw
DEBU Creating machine...
DEBU (crc) Calling .Create
DEBU (crc) DBG | time="2024-08-12T22:20:55+02:00" level=debug msg="Preparing /home/itsme/.crc/machines/crc/crc.qcow2 for machine use"
DEBU (crc) DBG | time="2024-08-12T22:20:55+02:00" level=debug msg="image creation took 77.478378ms"
DEBU (crc) DBG | time="2024-08-12T22:20:55+02:00" level=debug msg="Verifying executable bit set on /home/itsme/.crc/machines/crc"
DEBU (crc) DBG | time="2024-08-12T22:20:55+02:00" level=debug msg="Verifying executable bit set on /home/itsme/.crc/machines"
DEBU (crc) DBG | time="2024-08-12T22:20:55+02:00" level=debug msg="Verifying executable bit set on /home/itsme/.crc"
DEBU (crc) DBG | time="2024-08-12T22:20:55+02:00" level=debug msg="Verifying executable bit set on /home/itsme"
DEBU (crc) DBG | time="2024-08-12T22:20:55+02:00" level=debug msg="Verifying executable bit set on /home"
DEBU (crc) DBG | time="2024-08-12T22:20:55+02:00" level=debug msg="Defining VM..."
DEBU (crc) DBG | time="2024-08-12T22:20:55+02:00" level=debug msg="Found x86_64 hypervisor with 'hvm' capabilities"
DEBU (crc) DBG | time="2024-08-12T22:20:55+02:00" level=debug msg="Found q35 machine type"
DEBU (crc) DBG | time="2024-08-12T22:20:55+02:00" level=debug msg="Found x86_64 hypervisor with 'hvm' capabilities"
DEBU (crc) DBG | time="2024-08-12T22:20:55+02:00" level=debug msg="Found q35 machine type"
DEBU (crc) DBG | time="2024-08-12T22:20:56+02:00" level=debug msg="disk image capacity is already 33285996544 bytes"
INFO Generating new SSH key pair...
INFO Generating new password for the kubeadmin user
DEBU Created /home/itsme/.crc/machines/crc/.crc-exist
DEBU Machine successfully created
DEBU Making call to close driver server
DEBU (crc) Calling .Close
DEBU Successfully made call to close driver server
DEBU Making call to close connection to plugin binary
DEBU Checking file: /home/itsme/.crc/machines/crc/.crc-exist
DEBU Found binary path at /home/itsme/.crc/bin/crc-driver-libvirt-amd64
DEBU Launching plugin server for driver libvirt
DEBU Plugin server listening at address 127.0.0.1:46607
DEBU () Calling .GetVersion
DEBU Using API Version 1
DEBU () Calling .SetConfigRaw
DEBU () Calling .GetMachineName
DEBU (crc) Calling .GetBundleName
DEBU (crc) Calling .GetState
DEBU (crc) DBG | time="2024-08-12T22:20:56+02:00" level=debug msg="Getting current state..."
DEBU (crc) DBG | time="2024-08-12T22:20:56+02:00" level=debug msg="Fetching VM..."
INFO Starting CRC VM for openshift 4.16.4...
DEBU Making call to close driver server
DEBU (crc) Calling .Close
DEBU Successfully made call to close driver server
DEBU Making call to close connection to plugin binary
failed to expose port 127.0.0.1:2222 -> 192.168.127.2:22: listen tcp 127.0.0.1:2222: bind: address already in use
crc status
shows:
$ crc status
CRC VM: Stopped
OpenShift: Stopped (v4.16.4)
RAM Usage: 0B of 0B
Disk Usage: 0B of 0B (Inside the CRC VM)
Cache Usage: 27.61GB
Cache Directory: /home/itsme/.crc/cache
When I stop gitlab and try crc start
again, it fails on port 80 (I have another docker image running with also uses port 80):
failed to expose port :80 -> 192.168.127.2:80: listen tcp :80: bind: address already in use
Should I run these docker images on another port? Or can I configure crc to use others?
I have stopped both docker images and did another:
$ crc delete
$ crc cleanup
$ crc config set network-mode user
$ crc setup
$ crc start
This results in errors:
DEBU retry loop: attempt 61
DEBU Running SSH command: exit 0
DEBU Using ssh private keys: [/home/itsme/.crc/machines/crc/id_ecdsa /home/itsme/.crc/cache/crc_libvirt_4.16.4_amd64/id_ecdsa_crc]
DEBU SSH command results: err: ssh: handshake failed: read tcp 127.0.0.1:56730->127.0.0.1:2222: read: connection reset by peer, output:
DEBU error: Temporary error: ssh command error:
command : exit 0
err : ssh: handshake failed: read tcp 127.0.0.1:56730->127.0.0.1:2222: read: connection reset by peer
- sleeping 1s
DEBU retry loop: attempt 62
DEBU Running SSH command: exit 0
DEBU Using ssh private keys: [/home/itsme/.crc/machines/crc/id_ecdsa /home/itsme/.crc/cache/crc_libvirt_4.16.4_amd64/id_ecdsa_crc]
DEBU SSH command results: err: ssh: handshake failed: read tcp 127.0.0.1:56744->127.0.0.1:2222: read: connection reset by peer, output:
DEBU error: Temporary error: ssh command error:
command : exit 0
err : ssh: handshake failed: read tcp 127.0.0.1:56744->127.0.0.1:2222: read: connection reset by peer
- sleeping 1s
On the Ubuntu guest I have a config file defined in the .ssh
for the docker images I'm running which need ssh with identity file. Is this causing a problem for crc?
libvirt: error : libvirtd quit during handshake: Input/output error
2024-08-08 22:07:04.951+0000: shutting down, reason=failed
2024-08-09 05:21:30.494+0000: Starting external device: virtiofsd
I think following explain it, looks like libvirt is not working at all properly and VM is not running, you can check status of the VM using sudo virsh list --all
and might see the VM in stopped state. This might be the reason why ssh is failing.
I create a complete new Ubuntu image and right after that installed prerequisites for crc (docker, libvirt):
sudo apt install qemu-system qemu-kvm qemu-utils libvirt-daemon-system libvirt-clients bridge-utils virt-manager virtiofsd
Right after that installed crc:
crc config set network-mode user
crc setup
crc start
libvirt service is running:
libvirtd.service - libvirt legacy monolithic daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; preset: enabled)
Active: active (running) since Tue 2024-08-13 23:41:18 CEST; 6min ago
TriggeredBy: libvirtd.socket
libvirtd-admin.socket
libvirtd-ro.socket
Docs: man:libvirtd(8)
https://libvirt.org/
Main PID: 1070 (libvirtd)
Tasks: 26 (limit: 32768)
Memory: 36.3M (peak: 42.4M)
CPU: 1.312s
CGroup: /system.slice/libvirtd.service
1070 /usr/sbin/libvirtd --timeout 120
1244 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
1245 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
3224 /usr/libexec/virtiofsd --fd=34 -o source=/home/itsme
Aug 13 23:41:19 itsme dnsmasq[1244]: using nameserver 127.0.0.53#53
Aug 13 23:41:19 itsme dnsmasq[1244]: read /etc/hosts - 8 names
Aug 13 23:41:19 itsme dnsmasq[1244]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 names
Aug 13 23:41:19 itsme dnsmasq-dhcp[1244]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Aug 13 23:41:19 itsme libvirtd[1070]: libvirt version: 10.0.0, package: 10.0.0-2ubuntu8.3 (Ubuntu)
Aug 13 23:41:19 itsme libvirtd[1070]: hostname: itsme
Aug 13 23:41:19 itsme libvirtd[1070]: ignoring socket '/home/itsme/.crc/machines/crc/docker.sock'
Aug 13 23:41:51 itsme libvirtd[1070]: End of file while reading data: Input/output error
Aug 13 23:43:49 itsme libvirtd[1070]: End of file while reading data: Input/output error
Aug 13 23:46:58 itsme libvirtd[1070]: End of file while reading data: Input/output error
crc status shows:
CRC VM: Running
OpenShift: Unreachable (v4.16.4)
Disk Usage: 0B of 0B (Inside the CRC VM)
Cache Usage: 27.61GB
Cache Directory: /home/itsme/.crc/cache
sudo virsh list --all shows:
Id Name State
----------------------
1 crc running
In the crc.log
I still see ssh handshake errors:
2: read: connection reset by peer\n - sleeping 1s"
time="2024-08-13T23:46:54+02:00" level=debug msg="retry loop: attempt 75"
time="2024-08-13T23:46:54+02:00" level=debug msg="Running SSH command: exit 0"
time="2024-08-13T23:46:54+02:00" level=debug msg="Using ssh private keys: [/home/itsme/.crc/machines/crc/id_ecdsa /home/itsme/.crc/cache/crc_libvirt_4.16.4_amd64/id_ecdsa_crc]"
time="2024-08-13T23:46:57+02:00" level=debug msg="SSH command results: err: ssh: handshake failed: read tcp 127.0.0.1:48438->127.0.0.1:2222: read: connection reset by peer, output: "
time="2024-08-13T23:46:57+02:00" level=debug msg="error: Temporary error: ssh command error:\ncommand : exit 0\nerr : ssh: handshake failed: read tcp 127.0.0.1:48438->127.0.0.1:2222: read: connection reset by peer\n - sleeping 1s"
and in /var/log/libvirt/qemu/crc.log
still one handhake errors:
libvirt: error : libvirtd quit during handshake: Input/output error
We can only debug more around this if it can reproduce in our testing/dev environment and which is not the case :( . There is lot of things depend for failure like base/guest HyperVisor and also underlying hardware. As I told before nested-virt
tests are not something we perform or encourage users to do it. If possible try on native hypervisor to see if it still fails instead nested-virt
.
General information
crc setup
before starting it (Yes/No)? YesCRC version
CRC status
The debug log shows
DEBU systemd-networkd.service is not running
, so I enabled and started it, but thancrc start
complains it cannot work withsystemd-networkd.service
, so I stopped and disabled it again.I also see errors about
systemctl status virtqemud.socket' which cannot be found (not running nor listening). It was my understanding that this should be available when installing
libvirt-daemon-system`. I installed the following applications:Am I missing another library here? I understand libvirtd is moving away from monolith to modules. I didn't get the modular approach to work though.
CRC config
Host Operating System
Steps to reproduce
Booting QEMU from Windows 11 host (with 64 GB RAM) using a batch file with the following options (using networking mode NAT). I noticed the crc network runs in bridge mode and thought that might be a problem. I tried to run QEMU in bridge, but didn't get that to work together with SPICE (the image won't boot if I use bridge mode).
Expected
CRC to start succesfully and
Actual
crc start takes a long time, and log shows 60 tries to GetIP for crc. Doing another start shows:
But a
crc status
shows:The CRC VM is running, but OpenShift is unreachable because it didn't get an IP assigned?
Logs
Before gather the logs try following if that fix your issue
Please consider posting the output of
crc start --log-level debug
on http://gist.github.com/ and post the link in the issue.virsh net-list --all
nmcli connection
virsh net-dumpxml crc | grep -i dhcp
systemctl status libvirtd.service
systemctl status NetworkManager
Older (related?) bugs/posts?
I have seen older other similar bugs around here: