Avoiding I/O storms from VMs via blkdeviotune

Anyone else tried to use blkdeviotune on kvm VMs to avoid overloading IO writes on sub-optimal SSDs?

My current pair of 1TB SSDs that I use for VMs aren’t well matched and high IO causes errors as I’ve got a Samsung 850 EVO and a Crucial BX100. Given current SSD prices I can’t replace the BX100 at present and my goal is to move the VMs to NVMe when I can get better pricing.

I’ve found that I can avoid an write storm by restricting the IO via blkdeviotune, for example

virsh blkdeviotune MyVM /dev/zvol/ssd-pool/VMs/MyVM-zx12ab --write-iops-sec 1000 --write-bytes-sec 52428800

Now I don’t know of anyway to persist this under TrueNas, or to run the script on VM Startup. Has anyone else tried this and could perhaps provide guidance.

You could set the VM not to auto-start and run virsh blkdeviotune MyVM /dev/zvol/ssd-pool/VMs/MyVM-zx12ab --config --write-iops-sec 1000 --write-bytes-sec 52428800, followed by midclt call vm.start <VM ID of MyVM> inside a post-init startup script.

One option, but the change isn’t picked up if I modify or restart the VM via the TrueNas WebUI.

It would be great it we had an advanced mode for extended libvirt options, especially around storage and networking, or a way to persist these changes from the command line.