The last iteration of this work (which is now completely obsoleted) is
at
https://www.redhat.com/archives/libvir-list/2010-January/msg00302.html
These patches are intended in particular to deal with problems
creating storage volumes on pools that are located on root-squashing
NFS servers, but hopefully they are overall just "a good thing" and
will solve other as-yet-unencountered/unreported problems.
Differences from previous version of the patches:
1) For completeness, chmod is done inside virFileCreate and
virDirCreate as well as setting uid and gid.
2) Both of those functions now take an additional flag -
VIR_FILE_CREATE_ALLOW_EXIST, which does exactly what you'd think.
3) I now always attempt to set uid/gid correctly, even if not running
as root (per Serge Hallyn's suggestions during the last go around)
4) I've added a patch that uses similar logic to get the uid/gid/mode
of the directories for newly created pools correct as well.
(Previously, we'd been ignoring the permission bits of pool
definition xml).