vhost-user-blk: Implement reconnection during realize
commita527e312b59ac382cb84af4b91f517a846f50705
authorKevin Wolf <kwolf@redhat.com>
Wed, 9 Jun 2021 15:46:58 +0000 (9 08:46 -0700)
committerKevin Wolf <kwolf@redhat.com>
Wed, 30 Jun 2021 11:21:22 +0000 (30 13:21 +0200)
tree7cef671d37a79405677c7cba676a509e23291a09
parent415fc2940b1536061c904bf192e097c27d3a787b
vhost-user-blk: Implement reconnection during realize

Commit dabefdd6 removed code that was supposed to try reconnecting
during .realize(), but actually just crashed and had several design
problems.

This adds the feature back without the crash in simple cases while also
fixing some design problems: Reconnection is now only tried if there was
a problem with the connection and not an error related to the content
(which would fail again the same way in the next attempt). Reconnection
is limited to three attempts (four with the initial attempt) so that we
won't end up in an infinite loop if a problem is permanent. If the
backend restarts three times in the very short time window of device
initialisation, we have bigger problems and erroring out is the right
course of action.

In the case that a connection error occurs and we reconnect, the error
message is printed using error_report_err(), but otherwise ignored.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20210609154658.350308-8-kwolf@redhat.com>
Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
hw/block/vhost-user-blk.c