Skip to contentSkip to conversation

vhost: comments and doc update due to vhost-cuse removal

PATCH Applied Yuanhan Liu 3 participants 9 messages Nov 2, 2016 – Nov 7, 2016

lore
Share & tools
lore
#0 lore raw

cover vhost: comments and doc update due to vhost-cuse removal

Here is a small patchset of updating vhost programming and sample guide and comments, due to the removal of vhost-cuse.

---
Yuanhan Liu (3):
doc: update vhost programming guide
doc: update the vhost sample guide
vhost: update comments

 doc/guides/prog_guide/vhost_lib.rst                |  62 +-
 doc/guides/sample_app_ug/img/qemu_virtio_net.png   | Bin 31557 -> 0 bytes
 doc/guides/sample_app_ug/img/tx_dpdk_testpmd.png   | Bin 76019 -> 0 bytes
 doc/guides/sample_app_ug/img/vhost_net_arch.png    | Bin 154920 -> 0 bytes
 .../sample_app_ug/img/vhost_net_sample_app.png     | Bin 23800 -> 0 bytes
 .../sample_app_ug/img/virtio_linux_vhost.png       | Bin 30290 -> 0 bytes
 doc/guides/sample_app_ug/index.rst                 |  10 -
 doc/guides/sample_app_ug/tep_termination.rst       |  54 +-
 doc/guides/sample_app_ug/vhost.rst                 | 869 +++------------------
 examples/tep_termination/main.c                    |   7 +-
 examples/vhost/main.c                              |   4 +-
 examples/vhost_xen/main.c                          |   3 +-
 lib/librte_vhost/rte_virtio_net.h                  |   5 +-
 lib/librte_vhost/vhost.c                           |   9 +-
 lib/librte_vhost/vhost.h                           |   4 +-
 15 files changed, 148 insertions(+), 879 deletions(-)
 delete mode 100644 doc/guides/sample_app_ug/img/qemu_virtio_net.png
 delete mode 100644 doc/guides/sample_app_ug/img/tx_dpdk_testpmd.png
 delete mode 100644 doc/guides/sample_app_ug/img/vhost_net_arch.png
 delete mode 100644 doc/guides/sample_app_ug/img/vhost_net_sample_app.png
 delete mode 100644 doc/guides/sample_app_ug/img/virtio_linux_vhost.png
Signature · 1 line
1.9.0
#1 lore raw

PATCH 1/3 doc: update vhost programming guide

vhost-cuse has been removed in this release. Update the doc, with the vhost-cuse part being removed.

---
 doc/guides/prog_guide/vhost_lib.rst | 62 +++++--------------------------------
 1 file changed, 7 insertions(+), 55 deletions(-)
doc/guides/prog_guide/vhost_lib.rst +7 -55
index 573a318..4f997d4 100644
@@ -46,26 +46,8 @@ vhost library should be able to:
 * Know all the necessary information about the vring:
 
   Information such as where the available ring is stored. Vhost defines some
-  messages to tell the backend all the information it needs to know how to
-  manipulate the vring.
-
-Currently, there are two ways to pass these messages and as a result there are
-two Vhost implementations in DPDK: *vhost-cuse* (where the character devices
-are in user space) and *vhost-user*.
-
-Vhost-cuse creates a user space character device and hook to a function ioctl,
-so that all ioctl commands that are sent from the frontend (QEMU) will be
-captured and handled.
-
-Vhost-user creates a Unix domain socket file through which messages are
-passed.
-
-.. Note::
-
-   Since DPDK v2.2, the majority of the development effort has gone into
-   enhancing vhost-user, such as multiple queue, live migration, and
-   reconnect. Thus, it is strongly advised to use vhost-user instead of
-   vhost-cuse.
+  messages (passed through a Unix domain socket file) to tell the backend all
+  the information it needs to know how to manipulate the vring.
 
 
 Vhost API Overview
@@ -75,11 +57,10 @@ The following is an overview of the Vhost API functions:
 
 * ``rte_vhost_driver_register(path, flags)``
 
-  This function registers a vhost driver into the system. For vhost-cuse, a
-  ``/dev/path`` character device file will be created. For vhost-user server
-  mode, a Unix domain socket file ``path`` will be created.
+  This function registers a vhost driver into the system. ``path`` specifies
+  the Unix domain socket file path.
 
-  Currently supported flags are (these are valid for vhost-user only):
+  Currently supported flags are:
 
   - ``RTE_VHOST_USER_CLIENT``
 
@@ -171,35 +152,8 @@ The following is an overview of the Vhost API functions:
   default.
 
 
-Vhost Implementations
----------------------
-
-Vhost-cuse implementation
-~~~~~~~~~~~~~~~~~~~~~~~~~
-
-When vSwitch registers the vhost driver, it will register a cuse device driver
-into the system and creates a character device file. This cuse driver will
-receive vhost open/release/IOCTL messages from the QEMU simulator.
-
-When the open call is received, the vhost driver will create a vhost device
-for the virtio device in the guest.
-
-When the ``VHOST_SET_MEM_TABLE`` ioctl is received, vhost searches the memory
-region to find the starting user space virtual address that maps the memory of
-the guest virtual machine. Through this virtual address and the QEMU pid,
-vhost can find the file QEMU uses to map the guest memory. Vhost maps this
-file into its address space, in this way vhost can fully access the guest
-physical memory, which means vhost could access the shared virtio ring and the
-guest physical address specified in the entry of the ring.
-
-The guest virtual machine tells the vhost whether the virtio device is ready
-for processing or is de-activated through the ``VHOST_NET_SET_BACKEND``
-message. The registered callback from vSwitch will be called.
-
-When the release call is made, vhost will destroy the device.
-
-Vhost-user implementation
-~~~~~~~~~~~~~~~~~~~~~~~~~
+Vhost-user Implementations
+--------------------------
 
 Vhost-user uses Unix domain sockets for passing messages. This means the DPDK
 vhost-user implementation has two options:
@@ -246,8 +200,6 @@ For ``VHOST_SET_MEM_TABLE`` message, QEMU will send information for each
 memory region and its file descriptor in the ancillary data of the message.
 The file descriptor is used to map that region.
 
-There is no ``VHOST_NET_SET_BACKEND`` message as in vhost-cuse to signal
-whether the virtio device is ready or stopped. Instead,
 ``VHOST_SET_VRING_KICK`` is used as the signal to put the vhost device into
 the data plane, and ``VHOST_GET_VRING_BASE`` is used as the signal to remove
 the vhost device from the data plane.
Signature · 1 line
1.9.0
Acked-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] doc: update vhost programming guide

Quoted 10 lines

-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Wednesday, November 2, 2016 3:15 AM
To: [email protected]
Cc: Mcnamara, John <[email protected]>; Yuanhan Liu <[email protected]>
Subject: [PATCH 1/3] doc: update vhost programming guide

Quoted 4 lines

vhost-cuse has been removed in this release. Update the doc, with the vhost-cuse part being removed.

#3 lore raw

PATCH 2/3 doc: update the vhost sample guide

In reply to Yuanhan Liu

For vhost-switch sample, the old guide takes too many words on vhost-cuse, which is mainly due to vhost-cuse is invented before vhost-user.

Now vhost-cuse is removed, meaning the best part of the doc is useless. Instead of amending one piece here and there, this patch simply removes the most part of the doc and replace it with a simple test guide.

For tep_term sample, mainly for removing the part has "vhost-cuse".

---

The test is simplified a bit (from using two virtio-net devices to one), meaning few figures doesn't apply anymore; thus, vhost_net_sample and tx_dpdk_testpmd figure are removed.

And apparently, the vhost_net_arch figure also becomes useless. Yet I have no time to draw one for vhost-user, I also removed the two left
figures: qemu_virtio_net and virtio_linux_vhost, which shows the arch of typical virtio net and linux kernel vhost-net.

---
 doc/guides/sample_app_ug/img/qemu_virtio_net.png   | Bin 31557 -> 0 bytes
 doc/guides/sample_app_ug/img/tx_dpdk_testpmd.png   | Bin 76019 -> 0 bytes
 doc/guides/sample_app_ug/img/vhost_net_arch.png    | Bin 154920 -> 0 bytes
 .../sample_app_ug/img/vhost_net_sample_app.png     | Bin 23800 -> 0 bytes
 .../sample_app_ug/img/virtio_linux_vhost.png       | Bin 30290 -> 0 bytes
 doc/guides/sample_app_ug/index.rst                 |  10 -
 doc/guides/sample_app_ug/tep_termination.rst       |  54 +-
 doc/guides/sample_app_ug/vhost.rst                 | 869 +++------------------
 8 files changed, 128 insertions(+), 805 deletions(-)
 delete mode 100644 doc/guides/sample_app_ug/img/qemu_virtio_net.png
 delete mode 100644 doc/guides/sample_app_ug/img/tx_dpdk_testpmd.png
 delete mode 100644 doc/guides/sample_app_ug/img/vhost_net_arch.png
 delete mode 100644 doc/guides/sample_app_ug/img/vhost_net_sample_app.png
 delete mode 100644 doc/guides/sample_app_ug/img/virtio_linux_vhost.png
doc/guides/sample_app_ug/img/qemu_virtio_net.png deleted binary +0 -0
deleted file mode 100644
index a852c1662fe978e1dc785f4771ff285172ae5e86..0000000000000000000000000000000000000000
GIT binary patch
doc/guides/sample_app_ug/img/tx_dpdk_testpmd.png deleted binary +0 -0
deleted file mode 100644
index 656e17b88248d2dfb2cb7fdb038507c1f9f1a103..0000000000000000000000000000000000000000
GIT binary patch
doc/guides/sample_app_ug/img/vhost_net_arch.png deleted binary +0 -0
deleted file mode 100644
index 3008feef1f2d93f0419be339fc0717f115180048..0000000000000000000000000000000000000000
GIT binary patch
doc/guides/sample_app_ug/img/vhost_net_sample_app.png deleted binary +0 -0
deleted file mode 100644
index c7a181b20d84b4b738f6385636974d5a3d73270d..0000000000000000000000000000000000000000
GIT binary patch
doc/guides/sample_app_ug/img/virtio_linux_vhost.png deleted binary +0 -0
deleted file mode 100644
index 0614269943b9c90ea93e3e255ee9117d70c7bd5f..0000000000000000000000000000000000000000
GIT binary patch
doc/guides/sample_app_ug/index.rst +0 -10
index 96bb317..9d0fe1f 100644
@@ -120,16 +120,6 @@ Sample Applications User Guide
 
 :numref:`figure_vmdq_dcb_example` :ref:`figure_vmdq_dcb_example`
 
-:numref:`figure_qemu_virtio_net` :ref:`figure_qemu_virtio_net`
-
-:numref:`figure_virtio_linux_vhost` :ref:`figure_virtio_linux_vhost`
-
-:numref:`figure_vhost_net_arch` :ref:`figure_vhost_net_arch`
-
-:numref:`figure_vhost_net_sample_app` :ref:`figure_vhost_net_sample_app`
-
-:numref:`figure_tx_dpdk_testpmd` :ref:`figure_tx_dpdk_testpmd`
-
 :numref:`figure_test_pipeline_app` :ref:`figure_test_pipeline_app`
 
 :numref:`figure_dist_perf` :ref:`figure_dist_perf`
doc/guides/sample_app_ug/tep_termination.rst +5 -49

97 lines not on this page · raw message

doc/guides/sample_app_ug/vhost.rst +123 -746

946 lines not on this page · raw message

Signature · 1 line
1.9.0
Acked-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] doc: update the vhost sample guide

Quoted 14 lines

-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Wednesday, November 2, 2016 3:15 AM
To: [email protected]
Cc: Mcnamara, John <[email protected]>; Yuanhan Liu <[email protected]>
Subject: [PATCH 2/3] doc: update the vhost sample guide

For vhost-switch sample, the old guide takes too many words on vhost-cuse, which is mainly due to vhost-cuse is invented before vhost-user.

Quoted 7 lines

Now vhost-cuse is removed, meaning the best part of the doc is useless. Instead of amending one piece here and there, this patch simply removes the most part of the doc and replace it with a simple test guide.

For tep_term sample, mainly for removing the part has "vhost-cuse".

Good cleanup.

#5 lore raw

PATCH 3/3 vhost: update comments

In reply to Yuanhan Liu

vhost-cuse is removed, update corresponding comments that are still referencing it.

---
 examples/tep_termination/main.c   | 7 ++-----
 examples/vhost/main.c             | 4 +---
 examples/vhost_xen/main.c         | 3 +--
 lib/librte_vhost/rte_virtio_net.h | 5 ++---
 lib/librte_vhost/vhost.c          | 9 ++++-----
 lib/librte_vhost/vhost.h          | 4 +++-
 6 files changed, 13 insertions(+), 19 deletions(-)
examples/tep_termination/main.c +2 -5
index 622f248..1d6d463 100644
@@ -1151,8 +1151,7 @@ print_stats(void)
 }
 
 /**
- * Main function, does initialisation and calls the per-lcore functions. The CUSE
- * device is also registered here to handle the IOCTLs.
+ * Main function, does initialisation and calls the per-lcore functions.
  */
 int
 main(int argc, char *argv[])
@@ -1253,14 +1252,12 @@ main(int argc, char *argv[])
 	}
 	rte_vhost_feature_disable(1ULL << VIRTIO_NET_F_MRG_RXBUF);
 
-	/* Register CUSE device to handle IOCTLs. */
 	ret = rte_vhost_driver_register((char *)&dev_basename, 0);
 	if (ret != 0)
-		rte_exit(EXIT_FAILURE, "CUSE device setup failure.\n");
+		rte_exit(EXIT_FAILURE, "failed to register vhost driver.\n");
 
 	rte_vhost_driver_callback_register(&virtio_net_device_ops);
 
-	/* Start CUSE session. */
 	rte_vhost_driver_session_start();
 
 	return 0;
examples/vhost/main.c +1 -3
index 91000e8..0709859 100644
@@ -1409,8 +1409,7 @@ create_mbuf_pool(uint16_t nr_port, uint32_t nr_switch_core, uint32_t mbuf_size,
 }
 
 /*
- * Main function, does initialisation and calls the per-lcore functions. The CUSE
- * device is also registered here to handle the IOCTLs.
+ * Main function, does initialisation and calls the per-lcore functions.
  */
 int
 main(int argc, char *argv[])
@@ -1531,7 +1530,6 @@ main(int argc, char *argv[])
 
 	rte_vhost_driver_callback_register(&virtio_net_device_ops);
 
-	/* Start CUSE session. */
 	rte_vhost_driver_session_start();
 	return 0;
 
examples/vhost_xen/main.c +1 -2
index 2e40357..f4dbaa4 100644
@@ -1407,8 +1407,7 @@ print_stats(void)
 int init_virtio_net(struct virtio_net_device_ops const * const ops);
 
 /*
- * Main function, does initialisation and calls the per-lcore functions. The CUSE
- * device is also registered here to handle the IOCTLs.
+ * Main function, does initialisation and calls the per-lcore functions.
  */
 int
 main(int argc, char *argv[])
lib/librte_vhost/rte_virtio_net.h +2 -3
index c53ff64..926039c 100644
@@ -123,9 +123,8 @@ int rte_vhost_get_numa_node(int vid);
 uint32_t rte_vhost_get_queue_num(int vid);
 
 /**
- * Get the virtio net device's ifname. For vhost-cuse, ifname is the
- * path of the char device. For vhost-user, ifname is the vhost-user
- * socket file path.
+ * Get the virtio net device's ifname, which is the vhost-user socket
+ * file path.
  *
  * @param vid
  *  virtio-net device ID
lib/librte_vhost/vhost.c +4 -5
index d8116ff..31825b8 100644
@@ -227,9 +227,8 @@ reset_device(struct virtio_net *dev)
 }
 
 /*
- * Function is called from the CUSE open function. The device structure is
- * initialised and a new entry is added to the device configuration linked
- * list.
+ * Invoked when there is a new vhost-user connection established (when
+ * there is a new virtio device being attached).
  */
 int
 vhost_new_device(void)
@@ -261,8 +260,8 @@ vhost_new_device(void)
 }
 
 /*
- * Function is called from the CUSE release function. This function will
- * cleanup the device and remove it from device configuration linked list.
+ * Invoked when there is the vhost-user connection is broken (when
+ * the virtio device is being detached).
  */
 void
 vhost_destroy_device(int vid)
lib/librte_vhost/vhost.h +3 -1
index acec772..22564f1 100644
@@ -284,7 +284,9 @@ void vhost_set_ifname(int, const char *if_name, unsigned int if_len);
 void vhost_enable_dequeue_zero_copy(int vid);
 
 /*
- * Backend-specific cleanup. Defined by vhost-cuse and vhost-user.
+ * Backend-specific cleanup.
+ *
+ * TODO: fix it; we have one backend now
  */
 void vhost_backend_cleanup(struct virtio_net *dev);
 
Signature · 1 line
1.9.0
Acked-by on v1 3/3
#6 lore raw

Re: [PATCH 3/3] vhost: update comments

Quoted 17 lines

-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Wednesday, November 2, 2016 3:15 AM
To: [email protected]
Cc: Mcnamara, John <[email protected]>; Yuanhan Liu <[email protected]>
Subject: [PATCH 3/3] vhost: update comments

vhost-cuse is removed, update corresponding comments that are still referencing it.

...

Quoted 7 lines

/*
- * Backend-specific cleanup. Defined by vhost-cuse and vhost-user.
+ * Backend-specific cleanup.
+ *
+ * TODO: fix it; we have one backend now
*/
void vhost_backend_cleanup(struct virtio_net *dev);

In general it is not a good idea to leave TODOs/Fixmes around unless they that a better explanation of why they are there.

Apart from that:

#7 lore raw

Re: [PATCH 3/3] vhost: update comments

Quoted 25 lines · John
Quoted 17 lines

-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Wednesday, November 2, 2016 3:15 AM
To: [email protected]
Cc: Mcnamara, John <[email protected]>; Yuanhan Liu <[email protected]>
Subject: [PATCH 3/3] vhost: update comments

vhost-cuse is removed, update corresponding comments that are still referencing it.

...

Quoted 7 lines

/*
- * Backend-specific cleanup. Defined by vhost-cuse and vhost-user.
+ * Backend-specific cleanup.
+ *
+ * TODO: fix it; we have one backend now
*/
void vhost_backend_cleanup(struct virtio_net *dev);

Quoted 2 lines

In general it is not a good idea to leave TODOs/Fixmes around unless they that a better explanation of why they are there.

Agreed.

In this case, if you look at the delete line, you will find we have such function implemented both in vhost-user and vhost-cuse. Now we get one only. So, we may could just rename it to vhost_user_cleanup(). Or even, remove it completely by doing some small refactors.

It's obvious that we need do that in another patch. Thus, the TODO is been added.

	--yliu
Quoted 6 lines

Apart from that:

#8 lore raw
In reply to Yuanhan Liu

2016-11-02 11:14, Yuanhan Liu:

Quoted 2 lines

Here is a small patchset of updating vhost programming and sample guide and comments, due to the removal of vhost-cuse.

Applied, thanks