qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Cleber Rosa <crosa@redhat.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Prasad J Pandit" <pjp@fedoraproject.org>,
	qemu-block@nongnu.org,
	"Alistair Francis" <alistair@alistair23.me>,
	qemu-devel@nongnu.org,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
	"Alexander Bulekov" <alxndr@bu.edu>,
	"Niek Linnenbank" <nieklinnenbank@gmail.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [PATCH v2 4/9] tests/acceptance/boot_linux: Expand SD card image to power of 2
Date: Tue, 14 Jul 2020 13:55:54 +0200	[thread overview]
Message-ID: <2ad539ee-f23f-f3d5-4c2a-3962d6f0977f@amsat.org> (raw)
In-Reply-To: <20200714032226.GE2983508@localhost.localdomain>

On 7/14/20 5:22 AM, Cleber Rosa wrote:
> On Mon, Jul 13, 2020 at 08:32:04PM +0200, Philippe Mathieu-Daudé wrote:
>> In few commits we won't allow SD card images with invalid size
>> (not aligned to a power of 2). Prepare the tests: add the
>> pow2ceil() and image_pow2ceil_expand() methods and resize the
>> images (expanding) of the tests using SD cards.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>> Since v1: Addressed review comments
>> - truncate -> expand reword (Alistair Francis)
>> - expand after uncompress (Niek Linnenbank)
>> ---
>>  tests/acceptance/boot_linux_console.py | 27 +++++++++++++++++---------
>>  1 file changed, 18 insertions(+), 9 deletions(-)
>>
>> diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
>> index b7e8858c2d..8f2a6aa8a4 100644
>> --- a/tests/acceptance/boot_linux_console.py
>> +++ b/tests/acceptance/boot_linux_console.py
>> @@ -28,6 +28,18 @@
>>  except CmdNotFoundError:
>>      P7ZIP_AVAILABLE = False
>>  
>> +# round up to next power of 2
>> +def pow2ceil(x):
>> +    return 1 if x == 0 else 2**(x - 1).bit_length()
>> +
> 
> Nitpick: turn the comment into a docstring.

OK will do.

> Then, I was going to have a second nitpick about the method name, but
> realized it was following qemu-common.h's implementation.
> 
>> +# expand file size to next power of 2
>> +def image_pow2ceil_expand(path):
>> +        size = os.path.getsize(path)
>> +        size_aligned = pow2ceil(size)
>> +        if size != size_aligned:
>> +            with open(path, 'ab+') as fd:
>> +                fd.truncate(size_aligned)
>> +
> 
> Same nitpick comment about comment -> docstring here.
> 
> Either way,
> 
> Reviewed-by: Cleber Rosa <crosa@redhat.com>

Thanks!

Phil.


  reply	other threads:[~2020-07-14 11:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-13 18:32 [PATCH v2 0/9] hw/sd/sdcard: Fix CVE-2020-13253 Philippe Mathieu-Daudé
2020-07-13 18:32 ` [PATCH v2 1/9] MAINTAINERS: Cc qemu-block mailing list Philippe Mathieu-Daudé
2020-07-13 18:32 ` [PATCH v2 2/9] docs/orangepi: Add instructions for resizing SD image to power of two Philippe Mathieu-Daudé
2020-07-13 19:26   ` Alistair Francis
2020-07-13 18:32 ` [PATCH v2 3/9] tests/acceptance/boot_linux: Tag tests using a SD card with 'device:sd' Philippe Mathieu-Daudé
2020-07-13 18:58   ` Alistair Francis
2020-07-14  3:11   ` Cleber Rosa
2020-07-13 18:32 ` [PATCH v2 4/9] tests/acceptance/boot_linux: Expand SD card image to power of 2 Philippe Mathieu-Daudé
2020-07-13 19:28   ` Alistair Francis
2020-07-14  3:22   ` Cleber Rosa
2020-07-14 11:55     ` Philippe Mathieu-Daudé [this message]
2020-07-13 18:32 ` [PATCH v2 5/9] hw/sd/sdcard: Restrict Class 6 commands to SCSD cards Philippe Mathieu-Daudé
2020-07-13 18:32 ` [PATCH v2 6/9] hw/sd/sdcard: Simplify realize() a bit Philippe Mathieu-Daudé
2020-07-13 18:32 ` [PATCH v2 7/9] hw/sd/sdcard: Do not allow invalid SD card sizes Philippe Mathieu-Daudé
2020-07-13 19:30   ` Alistair Francis
2020-07-13 20:41   ` Peter Maydell
2020-07-14  9:40     ` Markus Armbruster
2020-07-13 18:32 ` [PATCH v2 8/9] hw/sd/sdcard: Update coding style to make checkpatch.pl happy Philippe Mathieu-Daudé
2020-07-13 19:34   ` Alexander Bulekov
2020-07-13 18:32 ` [PATCH v2 9/9] hw/sd/sdcard: Do not switch to ReceivingData if address is invalid Philippe Mathieu-Daudé
2020-07-14 13:37 ` [PATCH v2 0/9] hw/sd/sdcard: Fix CVE-2020-13253 Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2ad539ee-f23f-f3d5-4c2a-3962d6f0977f@amsat.org \
    --to=f4bug@amsat.org \
    --cc=alistair@alistair23.me \
    --cc=alxndr@bu.edu \
    --cc=crosa@redhat.com \
    --cc=nieklinnenbank@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=pjp@fedoraproject.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=wainersm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).