block/copy-before-write: implement cbw-timeout option
commit6db7fd1ca980f8dd2fd082f13613166e170afd05
authorVladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
Thu, 7 Apr 2022 13:27:25 +0000 (7 16:27 +0300)
committerVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Wed, 29 Jun 2022 07:56:12 +0000 (29 10:56 +0300)
tree0ba7ed482f029250b27470ac63e5c52b35bda546
parent15df6e698719505570f8532772c2b08cb278a45a
block/copy-before-write: implement cbw-timeout option

In some scenarios, when copy-before-write operations lasts too long
time, it's better to cancel it.

Most useful would be to use the new option together with
on-cbw-error=break-snapshot: this way if cbw operation takes too long
time we'll just cancel backup process but do not disturb the guest too
much.

Note the tricky point of realization: we keep additional point in
bs->in_flight during block_copy operation even if it's timed-out.
Background "cancelled" block_copy operations will finish at some point
and will want to access state. We should care to not free the state in
.bdrv_close() earlier.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
  [vsementsov: use bdrv_inc_in_flight()/bdrv_dec_in_flight() instead of
   direct manipulation on bs->in_flight]
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
block/copy-before-write.c
qapi/block-core.json