winapps-org / winapps

The winapps main project, forked from https://github.com/Fmstrat/winapps/
Other
892 stars 39 forks source link

[Docker] ERROR: KVM acceleration not available (device file missing), this will cause a major loss of performance. #157

Open PierreV23 opened 1 month ago

PierreV23 commented 1 month ago

What am i supposed to do?

pierrev@pierrevd:~/Downloads/winapps$ cat ~/.config/winapps/compose.yaml 
# For documentation, FAQ, additional configuration options and technical help, visit: https://github.com/dockur/windows

name: "winapps" # Docker Compose Project Name.
volumes:
  # Create Volume 'data'.
  # Located @ '/var/lib/docker/volumes/winapps_data/_data' (Docker).
  # Located @ '/var/lib/containers/storage/volumes/winapps_data/_data' or '~/.local/share/containers/storage/volumes/winapps_data/_data' (Podman).
  data:
services:
  windows:
    image: dockurr/windows # https://hub.docker.com/r/dockurr/windows
    container_name: WinApps # Created Docker VM Name.
    environment:
      # Version of Windows to configure. For valid options, visit:
      # https://github.com/dockur/windows?tab=readme-ov-file#how-do-i-select-the-windows-version
      # https://github.com/dockur/windows?tab=readme-ov-file#how-do-i-install-a-custom-image
      VERSION: "tiny11"
      RAM_SIZE: "4G" # RAM allocated to the Windows VM.
      CPU_CORES: "4" # CPU cores allocated to the Windows VM.
      DISK_SIZE: "64G" # Size of the primary hard disk.
      #DISK2_SIZE: "32G" # Uncomment to add an additional hard disk to the Windows VM. Ensure it is mounted as a volume below.
      #USERNAME: "Docker" # Uncomment to set a custom Windows username. The default is 'Docker'.
      #PASSWORD: "" # Uncomment to set a password for the Windows user. There is no default password.
      HOME: "${HOME}" # Set path to Linux user home folder.
    privileged: true # Grant the Windows VM extended privileges.
    ports:
      - 8006:8006 # Map '8006' on Linux host to '8006' on Windows VM --> For VNC Web Interface @ http://127.0.0.1:8006.
      - 3389:3389/tcp # Map '3389' on Linux host to '3389' on Windows VM --> For Remote Desktop Protocol (RDP).
      - 3389:3389/udp # Map '3389' on Linux host to '3389' on Windows VM --> For Remote Desktop Protocol (RDP).
    stop_grace_period: 120s # Wait 120 seconds before sending SIGTERM when attempting to shut down the Windows VM.
    restart: on-failure # Restart the Windows VM if the exit code indicates an error.
    volumes:
      - data:/storage # Mount volume 'data' to use as Windows 'C:' drive.
      - ${HOME}:/shared # Mount Linux user home directory @ '\\host.lan\Data'.
      #- /path/to/second/hard/disk:/storage2 # Uncomment to mount the second hard disk within the Windows VM. Ensure 'DISK2_SIZE' is specified above.
      #- ./oem:/oem # Enables automatic post-install execution of 'oem/install.bat', applying Windows registry modifications contained within 'oem/RDPApps.reg'.
      #- /home/pierrev/Downloads/tiny11_23H2_x64.iso:/custom.iso # Uncomment to use a custom Windows ISO. If specified, 'VERSION' (e.g. 'tiny11') will be ignored.
    devices:
      - /dev/kvm # Enable KVM.
      #- /dev/sdX:/disk1 # Uncomment to mount a disk directly within the Windows VM (Note: 'disk1' will be mounted as the main drive).
      #- /dev/sdY:/disk2 # Uncomment to mount a disk directly within the Windows VM (Note: 'disk2' and higher will be mounted as secondary drives).
pierrev@pierrevd:~/Downloads/winapps$ cat ~/.config/winapps/winapps.conf
RDP_USER="Docker"
RDP_PASS=""
#RDP_DOMAIN="MYDOMAIN"
#RDP_IP="192.168.123.111"
WAFLAVOR="docker" # Acceptable values are 'docker', 'podman' and 'libvirt'.
#RDP_SCALE=100 # Acceptable values are 100, 140, and 180.
#RDP_FLAGS=""
#MULTIMON="true"
#DEBUG="true"
#FREERDP_COMMAND="xfreerdp"
LDprg commented 1 month ago

@KernelGhost this seems like a bug with the waflavors?

PierreV23 commented 1 month ago

I had to run docker compose with sudo because otherwise i was getting errors about kvm: https://github.com/dockur/windows/issues/667 maybe this has something to do with it?

KernelGhost commented 1 month ago

The Docker virtual machine fails to boot due to KVM acceleration being unavailable (as per the Docker log you shared here). Consequently, the command docker ps --filter name="WinApps" --format '{{.Status}}' returns nothing, causing the script to incorrectly fall back to checking for a Podman virtual machine. I will update the script to prevent this unintended fallback behaviour.

In the meantime, we should focus on resolving the KVM issue.

Given that docker compose proceeded without error when running with root privileges, it is also worth checking whether your user is part of the kvm group by running groups $(whoami). If absent, you can add your user to the group using sudo usermod -aG kvm $(whoami). Ensure you reboot your system after adding your user to the group before re-attempting the Windows installation. If this works for you, please let me know so that I can update the documentation to ensure other users perform this step.

If the above fails, you can also try deleting the .docker directory in your home folder with the command sudo rm -r ~/.docker. I experienced a similar issue in the past, and vaguely recall this resolving the issue. It is unclear why this seemed to work for me, and I did not bother to investigate this further. Please ensure there is nothing important in that directory prior to deletion.

Please keep us updated on your progress.

PierreV23 commented 1 month ago

Thanks for the quick response,

My user seems to be part of the kvm group:

pierrev@pierrevd:~/Downloads/winapps$ groups $(whoami)
pierrev : pierrev cdrom floppy sudo audio dip video plugdev users kvm netdev bluetooth lpadmin scanner

I deleted the ~/.docker folder but now when i try to run the compose up command it just lags infinitely. Going to restart my laptop now.

Maybe something went wrong with my docker installation? I got kinda confused in the installation guide (https://docs.docker.com/engine/install/debian/) and first installed via apt, but then also the .deb file from https://docs.docker.com/desktop/install/debian/

PierreV23 commented 1 month ago

Alright so i restarted my laptop, deleted the .docker folder again because last time i forgot to shotdown docker desktop before doing so.

I had to set the memory limit in Docker Desktop > settings > Resources to 6GB by the way, otherwise docker compose would complain about:

pierrev@pierrevd:~$ docker compose --file ~/.config/winapps/compose.yaml up
[+] Running 7/7
 ✔ windows Pulled                                                                                                                                                12.7s 
   ✔ 28b9a042b2f1 Pull complete                                                                                                                                   6.7s 
   ✔ 607a8c080628 Pull complete                                                                                                                                   8.4s 
   ✔ 7da360374e0b Pull complete                                                                                                                                   8.6s 
   ✔ 75e784666a3f Pull complete                                                                                                                                   8.9s 
   ✔ 45217bed6de1 Pull complete                                                                                                                                   9.2s 
   ✔ e0d2bf59cee9 Pull complete                                                                                                                                   9.5s 
[+] Running 3/3
 ✔ Network winapps_default  Created                                                                                                                               0.1s 
 ✔ Volume "winapps_data"    Created                                                                                                                               0.0s 
 ✔ Container WinApps        Created                                                                                                                               1.0s 
Attaching to WinApps
WinApps  | ❯ Starting Windows for Docker v3.12...
WinApps  | ❯ For support visit https://github.com/dockur/windows
WinApps  | ❯ ERROR: Your configured RAM_SIZE of 4 GB is too high for the 1 GB of memory available, please set a lower value.
WinApps  | ❯ CPU: Intel Core TM i5 4300M CPU | RAM: 1/3 GB | DISK: 59 GB (ext4) | HOST: 6.6.32-linuxkit...
WinApps  | 
WinApps exited with code 0

I tried compose up again now but it still complains about kvm, even tho im in the kvm group.

pierrev@pierrevd:~$ docker compose --file ~/.config/winapps/compose.yaml up
[+] Running 2/2
 ✔ Network winapps_default  Created                                                                                                                               0.1s 
 ✔ Container WinApps        Created                                                                                                                               0.2s 
Attaching to WinApps
WinApps  | ❯ Starting Windows for Docker v3.12...
WinApps  | ❯ For support visit https://github.com/dockur/windows
WinApps  | ❯ CPU: Intel Core TM i5 4300M CPU | RAM: 5/6 GB | DISK: 54 GB (ext4) | HOST: 6.6.32-linuxkit...
WinApps  | 
WinApps  | ❯ ERROR: KVM acceleration not available (device file missing), this will cause a major loss of performance.
WinApps  | ❯ ERROR: See the FAQ on how to diagnose the cause, or continue without KVM by setting KVM=N (not recommended).
WinApps exited with code 0
KernelGhost commented 1 month ago

Thanks for trying the suggested changes. Unfortunately, this issue is outside my area of expertise, and may be best suited for the dockur/windows repository issue list.

  1. Is virtualisation enabled in your BIOS/UEFI?
  2. Does /dev/kvm have the correct permissions (root:kvm ownership and, at minimum, 660 permissions)?
  3. Have you attempted a complete uninstallation of Docker including deletion of ~/.docker and /var/lib/docker?
  4. Is it possible that a security policy (e.g. SELinux/AppArmor) is preventing Docker from accessing /dev/kvm?
  5. Would you be open to attempting to use an alternative backend for WinApps such as Podman or libvert?
PierreV23 commented 1 month ago

Thanks for trying the suggested changes. Unfortunately, this issue is outside my area of expertise, and may be best suited for the dockur/windows repository issue list.

1. Is virtualisation enabled in your BIOS/UEFI?

2. Does /dev/kvm have the correct permissions (`root:kvm` ownership and, at minimum, `660` permissions)?

3. Have you attempted a complete uninstallation of `Docker` including deletion of `~/.docker` and `/var/lib/docker`?

4. Is it possible that a security policy (e.g. SELinux/AppArmor) is preventing `Docker` from accessing `/dev/kvm`?

5. Would you be open to attempting to use an alternative backend for WinApps such as `Podman` or `libvert`?
  1. yes
  2. to my knowledge, yes:
    pierrev@pierrevd:~/Downloads$ ls -la /dev/kvm
    crw-rw----+ 1 root kvm 10, 232 Jul 23 23:20 /dev/kvm
    pierrev@pierrevd:~/Downloads$ stat -c "%a" /dev/kvm
    660
    pierrev@pierrevd:~/Downloads$ sudo kvm-ok
    INFO: /dev/kvm exists
    KVM acceleration can be used
  3. yes
  4. Im not sure how to check this.
  5. yes, i picked docker because it seemed to be the easiest approach, but i would try a different backend if this issue cannot be resolved.
KernelGhost commented 1 month ago

Thanks for getting back to me so quickly.

For the time being, I would recommend switching to the libvirt backend and awaiting further assistance from the dockur/windows team (should you wish to use Docker in the future).

Although the libvirt instructions seem long and daunting, I've done my best to be as descriptive as possible. You are more likely to have a more performant and optimised experience by using libvirt anyway.

Please let me know if you have any other thoughts or questions.

PierreV23 commented 1 month ago

Alright, thanks for your time and quick response, I'll try out libvirt!

Not sure if this issue should be closed or not, so I'll let that up to you.

KernelGhost commented 1 month ago

Since we didn't solve the root issue, it's probably best to leave this open in case anyone else encounters a similar issue in the future.

BADatCOMPUTER commented 1 month ago

I also have this issue. What is strange is, I have been using QEMU with KVM and without the need for sudo thanks to simple group permissions. Using sudo and no -d, I can see the following errors after the disk image is created.

ERROR: KVM acceleration not available (device file missing), this will cause a major loss of performance. ERROR: See the FAQ on how to diagnose the cause, or continue without KVM by setting KVM=N (not recommended). exited with code 88

BADatCOMPUTER commented 1 month ago

I found that this problem only exists when using docker-compose or docker desktop. Docker CLI with Sudo works but it shouldn't need sudo with permissions to KVM granted

KernelGhost commented 1 month ago

@BADatCOMPUTER Would you mind experimenting to see if the same issues are encountered when using podman-compose instead of docker compose?

aoceano commented 1 month ago

I'm having the same problem.

I use linux mint with docker desktop. Everything was checked several times, incluind a complete remove and install of docker desktop.

Even tried the docker-compose as well and had the same results.

aoceano commented 1 month ago

Some updates, it really seems that is the Docker Desktop.

I completely removed Docker Desktop and installed docker engine only. I had to change the docker context to use the right Docker Endpoint.

But using the docker compose command I managed to install windows and there was no KVM error message this time.

Now, in the Browser there is the VNC the is the windows with the "error conecting to the server", but I guess is not related with the KVM issue.

KernelGhost commented 1 month ago

@aoceano You make an excellent point, and I tend to agree with your assessment. I experienced a similar issue when I first installed Docker Desktop. The problem was only resolved after I removed Docker Desktop and deleted the ~/.docker directory.

aoceano commented 1 month ago

Some more updates.

After making the windows docker work with docker engine only, I installed Docker Desktop, because I need for work. The docker endpoint context is set to Docker Desktop.

I tried to run the Windows trought WinApps and said the Docker is not running. I started Docker Desktop and windows is working.

The funny thing is that in Docker Desktop and the docker ps -a cli does not show the windows container, but is running and working.

Accidentally I managed to make the winapps work with Docker Desktop installed. hahaha

MrTumnis commented 6 days ago

I was able to get Podman-rootless working with the suggested methods in: https://www.reddit.com/r/chimeralinux/comments/1ews3rt/podman_rootless_devkvm_and_kernel_modules_load/

juniornff commented 14 hours ago

I had the same issue, after using sudo for docker compose --file ./compose.yaml up it works.

even thought:

$ groups $(whoami)
familia : familia cdrom floppy audio dip video plugdev users kvm netdev bluetooth lpadmin scanner libvirt

$ sudo kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

Note: In Docker Desktop i don't see the container itself. When i don't use sudo it appears but dont work. so i guess if enough for now.

Of course i want to help to figure out the problem and solutions.

juniornff commented 14 hours ago

Was too good to be true. When trying to install Winapps by the setup.sh i got this:

$ ./setup.sh
################################################################################
#                                                                              #
#                            WinApps Install Wizard                            #
#                                                                              #
################################################################################

Q) Install or uninstall WinApps? --> Install
Q) Configure WinApps for the current user 'familia' or the whole system? --> Current User
Q) Automatically install supported applications or choose manually? --> Automatic

WinApps installation already present at /home/familia/.local/bin/winapps-src. Updating...
Ya está actualizado.
Installing WinApps.
Checking for existing conflicting WinApps installations... Done!
Attempting to load WinApps configuration file... Done!
Checking whether dependencies are installed... Done!
Checking container status... Failed!

ERROR: CONTAINER NOT RUNNING.
Windows is not running.
--------------------------------------------------------------------------------
Please ensure Windows is powered on:
docker compose --file ~/.config/winapps/compose.yaml start
--------------------------------------------------------------------------------
Exiting with status '11'.

But my docker windows container is running: image

$ sudo docker compose --file ~/.config/winapps/compose.yaml up
[sudo] contraseña para familia: 
[+] Running 1/1
 ✔ Container WinApps  Recreated                                            0.1s 
Attaching to WinApps
WinApps  | ❯ Starting Windows for Docker v3.15...
WinApps  | ❯ For support visit https://github.com/dockur/windows
WinApps  | ❯ CPU: Intel Core TM i5 7200U CPU | RAM: 9/16 GB | DISK: 73 GB (ext4) | HOST: 6.1.0-25-amd64...
WinApps  | 
WinApps  | ❯ Booting Windows using QEMU v9.0.2...
WinApps  | 
BdsDxe: loading Boot0004 "Windows Boot Manager" from HD(1,GPT,47E5942C-AAEB-4F02-BBC7-ED557FD39FEB,0x800,0x40000)/\EFI\Microsoft\Boot\bootmgfw.efi
WinApps  | BdsDxe: starting Boot0004 "Windows Boot Manager" from HD(1,GPT,47E5942C-AAEB-4F02-BBC7-ED557FD39FEB,0x800,0x40000)/\EFI\Microsoft\Boot\bootmgfw.efi
WinApps  | ❯ Windows started succesfully, visit http://localhost:8006/ to view the screen...

Also here is my winapps config file and my compose.yaml WINAPPS CONFIG FILE & COMPOSE.txt

Also, the container is already initialized when login in and needs to sudo all these commands to use them:

docker compose --file ~/.config/winapps/compose.yaml start # Power on the Windows VM
docker compose --file ~/.config/winapps/compose.yaml pause # Pause the Windows VM
docker compose --file ~/.config/winapps/compose.yaml unpause # Resume the Windows VM
docker compose --file ~/.config/winapps/compose.yaml restart # Restart the Windows VM
docker compose --file ~/.config/winapps/compose.yaml stop # Gracefully shut down the Windows VM
docker compose --file ~/.config/winapps/compose.yaml kill # Force shut down the Windows VM
MrTumnis commented 2 hours ago

Can you try adding this to your compose.yaml? This worked for me. After a few other changes I had to enable for Podman to work.

image:  dockur/windows
group_add:
       - keep-groups