Re: [Qemu-devel] [PATCH 1/1] Add vhost-pci-blk driver

2018-11-05 Thread Vitaly Mayatskih
> >  configure  | 10 +++
> >  default-configs/virtio.mak |  1 +
> >  hw/block/Makefile.objs |  1 +
> >  hw/virtio/virtio-pci.c | 60 ++
> >  hw/virtio/virtio-pci.h | 19 
> >  5 files changed, 91 insertions(+)
> >
>
> I think that you haven't sent all the files because at least some of the files
> are missing.
> For example the build fails with missing 'hw/virtio/vhost-blk.h'
>
> Also I don't see here any mention on how the qemu passes to the in-kernel
> driver, the file which the in-kernel driver is supposed to read/write.
> I don't think that generic vhost backend have this functionality because till
> now it was limited to iscsi, and thus qemu just passed to the kernel, the wwpn
> of the device.

Yes, I screwed it up and forgot two files. Will resend shortly.

Thanks!

-- 
wbr, Vitaly



Re: [Qemu-devel] [PATCH 1/1] Add vhost-pci-blk driver

2018-11-05 Thread Maxim Levitsky
On Fri, 2018-11-02 at 19:15 +, Vitaly Mayatskikh wrote:
> This driver uses the kernel-mode acceleration for virtio-blk and
> allows to get a near bare metal disk performance inside a VM.
> 
> Signed-off-by: Vitaly Mayatskikh 
> ---
>  configure  | 10 +++
>  default-configs/virtio.mak |  1 +
>  hw/block/Makefile.objs |  1 +
>  hw/virtio/virtio-pci.c | 60 ++
>  hw/virtio/virtio-pci.h | 19 
>  5 files changed, 91 insertions(+)
> 

I think that you haven't sent all the files because at least some of the files
are missing.
For example the build fails with missing 'hw/virtio/vhost-blk.h'

Also I don't see here any mention on how the qemu passes to the in-kernel
driver, the file which the in-kernel driver is supposed to read/write.
I don't think that generic vhost backend have this functionality because till
now it was limited to iscsi, and thus qemu just passed to the kernel, the wwpn
of the device.

Best regards,
   Maxim Levitsky




[Qemu-devel] [PATCH 1/1] Add vhost-pci-blk driver

2018-11-02 Thread Vitaly Mayatskikh
This driver uses the kernel-mode acceleration for virtio-blk and
allows to get a near bare metal disk performance inside a VM.

Signed-off-by: Vitaly Mayatskikh 
---
 configure  | 10 +++
 default-configs/virtio.mak |  1 +
 hw/block/Makefile.objs |  1 +
 hw/virtio/virtio-pci.c | 60 ++
 hw/virtio/virtio-pci.h | 19 
 5 files changed, 91 insertions(+)

diff --git a/configure b/configure
index 46ae1e8c76..787bc780da 100755
--- a/configure
+++ b/configure
@@ -371,6 +371,7 @@ vhost_crypto="no"
 vhost_scsi="no"
 vhost_vsock="no"
 vhost_user=""
+vhost_blk=""
 kvm="no"
 hax="no"
 hvf="no"
@@ -869,6 +870,7 @@ Linux)
   vhost_crypto="yes"
   vhost_scsi="yes"
   vhost_vsock="yes"
+  vhost_blk="yes"
   QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers 
$QEMU_INCLUDES"
   supported_os="yes"
   libudev="yes"
@@ -1263,6 +1265,10 @@ for opt do
   ;;
   --enable-vhost-vsock) vhost_vsock="yes"
   ;;
+  --disable-vhost-blk) vhost_blk="no"
+  ;;
+  --enable-vhost-blk) vhost_blk="yes"
+  ;;
   --disable-opengl) opengl="no"
   ;;
   --enable-opengl) opengl="yes"
@@ -6000,6 +6006,7 @@ echo "vhost-crypto support $vhost_crypto"
 echo "vhost-scsi support $vhost_scsi"
 echo "vhost-vsock support $vhost_vsock"
 echo "vhost-user support $vhost_user"
+echo "vhost-blk support $vhost_blk"
 echo "Trace backends$trace_backends"
 if have_backend "simple"; then
 echo "Trace output file $trace_file-"
@@ -6461,6 +6468,9 @@ fi
 if test "$vhost_user" = "yes" ; then
   echo "CONFIG_VHOST_USER=y" >> $config_host_mak
 fi
+if test "$vhost_blk" = "yes" ; then
+  echo "CONFIG_VHOST_BLK=y" >> $config_host_mak
+fi
 if test "$blobs" = "yes" ; then
   echo "INSTALL_BLOBS=yes" >> $config_host_mak
 fi
diff --git a/default-configs/virtio.mak b/default-configs/virtio.mak
index 1304849018..765c0a2a04 100644
--- a/default-configs/virtio.mak
+++ b/default-configs/virtio.mak
@@ -1,5 +1,6 @@
 CONFIG_VHOST_USER_SCSI=$(call land,$(CONFIG_VHOST_USER),$(CONFIG_LINUX))
 CONFIG_VHOST_USER_BLK=$(call land,$(CONFIG_VHOST_USER),$(CONFIG_LINUX))
+CONFIG_VHOST_BLK=$(CONFIG_LINUX)
 CONFIG_VIRTIO=y
 CONFIG_VIRTIO_9P=y
 CONFIG_VIRTIO_BALLOON=y
diff --git a/hw/block/Makefile.objs b/hw/block/Makefile.objs
index 53ce5751ae..857ce823fc 100644
--- a/hw/block/Makefile.objs
+++ b/hw/block/Makefile.objs
@@ -14,3 +14,4 @@ obj-$(CONFIG_SH4) += tc58128.o
 obj-$(CONFIG_VIRTIO_BLK) += virtio-blk.o
 obj-$(CONFIG_VIRTIO_BLK) += dataplane/
 obj-$(CONFIG_VHOST_USER_BLK) += vhost-user-blk.o
+obj-$(CONFIG_VHOST_BLK) += vhost-blk.o
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index a954799267..ec00b54424 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -2060,6 +2060,63 @@ static const TypeInfo vhost_user_blk_pci_info = {
 };
 #endif
 
+#ifdef CONFIG_VHOST_BLK
+/* vhost-blk */
+
+static Property vhost_blk_pci_properties[] = {
+DEFINE_PROP_UINT32("class", VirtIOPCIProxy, class_code, 0),
+DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
+   DEV_NVECTORS_UNSPECIFIED),
+DEFINE_PROP_END_OF_LIST(),
+};
+
+static void vhost_blk_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
+{
+VHostBlkPCI *dev = VHOST_BLK_PCI(vpci_dev);
+DeviceState *vdev = DEVICE(>vdev);
+
+if (vpci_dev->nvectors == DEV_NVECTORS_UNSPECIFIED) {
+vpci_dev->nvectors = dev->vdev.num_queues + 1;
+}
+
+qdev_set_parent_bus(vdev, BUS(_dev->bus));
+object_property_set_bool(OBJECT(vdev), true, "realized", errp);
+}
+
+static void vhost_blk_pci_class_init(ObjectClass *klass, void *data)
+{
+DeviceClass *dc = DEVICE_CLASS(klass);
+VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
+PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
+
+set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
+dc->props = vhost_blk_pci_properties;
+k->realize = vhost_blk_pci_realize;
+pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
+pcidev_k->device_id = PCI_DEVICE_ID_VIRTIO_BLOCK;
+pcidev_k->revision = VIRTIO_PCI_ABI_VERSION;
+pcidev_k->class_id = PCI_CLASS_STORAGE_SCSI;
+}
+
+static void vhost_blk_pci_instance_init(Object *obj)
+{
+VHostBlkPCI *dev = VHOST_BLK_PCI(obj);
+
+virtio_instance_init_common(obj, >vdev, sizeof(dev->vdev),
+TYPE_VHOST_BLK);
+object_property_add_alias(obj, "bootindex", OBJECT(>vdev),
+  "bootindex", _abort);
+}
+
+static const TypeInfo vhost_blk_pci_info = {
+.name   = TYPE_VHOST_BLK_PCI,
+.parent = TYPE_VIRTIO_PCI,
+.instance_size  = sizeof(VHostBlkPCI),
+.instance_init  = vhost_blk_pci_instance_init,
+.class_init = vhost_blk_pci_class_init,
+};
+#endif
+
 /* virtio-scsi-pci */
 
 static Property virtio_scsi_pci_properties[] = {
@@ -2723,6 +2780,9 @@ static void virtio_pci_register_types(void)
 #ifdef CONFIG_VHOST_VSOCK
 type_register_static(_vsock_pci_info);
 #endif
+#ifdef