This patch is a straightforward refactoring of libnbd’s nbdcopy program, and not very interesting. However I have plans for nbdcopy (see full todo below). I would like to use this utility for virt-v2v as a replacement for ”qemu-img convert”. qemu-img has caused us a series of problems: - change in zeroing behaviour caused a big performance regression - qemu-img reads extents up-front which is problematic when reading from VDDK because the progress counter sticks at 0% for ages - no support for NBD multi-conn, leaving a lot of performance on the table - inflexible progress bar The idea is to make nbdcopy into a very customizable and highly efficient copying tool [it obviously is not right now]. Rich. ---------------------------------------------------------------------- progress bar - write to fd - machine-readable threads - how many copying threads do we create read order, write order - allow reads/writes in order or out of order multi-conn - control it separately at either end extents - do we check them at all? - do we check them before or as we go along? (probably best to always check as we go along?) - do we zero up front or as we go along? (best always as we go along?) synchronous - some kind of deliberately linear mode, eg for pipes - with FUA on writes --from / --to - send data from/to an NBD server as subprocess - can we do this? block size - force requests to be aligned to block size support for copying ranges - offset and size - in a later version, since this is hard to get right io_uring(?) - in nbdcopy - in libnbd - later version - hard, needs benchmarking to prove it is worthwhile