Is it safe to read-only mount a running bhyve image from the host?

From: Pat Maddox <pat_at_patmaddox.com>
Date: Sun, 23 Mar 2025 21:11:09 UTC
I'm running a bhyve VM (freebsd guest), and want to back up individual files from the VM. I thought I would need to use SSH, or possibly stop the VM and mount the image from the host.

However, I tried mounting the image while the VM was running... and to my surprise, it worked (I was expecting a kernel panic):

1. `mdconfig -a /vm/myvm/myvm.img`
2. `zpool import -f -o readonly=on -t -R /tmp/myvm-root -d /dev/md0p2 zroot myvm-root`

I was then able to read the files from the host _as of the time I ran `mdconfig`_. So if I add / edit / delete files in the VM, the host doesn't see it until I unmount and remount.

Is this a wonderful feature that lets me back up individual files from a running VM? Or a giant footgun that will eventually corrupt my VM image?

Pat