On Thu, Oct 28, 2021 at 12:24:39PM +0200, Vladimir Sementsov-Ogievskiy wrote: > Let's detect block-size automatically if not specified by user: > > If both files define cluster-size, use minimum to be more precise. > If both files don't specify cluster-size, use default of 64K > If only one file specify cluster-size, just use it. > > Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]> > --- > docs/tools/qemu-img.rst | 7 +++- > qemu-img.c | 71 +++++++++++++++++++++++++++++++++++++---- > qemu-img-cmds.hx | 4 +-- > 3 files changed, 72 insertions(+), 10 deletions(-) >
Reviewed-by: Eric Blake <[email protected]> > + if (cluster_size1 > 0 && cluster_size2 > 0) { > + if (cluster_size1 == cluster_size2) { > + block_size = cluster_size1; > + } else { > + block_size = MIN(cluster_size1, cluster_size2); > + qprintf(quiet, "%s and %s have different cluster sizes: %d and > %d " > + "respectively. Using minimum as block-size for " > + "accuracy: %d. %s\n", > + fname1, fname2, cluster_size1, > + cluster_size2, block_size, note); Results in a long line; I don't know if it's worth trying to wrap it (if we had a generic utility function that took arbitrary text, then outputs it wrapped to the user's current terminal column width, I'd suggest using that instead - but that's NOT something I expect you to write, and I don't know if glib has such a utility). -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
