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

Support virtio-fs or replace 9P with virtio-fs in the domain filesystem directive #856

Open anthr76 opened 3 years ago

anthr76 commented 3 years ago

https://virtio-fs.gitlab.io/index.html#overview

Virtio-fs offers good performance enhancements over Virt9P and has been gaining some traction and popularity.

Per their documentation:

Available in mainline since Linux 5.4, QEMU 5.0, libvirt 6.2

What is the communities thoughts in having support in terraform-provider-libvirt?

vmorris commented 3 years ago

I would like to see this supported!

dmacvicar commented 3 years ago

I am personally interested in this, so I will likely implement it one day.

polhaghverdian commented 1 year ago

I am personally interested in this, so I will likely implement it one day.

Any more news regarding this?

dmacvicar commented 1 year ago

Follow-up the discussion in #990 :

The provider has support for filesystems.

filesystem {
  source   = "/tmp"
  target   = "tmp"
  readonly = false
}

(we also support the accessmode attribute.

The exported filesystems can be mounted inside of the guest in this way:

sudo mount -t 9p -o trans=virtio,version=9p2000.L,rw tmp /host/tmp

Looking at the docs for virtiofs:

<devices>
    ...
    <filesystem type='mount' accessmode='passthrough'>
      <driver type='virtiofs' queue='1024'/>
      <source dir='/path'/>
      <target dir='mount_tag'/>
    </filesystem>
    ...
  </devices>

So I wonder what is missing here. Is it only about the driver section?

@polhaghverdian does your XSLT work on top of HCL using the filesystem block?

polhaghverdian commented 1 year ago

@dmacvicar It's not only the driver section. You must also add a "memoryBacking" element to get virtio-fs to work. Please take a look at this link: https://libvirt.org/kbase/virtiofs.html

<domain>
  ...
  <memoryBacking>
    <source type='memfd'/>
    <access mode='shared'/>
  </memoryBacking>
  ...
  <devices>
    ...
    <filesystem type='mount' accessmode='passthrough'>
      <driver type='virtiofs' queue='1024'/>
      <source dir='/path'/>
      <target dir='mount_tag'/>
    </filesystem>
    ...
  </devices>
</domain>

Also, I have yet to try if the filesystem block works on top of the XSLT. I don't know.