kvm-guest-drivers-windows: virtio-scsi with lio/vhost: strange block device size and LUKS problems

I am using virtio-scsi (0.1.171-1) with the LIO/vhost backend. That works great with Linux and with Windows in normal cases. With normal I mean that targetcli has an iblock object for lets say /dev/sdc7 and a vhost target with a lun that references the iblock object.

However, on Windows the disk size differs from what Linux says about /dev/sdc7.

# blockdev --getsz /dev/sdc7
122880000

Windows:

wmic diskdrive
...stuff deleted... 122865120 ...

So for some reason the physical disk in Windows has less sectors than the Linux device? Do you know what is going on here?

When I then want to use LUKS/cryptsetup and create a /dev/mapper/crypt and pass that as iblock I cannot even format that disk using Windows (works perfectly with Linux as a qemu guest).

With Windows I get tons of errors in the host dmesg:

[ 3683.403467] bio error: 00000000f33a8dcd,  err: 10
[ 3683.403612] bio error: 00000000a508ea6b,  err: 10
[ 3683.414686] bio error: 00000000f06baf1d,  err: 10
[ 3683.414767] bio error: 0000000035714712,  err: 10
[ 3683.414829] bio error: 0000000062dd8892,  err: 10
[ 3683.414883] bio error: 000000005c303a2d,  err: 10
[ 3683.414936] bio error: 0000000024d02dea,  err: 10

Any idea about that?

Regards Andreas

About this issue

Most upvoted comments

Hi all,

I reproduced this issue with kernel-5.9.16-200.fc33.x86_64 and qemu-kvm-5.1.0-8.fc33.x86_64, I tested on my laptop os.

  1. Tested with "-device vhost-scsi-pci,wwpn=naa.5001405b8504f669 ", the disk cannot be formatted.
  2. Tried test with “-device virtio-scsi-pci,id=virtio_scsi_pci0 -blockdev driver=host_device,cache.direct=off,cache.no-flush=on,filename=/dev/sdb,node-name=my_file -blockdev driver=raw,node-name=my,file=my_file -device scsi-block,drive=my” , the disk can be formatted successfully. Both tests with same disk /dev/sdb and same vioscsi driver version(virtio-win-prewhql-196).

For 1) test, detail steps as follows:

  1. sudo modprobe scsi_debug max_luns=2 dev_size_mb=1024 [peixiu@localhost scripts]$ lsscsi -gs [0:0:0:0] disk Linux scsi_debug 0190 /dev/sda /dev/sg0 1.07GB [0:0:0:1] disk Linux scsi_debug 0190 /dev/sdb /dev/sg1 1.07GB [N:0:8215:1] disk WDC PC SN730 SDBQNTY-256G-1001__1 /dev/nvme0n1 - 256GB
  2. sudo cryptsetup -v luksFormat /dev/sdb
  3. sudo cryptsetup open /dev/sdb testcrypt
  4. sudo targetcli /backstores/block create name=cryptdev dev=/dev/mapper/testcrypt
  5. targetcli /vhost create
  6. targetcli /vhost/naa.5001405b8504f669/tpg1/luns create /backstores/block/cryptdev peixiu@localhost scripts]$ sudo targetcli ls [sudo] password for peixiu: o- / … […] o- backstores … […] | o- block … [Storage Objects: 1] | | o- cryptdev … [/dev/mapper/testcrypt (1008.0MiB) write-thru activated] | | o- alua … [ALUA Groups: 1] | | o- default_tg_pt_gp … [ALUA state: Active/optimized] | o- fileio … [Storage Objects: 0] | o- pscsi … [Storage Objects: 0] | o- ramdisk … [Storage Objects: 0] o- iscsi … [Targets: 0] o- loopback … [Targets: 0] o- vhost … [Targets: 1] o- naa.5001405b8504f669 … [TPGs: 1] o- tpg1 … [naa.50014054e17673ff, no-gen-acls] o- acls … [ACLs: 0] o- luns … [LUNs: 1] o- lun0 … [block/cryptdev (/dev/mapper/testcrypt) (default_tg_pt_gp)
  7. Boot guest vm up with -device vhost-scsi-pci devices:

/usr/bin/qemu-kvm
-machine pc
-cpu host,hv_time,hv_relaxed,hv_vapic,hv_spinlocks=0x1000,hv_vpindex,hv_runtime,hv_synic,hv_reset
-bios /usr/share/seabios/bios.bin
-m 2048
-mem-prealloc
-smp 4,sockets=1,cores=4,threads=1
-uuid 15eb58c8-9272-393f-91f6-450effe1c07a
-no-user-config
-nodefaults
-rtc base=localtime
-boot menu=on
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2
-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4
-drive file=/home/win10-64.qcow2,format=qcow2,if=none,id=drive-virtio-disk0,cache=writeback
-device virtio-blk-pci,scsi=off,num-queues=4,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=0,write-cache=on
-netdev tap,id=hostnet0,vhost=on
-device e1000,netdev=hostnet0,id=net0,mac=9a:7c:03:30:d6:8d,bus=pci.0,addr=0x3
-device VGA,bus=pci.0
-device vhost-scsi-pci,wwpn=naa.5001405b8504f669
-cdrom /mnt/windows/virtio-win-prewhql-0.1-196.iso

  1. Install vioscsi driver for vhost-scsi-pci device
  2. Format the new disk through diskmgmt.msc —> format hit error.
  3. Shutdown the guest vm and replace -device vhost-scsi-pci with -virtio-scsi-pci, cannot repoduce this issue.

On latest RHEL8.4.0 host, there is not /vhost support in targetcli; On latest RHEL9 host, “targetcli /vhost create” will also hit “Could not create VhostFabricModule in configFS” error, I cannot find some way to solve this problem, so I have to use fedora to reproduce the issue. And with RHEL8/RHEL9 qemu-kvm version, under /usr/libexec/qemu-kvm --device help, I don’t find the vhost-scsi-pci device support~ @vrozenfe About this situation, if we need to file a new bug on Bugzilla to track this issue?

Thanks all~ Peixiu