[Kimchi-devel] [PATCH 3/3] Make sure ISO files have read permission while starting VM

Aline Manera alinefm at linux.vnet.ibm.com
Mon Feb 3 15:01:04 UTC 2014


From: Aline Manera <alinefm at br.ibm.com>

libvirt needs to have read permission on cdrom files in order to start
the virtual machine without problems.

Otherwise, the user will get the following error:

$ sudo virsh start aaaa
error: Failed to start domain aaaa
error: internal error process exited while connecting to monitor: kvm:
-drive file=/root/Fedora-Live-Desktop-x86_64-19-1.iso: could not open disk image
/root/Fedora-Live-Desktop-x86_64-19-1.iso: Permission denied

So make sure the ISO file has read permission before starting the
virtual machine.

Signed-off-by: Aline Manera <alinefm at br.ibm.com>
---
 src/kimchi/model/vms.py |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
index e9f7753..d4384a1 100644
--- a/src/kimchi/model/vms.py
+++ b/src/kimchi/model/vms.py
@@ -36,7 +36,7 @@ from kimchi.model.config import CapabilitiesModel
 from kimchi.model.templates import TemplateModel
 from kimchi.model.utils import get_vm_name
 from kimchi.screenshot import VMScreenshot
-from kimchi.utils import template_name_from_uri
+from kimchi.utils import run_setfacl_set_attr, template_name_from_uri
 
 
 DOM_STATE_MAP = {0: 'nostate',
@@ -346,6 +346,14 @@ class VMModel(object):
             vnc.remove_proxy_token(name)
 
     def start(self, name):
+        # make sure the ISO file has read permission
+        dom = self.get_vm(name, self.conn)
+        xml = dom.XMLDesc(0)
+        xpath = "/domain/devices/disk[@device='cdrom']/source/@file"
+        isofiles = xmlutils.xpath_get_text(xml, xpath)
+        for iso in isofiles:
+            run_setfacl_set_attr(iso)
+
         dom = self.get_vm(name, self.conn)
         dom.create()
 
-- 
1.7.10.4




More information about the Kimchi-devel mailing list