[libvirt] FIrst approximation of creating volumes directly with desired uid

Laine Stump laine at laine.org
Mon Jan 4 06:42:51 UTC 2010

|I've made an attempt to create storage volumes directly with the 
desired uid/gid (by forking a new process, calling setuid/setgid in that 
process, and then creating the file). Since it's sure to get ripped 
apart, I've put it up on gitorious rather than sending patches to the list.

The repository is:


and the branch is (in a quite non-sequiter fashion) "xml2xmltest"

Only the last 3 commits on the branch are related to this topic.

The first adds uid and gid args to virRun (and all related functions) so 
that new processes can be run as a different user. This is necessary for 
the cases where we call an external program to create the image 
(qemu-img, for example).

The second commit adds two new functions to util.c: virFileCreate and 
virDirCreate. In the case that the current process is running as root, 
and the caller has requested a different uid or gid for the new 
file/directory, these functions do the proper fork dance to get this 
done and return proper status to the caller.

The third commit uses the enhanced virRun, and the two new functions to 
change the way that storage volumes are created.

I've noted some of my concerns about doing things this way in a bugzilla 
report about the problem I'm trying to fix:



More information about the libvir-list mailing list