dmacvicar / terraform-provider-libvirt

Terraform provider to provision infrastructure with Linux's KVM using libvirt
Apache License 2.0
1.54k stars 457 forks source link

cpu mode host-passthrough - Unsupported argument #970

Open mvrk69 opened 1 year ago

mvrk69 commented 1 year ago

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://root@xxx.xxx.xxx.xxx/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?

MusicDin commented 1 year ago

Hi,

the host-passthrough mode should be supported.

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

cpu { # <--
  mode = "host-passthrough"
}
mvrk69 commented 1 year ago

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

linuzer commented 1 year ago

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...