29.10.2021 23:32, Eric Blake wrote:
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 <vsement...@virtuozzo.com>
---
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 <ebl...@redhat.com>
+ 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).
Hmm. But long lines printed to the terminal are wrapped by terminal
automatically, so we don't need to wrap to terminal width by hand..
--
Best regards,
Vladimir