dmacvicar / terraform-provider-libvirt

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

Is terraform libvirt provider supports attaching SRIOV VF's #783

Open MaheshTR033 opened 3 years ago

MaheshTR033 commented 3 years ago

System Information

HP Bare Metal Server

Linux distribution

NAME="openSUSE Leap" VERSION="15.1"

Terraform version

Terraform v0.12.28

Provider and libvirt versions

# ./terraform-provider-libvirt -version
./terraform-provider-libvirt 0.6.0+git.1569597268.1c8597df
Compiled against library: libvirt 4.0.0
Using library: libvirt 5.1.0
Running hypervisor: QEMU 3.1.1
Running against daemon: 5.1.0

======================

Is passthrough option in terraform supports SRIOV. Can you please share example configuration file in terraform.

When SRIOV vf is attached using libvirt/virsh commands, output is as follows.

# virsh domiflist guest
Interface   Type      Source      Model    MAC
---------------------------------------------------------------
 -           hostdev   -           -        52:54:00:50:7b:52

In case, SRIOV is not supported. Can we use xslt.

<interface type='hostdev'>
 <source>
  <address type='pci' domain='0' bus='33' slot='3' function='1'/>
 </source>
</interface>

Looks like following xslt is working.

# cat /root/terraform/nicmodel.xsl
<?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">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
        <interface type="hostdev" managed="yes">
         <driver name="vfio"/>
          <source>
            <address type="pci" domain="0x0000" bus="0x21" slot="0x02" function="0x06"/>
          </source>
         </interface>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
MalloZup commented 3 years ago

@MaheshTR033 If you want to send a documentation PR about this, I'm ok. otherwise I do think having an issue ad doc is an anti-pattern for maintainers.