(This will get committed as two separate parts, but both are included in this review for easier review)
Instead of relying on the boot path to setup the kenv, use libbe which should divine the same information from the dataset booted at / and scurrying through ZPOOL_CONFIG_VDEV_TREE.
This is completely untested, but in theory it should work.