vhost-scsi: new device supporting the tcm_vhost Linux kernel module
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 68 lines · Asias He
Quoted 56 lines · Michael S. Tsirkin
Quoted 44 lines · Paolo Bonzini
Ok, so here is my attempt at a vhost-scsi device. I'm creating an entirely separate device, with the common parts of virtio-scsi and vhost-scsi (actually little more than the initialization) grouped into a VirtIOSCSICommon type. The device is used simply like "-device vhost-scsi-pci,wwpn=WWPN", with all configuration done in configfs beforehand.
As expected, using a separate device finds a snag: vhost-scsi is passing force=false to
vhost_dev_init, and the BIOS does not use MSI-X so it will actually use the non-vhost implementation which is wrong. I fixed this by passing force=true; I'm not sure what that would break, but I figured "not much" since the BIOS polls and does not rely on interrupts.That makes vhost start, but it still doesn't work for me with a 3.7.2 kernel on the host. Even Nick's patches hang the guest as soon as vhost starts, and I get the same behavior with mine. (Of course with my patches the BIOS hangs and you never reach Linux; but try a BIOS without virtio-scsi support, and you'll see Linux hanging in the same way).
Here is my configuration:
cd
/sys/kernel/config/target
mkdir -p core/fileio_0/fileio
echo 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' > core/fileio_0/fileio/control echo 1 > core/fileio_0/fileio/enable
mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
cd vhost/naa.600140554cf3a18e/tpgt_0
ln -sf ../../../../../core/fileio_0/fileio/ lun/lun_0/virtual_scsi_port
echo naa.60014053226f0388 > nexusNick's patches are run with "-vhost-scsi id=vs,tpgt=0,wwpn=naa.600140554cf3a18e -device virtio-scsi-pci,vhost-scsi=vs". Perhaps I'm doing something wrong.
Another small bug I found is an ordering problem between
VHOST_SET_VRING_KICKandVHOST_SCSI_SET_ENDPOINT. Starting the vq causes a "vhost_scsi_handle_vqendpoint not set" error in dmesg. Because of this I added the first two patches, which let me doVHOST_SCSI_SET_ENDPOINTbeforeVHOST_SET_VRING_KICKbut after setting up the vring.Unfortunately, this is not enough to fix the hang. And anyway, it's probably simpler to avoid the two patches and remove this test from the
tcm_vhost.cvhost_scsi_set/clear_endpoint functions:Quoted 10 lines
mutex_lock(&vs->dev.mutex); /* Verify that ring has been setup correctly. */ for (index = 0; index < vs->dev.nvqs; ++index) { /* Verify that ring has been setup correctly. */ if (!vhost_vq_access_ok(&vs->vqs[index])) { mutex_unlock(&vs->dev.mutex); return -EFAULT; } } mutex_unlock(&vs->dev.mutex);Quoted 5 lines
Well userspace should initialize the kick eventfd to 0, it seems to init it to 1 which is why we get the error. But I think the only issue is
pr_err: vhost-net already ignores such a kick with no backend. So let's just remove it, preferably for 3.8.With following patch, the kick before backend is set is gone.
hw/virtio-pci.c static int · line 174
Quoted 7 lines
hw/virtio-pci.c +1
-1@@ -169,7 +169,7 @@ static intvirtio_pci_set_host_notifier_internal (VirtIOPCIProxy *proxy, int r = 0;if (assign) { - r =event_notifier_init (notifier, false); + r =event_notifier_init (notifier,1 );
Hmm, not the reverse?
It's also int so should be 0 not false.
Quoted 32 lines
Quoted 28 lines
--->
tcm_vhost: fixpr_erron early kickIt's OK to get kick before backend is set or after it is cleared, we can just ignore it.
Signed-off-by Michael S. Tsirkin <[email protected]>---
drivers/vhost/tcm_vhost.c +1
-3@@ -575,10 +575,8 @@ static void vhost_scsi_handle_vq(struct vhost_scsi *vs)/* Must use ioctl VHOST_SCSI_SET_ENDPOINT */ tv_tpg = vs->vs_tpg; -if (unlikely (!tv_tpg)) { -pr_err ("%s endpoint not set\n" , __func__); +if (unlikely (!tv_tpg))return ; - }mutex_lock (&vq->mutex);vhost_disable_notify (&vs->dev, vq);Signature · 1 line
Asias