qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Skip resizing image to the same size


From: Michael Tokarev
Subject: Re: [PATCH] Skip resizing image to the same size
Date: Tue, 21 Jan 2025 00:49:12 +0300
User-agent: Mozilla Thunderbird

20.01.2025 23:17, Fahrzin Hemmati wrote:
My apologies, I saw the Signed-off-by requirement at first, but as I followed the docs I got to "git publish" and didn't realize "git publish" was actually able to send emails on my system (I don't remember setting up any SMTP settings). By that time, I forgot and thought this patch was short enough to not warrant much of a commit message.

The main practical advantage is for users that call "qemu-img resize" via scripts or other systems (like Packer in my case) that don't check the image size ahead of time. I can upstream this change into them (by using "qemu-img info —output=json ...") but I figured it would be useful to more users here.

This could trivially be added to block/io.c:bdrv_co_truncate(), as well as blockdev.c:qmp_block_resize() with a little more work. I'm not familiar with those workflows, but if needed I can do that as well.

Here's the new patch:

 From 17f5c5f03d930c4816b92b97e0e54db0725d7b94 Mon Sep 17 00:00:00 2001
From: Fahrzin Hemmati <fahhem@fahhem.com <mailto:fahhem@fahhem.com>>
Date: Mon, 20 Jan 2025 01:56:24 -0800
Subject: [PATCH] Skip resizing image to the same size

Higher-level software, such as Packer, blindly call "qemu-img resize"
even when the size is the same. This change can be pushed to those
users, but it's very cheap to check and can save many other users more
time here.

Signed-off-by: Fahrzin Hemmati <fahhem@fahhem.com <mailto:fahhem@fahhem.com>>
---
qemu-img.c | 6 ++++++
tests/qemu-iotests/061 | 8 ++++++++
tests/qemu-iotests/061.out | 9 +++++++++
3 files changed, 23 insertions(+)

diff --git a/qemu-img.c b/qemu-img.c
index 2f2fac90e8..3345c4e63f 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -4184,6 +4184,12 @@ static int img_resize(int argc, char **argv)
goto out;
}

+ if (total_size == current_size) {
+ qprintf(quiet, "Image already has the desired size.\n");
+ ret = 0;
+ goto out;
+ }


I don't think this is necessary: the actual operation is a no-op
anyway, there's no need to special-case it.

Please also refrain from changing qemu-img until my refresh
patchset is either accepted or rejected.  It was a large work
and it'd be sad to lose it.

Thanks,

/mjt



reply via email to

[Prev in Thread] Current Thread [Next in Thread]