dmacvicar / terraform-provider-libvirt

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

Bug: Ubuntu 24.04 - Getting 's390-ccw-virtio-noble' does not support ACPI for libvirt_domain #1094

Open Sashwat-K opened 2 weeks ago

Sashwat-K commented 2 weeks ago

System Information

Linux distribution

Ubuntu 24.04

Terraform version

Terraform v1.9.4
on linux_amd64
+ provider registry.terraform.io/dmacvicar/libvirt v0.7.1
+ provider registry.terraform.io/hashicorp/local v2.5.1
+ provider registry.terraform.io/hashicorp/null v3.2.2
+ provider registry.terraform.io/ibm-hyper-protect/hpcr v0.8.0

Provider and libvirt versions

provider registry.terraform.io/dmacvicar/libvirt v0.7.1

Compiled against library: libvirt 10.0.0
Using library: libvirt 10.0.0
Using API: QEMU 10.0.0
Running hypervisor: QEMU 8.2.2

Description of Issue/Question

Setup

resource "libvirt_domain" "sashwatk_onprem_compose_domain" {
  name   = format("%s-domain", var.prefix)
  memory = 8192
  vcpu   = 2

  machine = "s390-ccw-virtio"
  xml {
    xslt = file("domain_update.xsl")
  }

  disk {
    volume_id = libvirt_volume.sashwatk_onprem_compose_vda.id
  }

  disk {
    volume_id = libvirt_volume.sashwatk_onprem_compose_vdc.id
  }

  network_interface {
    network_name = "default"
    addresses    = ["192.168.122.170"]
  }

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

  depends_on = [
    libvirt_volume.sashwatk_onprem_compose_vda,
    libvirt_volume.sashwatk_onprem_compose_vdc
  ]
}

Steps to Reproduce Issue

Error

libvirt_domain.sashwatk_onprem_compose_domain: Still creating... [20s elapsed]
╷
│ Error: error defining libvirt domain: unsupported configuration: machine type 's390-ccw-virtio-noble' does not support ACPI
│ 
│   with libvirt_domain.sashwatk_onprem_compose_domain,
│   on terraform.tf line 160, in resource "libvirt_domain" "sashwatk_onprem_compose_domain":
│  160: resource "libvirt_domain" "sashwatk_onprem_compose_domain" {
│ 
╵

Additional information:

This terraform script is working on Ubuntu 22.04 and RHEL 8.4. But, not working in Ubuntu 24.04

I tried manually creating using virsh define and virt-install and it is working.

Sashwat-K commented 2 weeks ago

@dmacvicar , please help here

scabala commented 1 week ago

I think this issue is related to libvirt directly more than to this provider. I would advise to try to reproduce this error using virt-install. If you are able to do so, that's libvirt bug, not terraform-provider-libvirt one.

Sashwat-K commented 1 week ago

Hello @scabala ,

I used virt-install and I am able to bring up an instance.

I used debug mode to see what is in the XML config generated by the provider. I can see it is defining <acpi>.

<domain type="kvm">
      <name>sashwatk_onprem_crypto_passthrough-domain</name>
      <memory unit="MiB">8192</memory>
      <vcpu>2</vcpu>
      <os>
          <type machine="s390-ccw-virtio">hvm</type>
      </os>
      <features>
          <pae></pae>
          <acpi></acpi>
          <apic></apic>
      </features>
      <cpu></cpu>
      <devices>
          <disk type="volume" device="disk">
              <driver name="qemu" type="qcow2"></driver>
              <source pool="sashwatk_onprem_cryptopassthrough_pool" volume="sashwatk_onprem_crypto_passthrough-vda"></source>
              <target dev="vda" bus="virtio"></target>
          </disk>
          <disk type="volume" device="disk">
              <driver name="qemu" type="raw"></driver>
              <source pool="sashwatk_onprem_cryptopassthrough_pool" volume="sashwatk_onprem_crypto_passthrough-vdc"></source>
              <target dev="vdb" bus="virtio"></target>
          </disk>
          <interface type="network">
              <mac address="52:54:00:02:b6:df"></mac>
              <source network="default"></source>
              <model type="virtio"></model>
          </interface>
          <console>
              <target type="sclp" port="0"></target>
          </console>
          <channel type="unix">
              <target type="virtio" name="org.qemu.guest_agent.0"></target>
          </channel>
          <rng model="virtio">
              <backend model="random">/dev/urandom</backend>
          </rng>
      </devices>
  </domain>

Would you guide me where should I raise the issue?

Thank you for the response.

scabala commented 1 week ago

In that case I think this might be provider issue. Could you share the domain_update.xsl file?

Sashwat-K commented 1 week ago

Hello @scabala , The following the xsl file contents.

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output omit-xml-declaration="yes" indent="yes"/>

  <xsl:template match="node()|@*">
     <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
     </xsl:copy>
  </xsl:template>

  <xsl:template match="/domain/devices/disk/driver">
    <xsl:copy>
      <xsl:attribute name="iommu">on</xsl:attribute>
      <xsl:apply-templates select="node()|@*" />
    </xsl:copy>
  </xsl:template>

  <xsl:template match="/domain/devices">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
      <memballoon model="none"/>
    </xsl:copy>
  </xsl:template>

  <xsl:variable name="i" select="position()" />
  <xsl:template match="/domain/devices/interface">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
      <driver name="vhost" iommu="on"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="/domain/devices/controller[@type='virtio-serial']"/>
  <xsl:template match="/domain/devices/channel"/>
  <xsl:template match="/domain/devices/audio"/>
  <xsl:template match="/domain/devices/rng"/>

</xsl:stylesheet>
Sashwat-K commented 6 days ago

Hello @scabala , Did you get a chance to take a look into this issue?

scabala commented 5 days ago

Hi, I think this is caused by provider adding fields to VM definition but I haven't checked it - from you provided it looks like xsl file does not mess with ACPI so that's the only logical conclusion.

Sashwat-K commented 2 hours ago

Hello @dmacvicar , Could you please help here?