Skip to content

Error creating libvirt domain: Permission denied #1163

Open
@stew3254

Description

@stew3254

When trying to set up any basic vm with a disk I created with Terraform, I run into this error

error creating libvirt domain: internal error: process exited while connecting to monitor: 2025-03-03T11:25:49.961773Z qemu-system-x86_64: -blockdev {"driver":"file","filename":"/var/lib/libvirt/images/cloud-noble.qcow2","node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}: Could not open '/var/lib/libvirt/images/cloud-noble.qcow2': Permission denied

I noticed Terraform doesn't like to follow the usual file permissions of libvirt vms. I've tried changing it, but to no avail. I have no idea why it keeps saying permission denied. I am using upstream Terraform version v1.11.0. Here is my Terraform

terraform {
  required_providers {
    libvirt = {
      source = "dmacvicar/libvirt"
      version = "0.8.2"
    }
  }
}

provider "libvirt" {
  uri = "qemu:///system"
}

### Network Configuration ###
resource "libvirt_network" "my_net" {
  name = "lv-net"
  mode = "nat"
  addresses = ["192.168.123.1/24"]
  autostart = true
}

### Image Configuration ###
resource "libvirt_volume" "noble" {
  name = "cloud-noble.qcow2"
  source = "https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img"
}

resource "libvirt_domain" "test" {
  name = "test"
  description = "Test image"
  vcpu = 2
  memory = "2048"
  disk {
    volume_id = libvirt_volume.noble.id
  }
  network_interface {
    network_id = libvirt_network.my_net.id
    wait_for_lease = true
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions