[virt-tools-list] (PATCH) Give clone priv to group 'libvirtd'

莊承恩 ChengEn.Chuang at gmail.com
Mon Dec 19 08:40:54 UTC 2011


Dear all:
   It's my first time to give a patch.
 I've been trying to clone a virtual machine, where invoking the virt-clone
from an Apache.
 However, virt-clone give me such error
*
$ virt-clone -o debian-test -n debian-test6 -f
/home/xen/domains/debian-test6.img*
*ERROR    Must be privileged to clone Xen guests*

 I don't know if there are some serious concern about the clone priv,
but more over, I really need to clone the VM without root priv,
  As a result,  I made a patch as following, which give the clove priv to
group libvirtd. ; )

--- a/virtinst/User.py
+++ b/virtinst/User.py
@@ -58,7 +58,10 @@ class User(object):
             is_xen = not conn or conn.lower()[0:3] == 'xen'
             if priv in [ self.PRIV_CLONE, self.PRIV_CREATE_DOMAIN ]:
                 if is_xen:
-                    return self._euid == 0
+                    import grp, pwd
+                    virt_grps = grp.getgrnam("libvirtd")[3]
+                    usr_name = pwd.getpwuid(self._euid)[0]
+                    return self._euid == 0 or usr_name in virt_grps
                 return True

             return self._euid == 0


-- 
Best Regards,
莊承恩,
Cheng-En, Chuang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20111219/a0897a52/attachment.htm>


More information about the virt-tools-list mailing list