On Tue, Jul 19, 2022 at 04:45:53PM +0100, Richard W.M. Jones wrote:
qemu-img has new(?) behaviour that breaks some things:
$ nbdkit linuxdisk ~/d/nbdkit --filter=checkwrite --run 'qemu-img convert "$uri" "$uri"' nbdkit: linuxdisk.0: error: data written does not match expected qemu-img: nbd://localhost:10809: error while converting raw: Failed to clear the new image's first sector: Input/output error
I understand why this happens, but also it's kind of a bug ... We should probably modify checkwrite to handle this, but it's rather complicated.
I see you fixed this in the meantime (commit c7420c04), but repeating the context here: qemu-img convert normally assumes that source and destination are not the same, and assumes that when creating a destination on an existing block device (such as NBD), it must wipe any pre-existing signature in the first sector of the destination to make sure we don't probe an incorrect format. It is this attempt to wipe that writes different data; using 'qemu-img convert -n' skips the creation step and therefore the wipe. Perhaps qemu-img convert could be taught to special-case when -n is not in use by first reading the destination to see if it reads identically and only do the wipe if not; but that's asking a lot when we can solve it by using -n. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org