Dan Kenigsberg has submitted this change and it was merged.

Change subject: tc_wrapper: Fix errno reporting
......................................................................


tc_wrapper: Fix errno reporting

When tc fails in and of itself, it returns with code 1. When it is
due to kernel error as relayed by the kernel in rtnl_talk, it sets
the return code to 2 and prints like so:

    fprintf(stderr, "RTNETLINK answers: %s\n",
            strerror(-err->error));

Thus, if wrapper._process_request is to raise proper errno
verifiable error codes in its TrafficControlExceptions, it is
necessary that we do the inverse process, strerror -> errno.

After this patch:

When deleting a non-existing class as root:

In [6]: wrapper._process_request(['class', 'del', 'dev', 'em1',
                                  'classid', '1:2'])
TrafficControlException:
(2, 'RTNETLINK answers: No such file or directory\n',
['/usr/sbin/tc', 'class', 'del', 'dev', 'em1', 'classid', '1:2'])

And as regular user:
In [49]: wrapper._process_request(['class', 'del', 'dev', 'em1',
                                   'classid', '1:2']
TrafficControlException:
(1, 'RTNETLINK answers: Operation not permitted\n',
['/usr/sbin/tc', 'class', 'del', 'dev', 'em1', 'classid', '1:2'])

Both being the correct errno codes.

Change-Id: I0483b694d805e8f7d686146c3545b93dc8962d76
Signed-off-by: Antoni S. Puimedon <[email protected]>
Reviewed-on: http://gerrit.ovirt.org/30459
Reviewed-by: Dan Kenigsberg <[email protected]>
---
M vdsm/network/tc/__init__.py
M vdsm/network/tc/_wrapper.py
2 files changed, 11 insertions(+), 4 deletions(-)

Approvals:
  Antoni Segura Puimedon: Verified
  Dan Kenigsberg: Looks good to me, approved



-- 
To view, visit http://gerrit.ovirt.org/30459
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0483b694d805e8f7d686146c3545b93dc8962d76
Gerrit-PatchSet: 9
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <[email protected]>
Gerrit-Reviewer: Antoni Segura Puimedon <[email protected]>
Gerrit-Reviewer: Dan Kenigsberg <[email protected]>
Gerrit-Reviewer: [email protected]
Gerrit-Reviewer: oVirt Jenkins CI Server
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to