terraform-provider-libvirt icon indicating copy to clipboard operation
terraform-provider-libvirt copied to clipboard

cpu mode host-passthrough - Unsupported argument

Open mvrk69 opened this issue 3 years ago • 3 comments

System Information

Linux distribution

Fedora 36

Terraform version

Terraform v1.2.7

Provider and libvirt versions

0.6.14

Description of Issue/Question

Hi, i'm trying to provision my vm with cpu mode = "host-passthrough", i added the block according to the documentation, but i get this error:

terraform plan ╷ │ Error: Unsupported argument │ │ on vm-create.tf line 22, in resource "libvirt_domain" "PROV-TST": │ 22: cpu = { │ │ An argument named "cpu" is not expected here. Did you mean to define a block of type "cpu"?

This is my terraform code:

`terraform { required_providers { libvirt = { source = "dmacvicar/libvirt" } ansiblevault = { source = "MeilleursAgents/ansiblevault" } } }

provider "libvirt" { uri = "qemu+ssh://[email protected]/system?keyfile=/home/xxxxx/.ssh/id_rsa&sshauth=privkey" }

provider "ansiblevault" { vault_path = "/xxx/.xxxxxx.txt" root_folder = "/xxx/" }

resource "libvirt_volume" "volume-PROV-TST_01_BOOT" { name = "PROV-TST_01_BOOT.qcow2" pool = "vms" format = "qcow2" size = 1073741824 }

resource "libvirt_volume" "volume-PROV-TST_02_OS" { name = "PROV-TST_02_OS.qcow2" pool = "vms" format = "qcow2" size = 8589934592 }

resource "libvirt_domain" "PROV-TST" { name = "PROV-TST" memory = "2048" vcpu = 2

cpu = { mode = "host-passthrough" }

network_interface { network_name = "lan" }

network_interface { network_name = "priv-iscsi1" }

network_interface { network_name = "priv-iscsi2" }

disk { volume_id = "${libvirt_volume.volume-PROV-TST_01_BOOT.id}" }

disk { volume_id = "${libvirt_volume.volume-PROV-TST_02_OS.id}" }

video { type = "virtio" }

console { type = "pty" target_type = "serial" target_port = "0" }

graphics { type = "spice" listen_type = "address" autoport = true } } `

Is this a bug? Or cpu mode is not supported anymore in the provider?

mvrk69 avatar Aug 25 '22 09:08 mvrk69

Hi,

the host-passthrough mode should be supported.

Can you try without equals sign (=) after cpu?

cpu { # <--
  mode = "host-passthrough"
}

MusicDin avatar Aug 25 '22 13:08 MusicDin

Yup, that is it. Can't believe i didn't noticed that. Thank you.

mvrk69 avatar Aug 25 '22 15:08 mvrk69

Since I stumbled over the same: Could you please also correct the documentation? https://registry.terraform.io/providers/multani/libvirt/latest/docs/resources/domain#cpu-mode

That's why at least I tapped into that issue...

linuzer avatar Dec 26 '22 18:12 linuzer