Skip to contentSkip to conversation

block: Always compile virtio-blk dataplane

PATCH Applied Fam Zheng 3 participants 6 messages Sep 10, 2014 – Sep 19, 2014

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

v3 cover block: Always compile virtio-blk dataplane

v3: Fix -ENOBUFS.
v2: Import virtio_vring.h.

Fam Zheng (3):
virtio: Import virtio_vring.h
vring: Better error handling if num is too large
block: Always compile virtio-blk dataplane

 configure                           |  21 +----
 hw/block/Makefile.objs              |   2 +-
 hw/block/virtio-blk.c               |  20 +----
 hw/net/vhost_net.c                  |   2 +-
 hw/virtio/Makefile.objs             |   2 +-
 hw/virtio/dataplane/vring.c         |   3 +-
 include/hw/virtio/dataplane/vring.h |   2 +-
 include/hw/virtio/virtio-blk.h      |   2 -
 include/hw/virtio/virtio_ring.h     | 167 ++++++++++++++++++++++++++++++++++++
 linux-headers/linux/vhost.h         |   2 +-
 10 files changed, 178 insertions(+), 45 deletions(-)
 create mode 100644 include/hw/virtio/virtio_ring.h
Signature · 1 line
1.9.3
author
#1 lore raw

PATCH v3 1/3 virtio: Import virtio_vring.h

This header has no further dependencies. It only has some stable data types and primitive functions, so we can copy it to include/hw/virtio in order to allow vring code (and its user virtio-blk dataplane) to be built unconditionally, even for cross compiling.

---
 hw/net/vhost_net.c                  |   2 +-
 include/hw/virtio/dataplane/vring.h |   2 +-
 include/hw/virtio/virtio_ring.h     | 167 ++++++++++++++++++++++++++++++++++++
 linux-headers/linux/vhost.h         |   2 +-
 4 files changed, 170 insertions(+), 3 deletions(-)
 create mode 100644 include/hw/virtio/virtio_ring.h
hw/net/vhost_net.c +1 -1
index b21e7a4..1b9b749 100644
@@ -28,7 +28,6 @@
 #include <sys/socket.h>
 #include <linux/kvm.h>
 #include <fcntl.h>
-#include <linux/virtio_ring.h>
 #include <netpacket/packet.h>
 #include <net/ethernet.h>
 #include <net/if.h>
@@ -36,6 +35,7 @@
 
 #include <stdio.h>
 
+#include "hw/virtio/virtio_ring.h"
 #include "hw/virtio/vhost.h"
 #include "hw/virtio/virtio-bus.h"
 
include/hw/virtio/dataplane/vring.h +1 -1
index af73ee2..d3e086a 100644
@@ -17,8 +17,8 @@
 #ifndef VRING_H
 #define VRING_H
 
-#include <linux/virtio_ring.h>
 #include "qemu-common.h"
+#include "hw/virtio/virtio_ring.h"
 #include "hw/virtio/virtio.h"
 
 typedef struct {
include/hw/virtio/virtio_ring.h new file +167 -0

167 lines not on this page · raw message

linux-headers/linux/vhost.h +1 -1
index c656f61..bb5df43 100644
@@ -14,7 +14,7 @@
 
 #include <linux/ioctl.h>
 #include <linux/virtio_config.h>
-#include <linux/virtio_ring.h>
+#include "hw/virtio/virtio_ring.h"
 
 struct vhost_vring_state {
 	unsigned int index;
Signature · 1 line
1.9.3
author
#2 lore raw

PATCH v3 2/3 vring: Better error handling if num is too large

In reply to Fam Zheng

To be more consistent inside this function.

---
 hw/virtio/dataplane/vring.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/virtio/dataplane/vring.c +2 -1
index 67cb2b8..372706a 100644
@@ -181,7 +181,8 @@ static int get_desc(Vring *vring, VirtQueueElement *elem,
 
     /* Stop for now if there are not enough iovecs available. */
     if (*num >= VIRTQUEUE_MAX_SIZE) {
-        return -ENOBUFS;
+        error_report("Invalid SG num: %u", *num);
+        return -EFAULT;
     }
 
     /* TODO handle non-contiguous memory across region boundaries */
Signature · 1 line
1.9.3
author
#3 lore raw

PATCH v3 3/3 block: Always compile virtio-blk dataplane

In reply to Fam Zheng

Dataplane doesn't depend on linux-aio any more, so we don't need the compiling condition now.

Configure options are kept but just print a message.

---
 configure                      | 21 ++-------------------
 hw/block/Makefile.objs         |  2 +-
 hw/block/virtio-blk.c          | 20 ++------------------
 hw/virtio/Makefile.objs        |  2 +-
 include/hw/virtio/virtio-blk.h |  2 --
 5 files changed, 6 insertions(+), 41 deletions(-)
configure +2 -19
index 961bf6f..c539786 100755
@@ -327,7 +327,6 @@ glusterfs=""
 glusterfs_discard="no"
 glusterfs_zerofill="no"
 archipelago=""
-virtio_blk_data_plane=""
 gtk=""
 gtkabi=""
 vte=""
@@ -1092,9 +1091,8 @@ for opt do
   ;;
   --enable-archipelago) archipelago="yes"
   ;;
-  --disable-virtio-blk-data-plane) virtio_blk_data_plane="no"
-  ;;
-  --enable-virtio-blk-data-plane) virtio_blk_data_plane="yes"
+  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
+      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
   ;;
   --disable-gtk) gtk="no"
   ;;
@@ -2936,16 +2934,6 @@ else
 fi
 
 ##########################################
-# adjust virtio-blk-data-plane based on linux-aio
-
-if test "$virtio_blk_data_plane" = "yes" -a \
-	"$linux_aio" != "yes" ; then
-  error_exit "virtio-blk-data-plane requires Linux AIO, please try --enable-linux-aio"
-elif test -z "$virtio_blk_data_plane" ; then
-  virtio_blk_data_plane=$linux_aio
-fi
-
-##########################################
 # attr probe
 
 if test "$attr" != "no" ; then
@@ -4319,7 +4307,6 @@ echo "coroutine backend $coroutine"
 echo "coroutine pool    $coroutine_pool"
 echo "GlusterFS support $glusterfs"
 echo "Archipelago support $archipelago"
-echo "virtio-blk-data-plane $virtio_blk_data_plane"
 echo "gcov              $gcov_tool"
 echo "gcov enabled      $gcov"
 echo "TPM support       $tpm"
@@ -4778,10 +4765,6 @@ if test "$quorum" = "yes" ; then
   echo "CONFIG_QUORUM=y" >> $config_host_mak
 fi
 
-if test "$virtio_blk_data_plane" = "yes" ; then
-  echo 'CONFIG_VIRTIO_BLK_DATA_PLANE=$(CONFIG_VIRTIO)' >> $config_host_mak
-fi
-
 if test "$vhdx" = "yes" ; then
   echo "CONFIG_VHDX=y" >> $config_host_mak
 fi
hw/block/Makefile.objs +1 -1
index bf46f03..d4c3ab7 100644
@@ -12,4 +12,4 @@ common-obj-$(CONFIG_NVME_PCI) += nvme.o
 obj-$(CONFIG_SH4) += tc58128.o
 
 obj-$(CONFIG_VIRTIO) += virtio-blk.o
-obj-$(CONFIG_VIRTIO_BLK_DATA_PLANE) += dataplane/
+obj-$(CONFIG_VIRTIO) += dataplane/
hw/block/virtio-blk.c +2 -18
index a7f2827..75b4607 100644
@@ -18,10 +18,8 @@
 #include "hw/block/block.h"
 #include "sysemu/blockdev.h"
 #include "hw/virtio/virtio-blk.h"
-#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
-# include "dataplane/virtio-blk.h"
-# include "migration/migration.h"
-#endif
+#include "dataplane/virtio-blk.h"
+#include "migration/migration.h"
 #include "block/scsi.h"
 #ifdef __linux__
 # include <scsi/sg.h>
@@ -432,7 +430,6 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
         .num_writes = 0,
     };
 
-#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
     /* Some guests kick before setting VIRTIO_CONFIG_S_DRIVER_OK so start
      * dataplane here instead of waiting for .set_status().
      */
@@ -440,7 +437,6 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
         virtio_blk_data_plane_start(s->dataplane);
         return;
     }
-#endif
 
     while ((req = virtio_blk_get_request(s))) {
         virtio_blk_handle_request(req, &mrb);
@@ -497,11 +493,9 @@ static void virtio_blk_reset(VirtIODevice *vdev)
 {
     VirtIOBlock *s = VIRTIO_BLK(vdev);
 
-#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
     if (s->dataplane) {
         virtio_blk_data_plane_stop(s->dataplane);
     }
-#endif
 
     /*
      * This should cancel pending requests, but can't do nicely until there
@@ -591,12 +585,10 @@ static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status)
     VirtIOBlock *s = VIRTIO_BLK(vdev);
     uint32_t features;
 
-#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
     if (s->dataplane && !(status & (VIRTIO_CONFIG_S_DRIVER |
                                     VIRTIO_CONFIG_S_DRIVER_OK))) {
         virtio_blk_data_plane_stop(s->dataplane);
     }
-#endif
 
     if (!(status & VIRTIO_CONFIG_S_DRIVER_OK)) {
         return;
@@ -691,7 +683,6 @@ static const BlockDevOps virtio_block_ops = {
     .resize_cb = virtio_blk_resize,
 };
 
-#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
 /* Disable dataplane thread during live migration since it does not
  * update the dirty memory bitmap yet.
  */
@@ -722,7 +713,6 @@ static void virtio_blk_migration_state_changed(Notifier *notifier, void *data)
         }
     }
 }
-#endif /* CONFIG_VIRTIO_BLK_DATA_PLANE */
 
 static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
 {
@@ -759,7 +749,6 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
 
     s->vq = virtio_add_queue(vdev, 128, virtio_blk_handle_output);
     s->complete_request = virtio_blk_complete_request;
-#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
     virtio_blk_data_plane_create(vdev, blk, &s->dataplane, &err);
     if (err != NULL) {
         error_propagate(errp, err);
@@ -768,7 +757,6 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
     }
     s->migration_state_notifier.notify = virtio_blk_migration_state_changed;
     add_migration_state_change_notifier(&s->migration_state_notifier);
-#endif
 
     s->change = qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s);
     register_savevm(dev, "virtio-blk", virtio_blk_id++, 2,
@@ -786,11 +774,9 @@ static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp)
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VirtIOBlock *s = VIRTIO_BLK(dev);
 
-#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
     remove_migration_state_change_notifier(&s->migration_state_notifier);
     virtio_blk_data_plane_destroy(s->dataplane);
     s->dataplane = NULL;
-#endif
     qemu_del_vm_change_state_handler(s->change);
     unregister_savevm(dev, "virtio-blk", s);
     blockdev_mark_auto_del(s->bs);
@@ -815,9 +801,7 @@ static Property virtio_blk_properties[] = {
 #ifdef __linux__
     DEFINE_PROP_BIT("scsi", VirtIOBlock, blk.scsi, 0, true),
 #endif
-#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
     DEFINE_PROP_BIT("x-data-plane", VirtIOBlock, blk.data_plane, 0, false),
-#endif
     DEFINE_PROP_END_OF_LIST(),
 };
 
hw/virtio/Makefile.objs +1 -1
index ec9e855..d21c397 100644
@@ -2,7 +2,7 @@ common-obj-y += virtio-rng.o
 common-obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o
 common-obj-y += virtio-bus.o
 common-obj-y += virtio-mmio.o
-common-obj-$(CONFIG_VIRTIO_BLK_DATA_PLANE) += dataplane/
+common-obj-$(CONFIG_VIRTIO) += dataplane/
 
 obj-y += virtio.o virtio-balloon.o 
 obj-$(CONFIG_LINUX) += vhost.o vhost-backend.o vhost-user.o
include/hw/virtio/virtio-blk.h +0 -2
index afb7b8d..f4c5239 100644
@@ -131,10 +131,8 @@ typedef struct VirtIOBlock {
     VMChangeStateEntry *change;
     /* Function to push to vq and notify guest */
     void (*complete_request)(struct VirtIOBlockReq *req, unsigned char status);
-#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
     Notifier migration_state_notifier;
     struct VirtIOBlockDataPlane *dataplane;
-#endif
 } VirtIOBlock;
 
 typedef struct MultiReqBuffer {
Signature · 1 line
1.9.3
Reviewed-by on the v3 series
#4 lore raw
In reply to Fam Zheng

Il 10/09/2014 08:17, Fam Zheng ha scritto:

Quoted 8 lines

v3: Fix -ENOBUFS.
v2: Import virtio_vring.h.

Fam Zheng (3):
virtio: Import virtio_vring.h
vring: Better error handling if num is too large
block: Always compile virtio-blk dataplane

Quoted 13 lines
 configure                           |  21 +----
 hw/block/Makefile.objs              |   2 +-
 hw/block/virtio-blk.c               |  20 +----
 hw/net/vhost_net.c                  |   2 +-
 hw/virtio/Makefile.objs             |   2 +-
 hw/virtio/dataplane/vring.c         |   3 +-
 include/hw/virtio/dataplane/vring.h |   2 +-
 include/hw/virtio/virtio-blk.h      |   2 -
 include/hw/virtio/virtio_ring.h     | 167 ++++++++++++++++++++++++++++++++++++
 linux-headers/linux/vhost.h         |   2 +-
 10 files changed, 178 insertions(+), 45 deletions(-)
 create mode 100644 include/hw/virtio/virtio_ring.h
#5 lore raw
In reply to Fam Zheng
Quoted 8 lines · Fam Zheng

v3: Fix -ENOBUFS.
v2: Import virtio_vring.h.

Fam Zheng (3):
virtio: Import virtio_vring.h
vring: Better error handling if num is too large
block: Always compile virtio-blk dataplane

Quoted 17 lines
 configure                           |  21 +----
 hw/block/Makefile.objs              |   2 +-
 hw/block/virtio-blk.c               |  20 +----
 hw/net/vhost_net.c                  |   2 +-
 hw/virtio/Makefile.objs             |   2 +-
 hw/virtio/dataplane/vring.c         |   3 +-
 include/hw/virtio/dataplane/vring.h |   2 +-
 include/hw/virtio/virtio-blk.h      |   2 -
 include/hw/virtio/virtio_ring.h     | 167 ++++++++++++++++++++++++++++++++++++
 linux-headers/linux/vhost.h         |   2 +-
 10 files changed, 178 insertions(+), 45 deletions(-)
 create mode 100644 include/hw/virtio/virtio_ring.h
Signature · 1 line
1.9.3

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan