Skip to content

Commit

Permalink
pyverbs: Raise proper exception class if error is returned
Browse files Browse the repository at this point in the history
PyverbsRDMAErrno is using errno as the error code, this is a
problem where the error code is meaningful and can be checked.
Moreover, errno is not meaningful in these situations.

Reviewed-by: Chen Brasch <cbrasch@amazon.com>
Reviewed-by: Yossi Leybovich <sleybo@amazon.com>
Signed-off-by: Yonatan Nachum <ynachum@amazon.com>
Signed-off-by: Firas Jahjah <firasj@amazon.com>
  • Loading branch information
YonatanNachum authored and firasj committed Jan 19, 2022
1 parent 4834dd4 commit dd31621
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pyverbs/cmid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from libc.stdint cimport uintptr_t, uint8_t
from libc.string cimport memset
import weakref

from pyverbs.pyverbs_error import PyverbsUserError, PyverbsError
from pyverbs.pyverbs_error import PyverbsUserError, PyverbsError, PyverbsRDMAError
from pyverbs.qp cimport QPInitAttr, QPAttr, ECE
from pyverbs.base import PyverbsRDMAErrno
from pyverbs.base cimport close_weakrefs
Expand Down Expand Up @@ -598,7 +598,7 @@ cdef class CMID(PyverbsCM):
init_attr = QPInitAttr()
rc = v.ibv_query_qp(self.id.qp, &attr.attr, attr_mask, &init_attr.attr)
if rc != 0:
raise PyverbsRDMAErrno('Failed to query QP')
raise PyverbsRDMAError('Failed to query QP', rc)
return attr, init_attr

def init_qp_attr(self, qp_state):
Expand Down
2 changes: 1 addition & 1 deletion pyverbs/cq.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ cdef class CQ(PyverbsCM):
while npolled < num_entries:
rc = v.ibv_poll_cq(self.cq, 1, &wc)
if rc < 0:
raise PyverbsRDMAErrno('Failed to poll CQ')
raise PyverbsRDMAError('Failed to poll CQ', -rc)
if rc == 0:
break;
npolled += 1
Expand Down
3 changes: 1 addition & 2 deletions pyverbs/qp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1385,8 +1385,7 @@ cdef class QPEx(QP):
def wr_complete(self):
rc = v.ibv_wr_complete(self.qp_ex)
if rc != 0:
raise PyverbsRDMAErrno('ibv_wr_complete failed , returned {}'.
format(rc))
raise PyverbsRDMAError('ibv_wr_complete failed.', rc)

def wr_abort(self):
v.ibv_wr_abort(self.qp_ex)
Expand Down

0 comments on commit dd31621

Please sign in to comment.