Sandro Bonazzola has uploaded a new change for review. Change subject: packaging: setup: allow boot from host's cdrom ......................................................................
packaging: setup: allow boot from host's cdrom Allow boot from host's cdrom. Change-Id: I71d3f503ce6b49d11a297cd010b182b5b2804065 Bug-Url: https://bugzilla.redhat.com/1082028 Signed-off-by: Sandro Bonazzola <sbona...@redhat.com> --- M src/plugins/ovirt-hosted-engine-setup/vm/boot_cdrom.py 1 file changed, 45 insertions(+), 17 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup refs/changes/01/26701/1 diff --git a/src/plugins/ovirt-hosted-engine-setup/vm/boot_cdrom.py b/src/plugins/ovirt-hosted-engine-setup/vm/boot_cdrom.py index f944dfa..822b869 100644 --- a/src/plugins/ovirt-hosted-engine-setup/vm/boot_cdrom.py +++ b/src/plugins/ovirt-hosted-engine-setup/vm/boot_cdrom.py @@ -1,6 +1,6 @@ # # ovirt-hosted-engine-setup -- ovirt hosted engine setup -# Copyright (C) 2013 Red Hat, Inc. +# Copyright (C) 2013-2014 Red Hat, Inc. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -24,6 +24,10 @@ import gettext +import grp +import os +import pwd +import stat from otopi import util @@ -46,23 +50,47 @@ super(Plugin, self).__init__(context=context) def _check_iso_readable(self, filepath): - try: - self.execute( + realpath = os.path.realpath(filepath) + file_stat = os.stat(realpath) + readable = False + if stat.S_ISBLK(file_stat.st_mode): + # Host device must be available to qemu user + if ( + (file_stat.st_mode & stat.S_IROTH) or ( - self.command.get('sudo'), - '-u', - 'vdsm', - '-g', - 'kvm', - 'test', - '-r', - filepath, - ), - raiseOnError=True - ) - readable = True - except RuntimeError: - readable = False + file_stat.st_mode & stat.S_IRGRP and + file_stat.st_gid in [ + g.gr_gid + for g in grp.getgrall() + if 'qemu' in g.gr_mem + ] + ) or + ( + file_stat.st_mode & stat.S_IRUSR and + file_stat.st_uid == pwd.getpwnam('qemu').pw_uid + ) + ): + readable = True + else: + # iso images may be on existing ISO domains and must be readable + # by vdsm user + try: + self.execute( + ( + self.command.get('sudo'), + '-u', + 'vdsm', + '-g', + 'kvm', + 'test', + '-r', + realpath, + ), + raiseOnError=True + ) + readable = True + except RuntimeError: + readable = False return readable @plugin.event( -- To view, visit http://gerrit.ovirt.org/26701 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I71d3f503ce6b49d11a297cd010b182b5b2804065 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-hosted-engine-setup Gerrit-Branch: master Gerrit-Owner: Sandro Bonazzola <sbona...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches