[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes
From: |
Alistair Francis |
Subject: |
Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes |
Date: |
Thu, 9 Jul 2020 09:17:33 -0700 |
On Thu, Jul 9, 2020 at 7:35 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> On 7/9/20 4:15 PM, Peter Maydell wrote:
> > On Thu, 9 Jul 2020 at 14:56, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> >>
> >> On 7/7/20 10:29 PM, Niek Linnenbank wrote:
> >>> So I manually copy & pasted the change into hw/sd/sd.c to test it.
> >>> It looks like the check works, but my concern is that with this change,
> >>> we will be getting this error on 'off-the-shelf' images as well.
> >>> For example, the latest Raspbian image size also isn't a power of two:
> >>>
> >>> $ ./arm-softmmu/qemu-system-arm -M raspi2 -sd
> >>> ~/Downloads/2020-05-27-raspios-buster-lite-armhf.img -nographic
> >>> WARNING: Image format was not specified for
> >>> '/home/me/Downloads/2020-05-27-raspios-buster-lite-armhf.img' and
> >>> probing guessed raw.
> >>> Automatically detecting the format is dangerous for raw images,
> >>> write operations on block 0 will be restricted.
> >>> Specify the 'raw' format explicitly to remove the restrictions.
> >>> qemu-system-arm: Invalid SD card size: 1.73 GiB (expecting at least 2 GiB)
> >>>
> >>> If we do decide that the change is needed, I would like to propose that
> >>> we also give the user some instructions
> >>> on how to fix it, maybe some 'dd' command?
> >>
> >> On POSIX we can suggest to use 'truncate -s 2G' from coreutils.
> >> This is not in the default Darwin packages.
> >> On Windows I have no clue.
> >
> > dd/truncate etc won't work if the image file is not raw (eg if
> > it's qcow2).
>
> Good catch...
>
> > The only chance you have of something that's actually
> > generic would probably involve "qemu-img resize". But I'm a bit
> > wary of having an error message that recommends that, because
> > what if we got it wrong?
>
> I am not sure what to recommend then.
>
> Would that work as hint?
>
> qemu-system-arm -M raspi2 -sd ./buster-lite-armhf.img
> qemu-system-arm: Invalid SD card size: 1.73 GiB
> SD card size has to be a power of 2, e.g. 2GiB.
That sounds good to me. That's enough for a user to figure out the next step.
If you want you could also add: "qemu-img might be able to help." or
something like that.
Alistair
- Re: [PATCH 1/2] tests/acceptance/boot_linux: Truncate SD card image to power of 2, (continued)
- [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes, Philippe Mathieu-Daudé, 2020/07/07
- Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes, Alistair Francis, 2020/07/07
- Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes, Peter Maydell, 2020/07/07
- Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes, Philippe Mathieu-Daudé, 2020/07/07
- Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes, Niek Linnenbank, 2020/07/07
- Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes, Philippe Mathieu-Daudé, 2020/07/09
- Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes, Peter Maydell, 2020/07/09
- Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes, Philippe Mathieu-Daudé, 2020/07/09
- Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes,
Alistair Francis <=
- Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes, Peter Maydell, 2020/07/10
- Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes, Niek Linnenbank, 2020/07/09
- Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes, Kevin Wolf, 2020/07/10
- Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes, Peter Maydell, 2020/07/10
- Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes, Kevin Wolf, 2020/07/10
- Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes, Peter Maydell, 2020/07/10
- Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes, Niek Linnenbank, 2020/07/09