Disclaimer: I have no experience with Xen, so I write with regards to ESXi, but the concepts are similar.
As for your initial question "How to test the performance difference between baremetal and VM with passthrough?":
Your setup would be as follows:
- Server-grade mainboard with Intel Xeon CPU supporting VT-d (there are alternatives, but I would keep it simple)
- A single SATA SSD of about 20 to 30 GB, depending on your OS (can also be an HDD, but it will be a bit slower)
- Your HBA with an LSI chip that supports your disks
- Two Intel NICs, could be onboard or on PCIe or both, but they should be the same model. Most boards already have them, but only some have 10Gbit ones. If you use 1Gbit, you will usually max out your performance for sequential read and write with about 4 disks or a single SSD, so I would recommend 10Gbit (also internal network is in most cases 10GBit, so this would be more interesting).
- A USB stick for the hypervisor
First, install your hypervisor onto the USB stick and configure it. Partition your SSD into 2 slices. Reboot and install your baremetal OS like you would do normally onto the first slice. Use your HBA with your other disks and configure one or more pools for your performance tests. Do those tests and write down the results. You should at least test local performance from the command line and network performance with your desired protocols (iSCSI, NFS, SMB). If possible, also test the SSD (not strictly necessary). If finished, export your pool(s).
Then, reboot (I assume you have Remote Console, so you can do this remotely), boot from your USB stick instead of the local SSD. Now use the second slice of the SSD to create a virtual file system that spans the entire slice 2. Onto this VFS, install your system from the same ISO as before, but now as a virtual machine. Setup passthrough in the hypervisor and assign one physical NIC and your HBA to this new VM. Also assign at least one virtual NIC to this VM (or more, if you want to test different types). Assign as most RAM as possible to the VM to make the conditions similar.
Then boot the VM, configure and from the VM (via VNC or SSH) import your pool(s) again. You can now do the same tests as before (local and remote) for both the physical and the virtual adapters and note any differences. Additionally, you can create a second VM, but now located on a shared NFS or iSCSI volume served from your pool. Tests on this VM tell you much about your later use case as a VM host.
Some thoughts beyond performance metrics. I kind of like this setup for several reasons:
- It is very similar to a native setup: If your server dies, you can remove all disks and plug them into any other host - if the host has a hypervisor, you can just continue to use them after you boot a small storage VM; and even if not, you already have all your data and network shares instantly ready, because everything is on the pool itself. With a traditional setup you would have to worry about the same type of RAID controller, filesystem support and would need a hypervisor (or copy the data off the virtual disks).
- It is surprisingly stable if the components play well together: if you buy good hardware, you will have a lot less problems; and even if problems arise, your data will be save (at least if you don't disable sync'ed writes, which you should never do with VMs!). And even if you would lose data for any reason, you would know it sooner than with other file systems.
- It is cheaper/more efficient: you have essentially virtualized your complete SAN, but you do not need two cases, two rackspaces, two redundant power supplies, two CPUs and so on. On the other hand, the same budget gets you much further - instead of two normal servers, you can get a beefy one with all the nice features (redundant power, HBA multipath, ), and your resources (memory, power etc) can be used as you need it.
- It is flexible: You can use the best operating system for each task. For example, use Oracle Solaris an illumos distribution like OpenSolaris, OmniOS or Nexenta for your storage VM to get all the newest features and the stability they offered for years. Then add Windows Server for Active Directory, FreeBSD or OpenBSD for internal or external routing and network tasks, various linux distributions for application software or databases and so on (if you do not want the overhead, but want the flexibility, you can try SmartOS on bare metal, although then your hypervisor choice is limited to KVM).
There are, of course, downsides. ewwhite mentioned one, hardware needs to match. Additionally:
- The performance will most likely never be as good as with a traditional setup. You can throw a good amount of money at the problem (more RAM, ZIL on SSD or NVMe, more disks, SSD disks only), but if performance is your first concern, VMs are not the best choice, ZFS is not the best choice, and both together is also not the best choice. This is the tradeoff you can't escape, you have safety and flexibility, but not maximum performance.
- You need to do some minor preparations for boot, shutdown and powerloss. Rule of thumb: your storage VM must be the first to fully boot up and the last to fully boot down. Test and time your boots to know how long you must wait before starting the other machines. Shutdown is not as critical, a premature shutdown roughly equals powerloss for the individual VMs (which is safe, as long as your application software and operating system and hypervisor and storage layer agree to only use sync writes for anything important).
- Updates can be a bit more time-consuming. Remember, if you change your storage VM, all other VMs have to be shut down (or will be shutdown forcefully). So plan some more downtime (this is of course the same as with a physical setup where your SAN would be down for updates). Also you should test any updates to the core functionality (hypervisor, network drivers, virtual network drivers, storage drivers, storage VM) thoroughly, because you don't want a bug that results in flaky NFS behaviour at random times.
- You are still doing backups, right? ;)