]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/sparc64/niagara: use int64_t for vdisk size to avoid truncation
authorDmitry Pimenov <sun4qemu@gmail.com>
Fri, 10 Jul 2026 22:23:50 +0000 (00:23 +0200)
committerPhilippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Wed, 15 Jul 2026 13:50:22 +0000 (15:50 +0200)
blk_getlength() returns int64_t, but niagara_init() stored it in an int,
truncating the if=pflash virtual-ramdisk size for images >= 2 GiB. A ~4 GiB
image truncated to 0/negative, failed the `size > 0` check, and exit(1)'d
before the CPU ran, ending with:

  qemu-system-sparc64: could not load ram disk

Signed-off-by: Dmitry Pimenov <sun4qemu@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260710222350.9185-1-sun4qemu@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
hw/sparc64/niagara.c

index 1211ecb82d4dd3ac64ffff5bdb9751c1a7325398..ad5e5945a8524981e487d453e903b791bd617ad9 100644 (file)
@@ -137,7 +137,7 @@ static void niagara_init(MachineState *machine)
        outside of the partition RAM */
     if (dinfo) {
         BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
-        int size = blk_getlength(blk);
+        int64_t size = blk_getlength(blk);
         if (size > 0) {
             memory_region_init_ram(&s->vdisk_ram, NULL, "sun4v_vdisk.ram", size,
                                    &error_fatal);