kubevirt: Unable to open /dev/kvm: Permission denied

What happened: vmi:

Events:
  Type     Reason            Age                 From                       Message
  ----     ------            ----                ----                       -------
  Normal   SuccessfulCreate  44s                 virtualmachine-controller  Created virtual machine pod virt-launcher-vmi-host-network-jptfp
  Warning  SyncFailed        19s (x13 over 39s)  virt-handler               lstat /proc/344846/root/sys/class/net/ns1: no such file or directory

virt-launcher pod log:

Connecting to libvirt daemon failed: virError(Code=38, Domain=7, Message='Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory
Unable to open /dev/kvm: Permission denied
internal error: Unable to get session bus connection: Cannot spawn a message bus without a machine-id: Unable to load /var/lib/dbus/machine-id or /etc/machine-id: Failed to open file “/var/lib/dbus/machine-id”: No such file or directory

What you expected to happen: virtual instance up and running

How to reproduce it (as minimally and precisely as possible): Deployed below yaml on kubevirt v0.58.0:

kind: NetworkAttachmentDefinition
apiVersion: k8s.cni.cncf.io/v1
metadata:
  name: macvtapnetwork
  namespace: ns1
  annotations:
    k8s.v1.cni.cncf.io/resourceName: macvtap.network.kubevirt.io/eth0
spec:
  config: '{
      "cniVersion": "0.3.1",
      "name": "macvtapnetwork",
      "type": "macvtap",
      "mtu": 1500
    }'
---
apiVersion: kubevirt.io/v1
kind: VirtualMachineInstance
metadata:
  labels:
    special: vmi-host-network
  name: vmi-host-network
  namespace: ns1
spec:
  domain:
    devices:
      disks:
      - disk:
          bus: virtio
        name: containerdisk
      - disk:
          bus: virtio
        name: cloudinitdisk
      interfaces:
      - macvtap: {}
        name: hostnetwork
      rng: {}
    machine:
      type: ""
    resources:
      requests:
        memory: 4024M
  networks:
  - multus:
      networkName: ns1/macvtapnetwork
    name: hostnetwork
  terminationGracePeriodSeconds: 0
  volumes:
  - containerDisk:
      image: kubevirt/fedora-with-test-tooling-container-disk:devel
    name: containerdisk
  - cloudInitNoCloud:
      userData: |-
        #!/bin/bash
        echo "fedora" |passwd fedora --stdin
    name: cloudinitdisk

Additional context:

{"component":"virt-launcher","level":"info","msg":"Collected all requested hook sidecar sockets","pos":"manager.go:86","timestamp":"2022-12-14T10:40:04.895432Z"}
{"component":"virt-launcher","level":"info","msg":"Sorted all collected sidecar sockets per hook point based on their priority and name: map[]","pos":"manager.go:89","timestamp":"2022-12-14T10:40:04.895484Z"}
{"component":"virt-launcher","level":"info","msg":"Connecting to libvirt daemon: qemu+unix:///session?socket=/var/run/libvirt/libvirt-sock","pos":"libvirt.go:497","timestamp":"2022-12-14T10:40:04.896097Z"}
{"component":"virt-launcher","level":"info","msg":"Connecting to libvirt daemon failed: virError(Code=38, Domain=7, Message='Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory')","pos":"libvirt.go:505","timestamp":"2022-12-14T10:40:04.896515Z"}
{"component":"virt-launcher","level":"info","msg":"libvirt version: 8.0.0, package: 2.module_el8.6.0+1087+b42c8331 (CentOS Buildsys \u003cbugs@centos.org\u003e, 2022-02-08-22:20:52, )","subcomponent":"libvirt","thread":"45","timestamp":"2022-12-14T10:40:04.913000Z"}
{"component":"virt-launcher","level":"info","msg":"hostname: vmi-host-network","subcomponent":"libvirt","thread":"45","timestamp":"2022-12-14T10:40:04.913000Z"}
{"component":"virt-launcher","level":"error","msg":"Unable to open /dev/kvm: Permission denied","pos":"virHostCPUGetCPUID:1325","subcomponent":"libvirt","thread":"45","timestamp":"2022-12-14T10:40:04.913000Z"}
{"component":"virt-launcher","level":"error","msg":"internal error: Unable to get session bus connection: Cannot spawn a message bus without a machine-id: Unable to load /var/lib/dbus/machine-id or /etc/machine-id: Failed to open file “/var/lib/dbus/machine-id”: No such file or directory","pos":"virGDBusGetSessionBus:128","subcomponent":"libvirt","thread":"45","timestamp":"2022-12-14T10:40:04.913000Z"}
{"component":"virt-launcher","level":"error","msg":"internal error: Unable to get system bus connection: Could not connect: No such file or directory","pos":"virGDBusGetSystemBus:101","subcomponent":"libvirt","thread":"45","timestamp":"2022-12-14T10:40:04.913000Z"}
{"component":"virt-launcher","level":"info","msg":"Connected to libvirt daemon","pos":"libvirt.go:513","timestamp":"2022-12-14T10:40:05.397628Z"}
{"component":"virt-launcher","level":"info","msg":"Registered libvirt event notify callback","pos":"client.go:510","timestamp":"2022-12-14T10:40:05.400177Z"}
{"component":"virt-launcher","level":"info","msg":"Marked as ready","pos":"virt-launcher.go:74","timestamp":"2022-12-14T10:40:05.400343Z"}
... ...

Environment:

  • KubeVirt version (use virtctl version): v0.58.0
  • Kubernetes version (use kubectl version): v1.25.4
  • VM or VMI specifications: centos based iso (Non cloud)
  • Cloud provider or hardware configuration: DELL
  • OS (e.g. from /etc/os-release): openEuler 22.09
  • Kernel (e.g. uname -a): Linux 5.10.0-106.18.0.68.oe2209.x86_64
  • Install tools: containerd v1.6.12/qemu-10:6.2.0-49.oe2209.x86_64/libvirt-6.2.0-45.oe2209.x86_64
  • Others: Multus plugin installed

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 16 (5 by maintainers)

Most upvoted comments

/dev/kvm is provided by the host kernel. Then /dev/kvm is picked up by whatever kube distro is being used to provide it to a pod, where eventually kubevirt will pick it up.

Thus 3 layers:

  1. Host
  2. Kube distro
  3. KubeVirt

Due to CI we see that KubeVirt can consume /dev/kvm if properly configured in the earlier layers.

In this thread there are now different mentions of 1 and 2 - different Host OSses (Ubuntu, Fedora, at least) and different Kube distros (kind, …) not to mention individual configurations on the hosts or kube distros.

I’m closing this “catch all” bug and request every affected person to open specific bugs for OS + Kube distro + kubevirt version. Otherwise this bug will never close and will not help anybody, because too many things are thrown into the same bucket.

/remove-lifecycle stale

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

/lifecycle stale

It appears to be a problem with running podman rootless. When creating the cluster and resources with sudo, it deploys. As regular user, it fails to deploy with a crash backoff loop.