q35 chipset by default

This commit is contained in:
Lukas Greve
2025-10-06 12:07:19 +02:00
parent 17a810d9c0
commit 1f1f2ce12f
2 changed files with 27 additions and 0 deletions

View File

@@ -3,6 +3,17 @@ resource "libvirt_domain" "domain" {
name = "${var.vm_name}-${count.index}"
memory = var.memory
vcpu = var.vcpu
machine = "q35"
# The chipset q35, which does not support the IDE bus, does not work with the terraform-provider-libvirt cloud-init implementation,
# which creates an ISO attached to an IDE bus by default. Workaround is implemented
# https://github.com/dmacvicar/terraform-provider-libvirt/issues/1137#issuecomment-2592329846
# A cleaner solution might be the following :
# https://github.com/dmacvicar/terraform-provider-libvirt/pull/895#issuecomment-1911167872
xml {
xslt = file("${path.module}/q35-workaround.xslt")
}
# Only include cloudinit if enabled
cloudinit = var.enable_cloudinit ? libvirt_cloudinit_disk.commoninit[count.index].id : null

View File

@@ -0,0 +1,16 @@
<?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[@device='cdrom']/target/@bus">
<xsl:attribute name="bus">
<xsl:value-of select="'sata'"/>
</xsl:attribute>
</xsl:template>
<xsl:template match="/domain/devices/disk[@device='cdrom']/alias" />
</xsl:stylesheet>