]> git.ipfire.org Git - thirdparty/libvirt.git/commit
nodedev: handle mdevctl errors consistently
authorJonathon Jongsma <jjongsma@redhat.com>
Tue, 22 Jun 2021 19:53:35 +0000 (14:53 -0500)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 1 Jul 2021 14:34:03 +0000 (16:34 +0200)
commitbcdcaa2d08e140da387bf198224cd7a451b16954
tree78f7341125580e1896faf4e6629e404295074cac
parent5cf6f18d5daf1b995ac41fc1ed5feace83ae51cf
nodedev: handle mdevctl errors consistently

Currently, we have three different types of mdevctl errors:
 1. the command cannot be constructed ecause of unsatisfied
    preconditions
 2. the command cannot be executed due to some error
 3. the command is executed, but returns an error status

These different failures are handled differently. Some cases set an
error and return and error status, and some return a error message but
do not set an error.

This means that the caller has to check both whether the return value is
negative and whether the errmsg parameter is non-NULL before deciding
whether to report the error or not. The situation is further complicated
by the fact that there are occasional instances where mdevctl exits with
an error status but does not print an error message.  This results in
errmsg being an empty string "" (i.e. non-NULL).

Simplify the situation by ensuring that virReportError() is called for
all error conditions rather than returning an error message back to the
calling function.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
src/node_device/node_device_driver.c