[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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

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

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]