Change in vdsm[master]: hostdev: change ownership for passthrough USB devices

nsoffer at redhat.com nsoffer at redhat.com
Mon Sep 21 08:39:04 UTC 2015


Nir Soffer has posted comments on this change.

Change subject: hostdev: change ownership for passthrough USB devices
......................................................................


Patch Set 17:

(2 comments)

https://gerrit.ovirt.org/#/c/44679/17/vdsm/supervdsmServer
File vdsm/supervdsmServer:

Line 414:         except OSError as e:
Line 415:             if e.errno == errno.ENOENT:
Line 416:                 self.log.warning('Rule %s missing', rule_file)
Line 417:             else:
Line 418:                 self.log.error("Failed to remove rule %s: %s", rule_file, e)
If we failed to remove the rule with errno != ENOENT, there is no point to continue, since triggering will apply the rule again.

So lets use:

    if e.errno != errno.ENOENT:
        raise
    warn about missing file...
Line 419: 
Line 420:         self.log.debug('Changing ownership (to root:root) of device '
Line 421:                        'bus: %s, device:: %s', bus, device)
Line 422:         device_path = _USB_DEVICE_PATH % (int(bus), int(device))


Line 424:         rc, out, err = utils.execCmd(cmd)
Line 425:         if err:
Line 426:             raise OSError(errno.EINVAL, 'Could not change ownership'
Line 427:                           'out %s\nerr %s' % (out, err))
Line 428:         else:
Remove the else - we should follow the return golden path rule:

    some code
    if failed:
        raise 

    more code
    ...
Line 429:             # It's possible that the device was in input class or had rule
Line 430:             # matched against it, trigger to make sure everything is fine.
Line 431:             self._udevTrigger(attr_matches=(('busnum', int(bus)),
Line 432:                                             ('devnum', int(device))))


-- 
To view, visit https://gerrit.ovirt.org/44679
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I1f72f63186187254cd4aded0a2e6c396001ca28b
Gerrit-PatchSet: 17
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Martin Polednik <mpolednik at redhat.com>
Gerrit-Reviewer: Michal Skrivanek <michal.skrivanek at redhat.com>
Gerrit-Reviewer: Michal Skrivanek <mskrivan at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczewski at gmail.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list