Commit 715ade55 authored by Vladimir Bashkirtsev's avatar Vladimir Bashkirtsev

Allow custom sized SD cards to be used by QEMU

parent cea175b2
......@@ -8,6 +8,7 @@ i386:
tar xf qemu-5.2.0.tar.xz
patch -Np1 -d qemu-5.2.0 < qemu-5.2.0-reduce_default_code_gen_buffer.patch
patch -Np1 -d qemu-5.2.0 < qemu-5.2.0-allow_custom_size_sd.patch
cd qemu-5.2.0 && ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --target-list=i386-softmmu,i386-linux-user
$(MAKE) -C qemu-5.2.0
$(MAKE) -C qemu-5.2.0 check
......@@ -29,6 +30,7 @@ x86_64:
tar xf qemu-5.2.0.tar.xz
patch -Np1 -d qemu-5.2.0 < qemu-5.2.0-reduce_default_code_gen_buffer.patch
patch -Np1 -d qemu-5.2.0 < qemu-5.2.0-allow_custom_size_sd.patch
cd qemu-5.2.0 && ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --target-list=x86_64-softmmu,x86_64-linux-user
$(MAKE) -C qemu-5.2.0
$(MAKE) -C qemu-5.2.0 check
......@@ -54,6 +56,7 @@ arm:
tar xf qemu-5.2.0.tar.xz
patch -Np1 -d qemu-5.2.0 < qemu-5.2.0-reduce_default_code_gen_buffer.patch
patch -Np1 -d qemu-5.2.0 < qemu-5.2.0-allow_custom_size_sd.patch
cd qemu-5.2.0 && ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --target-list=arm-softmmu,arm-linux-user,armeb-linux-user
$(MAKE) -C qemu-5.2.0
$(MAKE) -C qemu-5.2.0 check
......@@ -79,6 +82,7 @@ aarch64:
tar xf qemu-5.2.0.tar.xz
patch -Np1 -d qemu-5.2.0 < qemu-5.2.0-reduce_default_code_gen_buffer.patch
patch -Np1 -d qemu-5.2.0 < qemu-5.2.0-allow_custom_size_sd.patch
cd qemu-5.2.0 && ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --target-list=aarch64-softmmu,aarch64-linux-user,aarch64_be-linux-user
$(MAKE) -C qemu-5.2.0
$(MAKE) -C qemu-5.2.0 check
......
diff -uNr qemu-5.2.0/hw/sd/sd.c qemu-5.2.0-allow_custom_size_sd/hw/sd/sd.c
--- qemu-5.2.0/hw/sd/sd.c 2020-12-09 03:29:44.000000000 +1030
+++ qemu-5.2.0-allow_custom_size_sd/hw/sd/sd.c 2022-03-29 03:07:56.808634756 +1030
@@ -32,7 +32,6 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
-#include "qemu/cutils.h"
#include "hw/irq.h"
#include "hw/registerfields.h"
#include "sysemu/block-backend.h"
@@ -2153,35 +2152,11 @@
}
if (sd->blk) {
- int64_t blk_size;
-
if (blk_is_read_only(sd->blk)) {
error_setg(errp, "Cannot use read-only drive as SD card");
return;
}
- blk_size = blk_getlength(sd->blk);
- if (blk_size > 0 && !is_power_of_2(blk_size)) {
- int64_t blk_size_aligned = pow2ceil(blk_size);
- char *blk_size_str;
-
- blk_size_str = size_to_str(blk_size);
- error_setg(errp, "Invalid SD card size: %s", blk_size_str);
- g_free(blk_size_str);
-
- blk_size_str = size_to_str(blk_size_aligned);
- error_append_hint(errp,
- "SD card size has to be a power of 2, e.g. %s.\n"
- "You can resize disk images with"
- " 'qemu-img resize <imagefile> <new-size>'\n"
- "(note that this will lose data if you make the"
- " image smaller than it currently is).\n",
- blk_size_str);
- g_free(blk_size_str);
-
- return;
- }
-
ret = blk_set_perm(sd->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE,
BLK_PERM_ALL, errp);
if (ret < 0) {
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment