]> xenbits.xensource.com Git - osstest/seabios.git/commitdiff
virtio-blk: Fix incorrect type conversion in virtio_blk_op()
authorXiaofei Lee <hbuxiaofei@gmail.com>
Mon, 21 Nov 2022 14:54:10 +0000 (22:54 +0800)
committerKevin O'Connor <kevin@koconnor.net>
Tue, 22 Nov 2022 18:11:49 +0000 (13:11 -0500)
When using spdk aio bdev driver, the qemu command line like this:

qemu-system-x86_64 \
    -chardev socket,id=char0,path=/tmp/vhost.0 \
    -device vhost-user-blk-pci,id=blk0,chardev=char0 \
    ...

Boot failure message as below:

e820 map has 7 items:
  0: 0000000000000000 - 000000000009fc00 = 1 RAM
  1: 000000000009fc00 - 00000000000a0000 = 2 RESERVED
  2: 00000000000f0000 - 0000000000100000 = 2 RESERVED
  3: 0000000000100000 - 000000007ffdd000 = 1 RAM
  4: 000000007ffdd000 - 0000000080000000 = 2 RESERVED
  5: 00000000feffc000 - 00000000ff000000 = 2 RESERVED
  6: 00000000fffc0000 - 0000000100000000 = 2 RESERVED
enter handle_19:
  NULL
Booting from Hard Disk...
Boot failed: could not read the boot disk

Fixes: a05af290bac5 ("virtio-blk: split large IO according to size_max")
Acked-by: Andy Pei <andy.pei@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Xiaofei Lee <hbuxiaofei@gmail.com>
src/hw/virtio-blk.c

index 9b4a05a4c4245723b88a5d79dc2e320eb664fb46..ce3265e73440f2d015ca2a5e7b783ce456a9f3aa 100644 (file)
@@ -92,7 +92,7 @@ virtio_blk_op(struct disk_op_s *op, int write)
     u16 blk_num_max;
 
     if (vdrive->drive.blksize != 0 && max_io_size != 0)
-        blk_num_max = (u16)max_io_size / vdrive->drive.blksize;
+        blk_num_max = (u16)(max_io_size / vdrive->drive.blksize);
     else
         /* default blk_num_max if hardware doesnot advise a proper value */
         blk_num_max = 64;