Skip to contentSkip to conversation

vsock: add vsock device

PATCH Superseded Stefan Hajnoczi 3 participants 4 messages Nov 29, 2018 – Dec 13, 2018

v10 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

PATCH v10 1/1 vsock: add vsock device

The virtio vsock device is a zero-configuration socket communications device. It is designed as a guest<->host management channel suitable for communicating with guest agents.

vsock is designed with the sockets API in mind and the driver is typically implemented as an address family (at the same level as AF_INET). Applications written for the sockets API can be ported with minimal changes (similar amount of effort as adding IPv6 support to an IPv4 application).

Unlike the existing console device, which is also used for guest<->host communication, multiple clients can connect to a server at the same time over vsock. This limitation requires console-based users to arbitrate access through a single client. In vsock they can connect directly and do not have to synchronize with each other.

Unlike network devices, no configuration is necessary because the device comes with its address in the configuration space.

The vsock device was prototyped by Gerd Hoffmann and Asias He. I picked the code and design up from them.

---
v10:
* Add GitHub Issue URL [Michael]
* Add references from conformance section [Michael]

v9:
* There was no discussion on the last revision so I've rebased and intend to raise an issue to merge this on GitHub.
* Moved content to virtio-vsock.tex

v8:
* Rebased
* This version is up-to-date with the Linux drivers

v7:
* Add virtqueue flow control section to explain how deadlock is avoided when rings are full [Ian]

v6:
* Make CIDs 64-bits but reserve upper 32 bits for now [Michael]
* Specify SHUTDOWN -> RST clean disconnect process [Ian]

v5:
* Switch to new, unused Device ID 19 [Ian]
* Drop unused ctrl virtqueue, no need to reserve last virtqueue [Ian]
* Document that VIRTIO_VSOCK_OP_CREDIT_UPDATE packets are valid even if no VIRTIO_VSOCK_OP_CREDIT_REQUEST was previously received. [Ian]
* Document that only payload bytes are counted for buffer space management, not header bytes [Ian]
* List the reserved CIDs [Ian]

v4:
* Add event virtqueue and "Device Events" device operation section that explains how transport reset works for migration.
* Reorder virtqueues with rx/tx first, then ctrl/event (similar to virtio-net)
* __le32/16 -> le32/16 for consistency with existing code snippets
* Add missing conformance.tex subsections for socket device entry in table of contents

v3:
* "VSock device" -> "Virtio socket device" in free text [Michael]
* Extract normative statements and add references from conformance chapter [Michael]
v2:
* Document guest_cid field
* Use MAY/MUST/CAN according to RFC 2119
* Remove datagram socket type for the time being. This can be added in the future but there are currently no applications.
* Drop 3-way handshake for stream sockets. It is not needed since virtio-vsock is reliable, in-order delivery and spoofing source addresses is impossible.
* Drop max_virtqueue_pairs configuration space field. This field was never defined and Linux code does not support multiqueue. It can be added back later, if necessary.

---
 conformance.tex  |  23 +++-
 content.tex      |   1 +
 virtio-vsock.tex | 279 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 301 insertions(+), 2 deletions(-)
 create mode 100644 virtio-vsock.tex
conformance.tex +21 -2
index 24bd8b2..9fa028c 100644
@@ -15,13 +15,13 @@ Conformance targets:
   \begin{itemize}
     \item Clause \ref{sec:Conformance / Driver Conformance},
     \item One of clauses \ref{sec:Conformance / Driver Conformance / PCI Driver Conformance}, \ref{sec:Conformance / Driver Conformance / MMIO Driver Conformance} or \ref{sec:Conformance / Driver Conformance / Channel I/O Driver Conformance}.
-    \item One of clauses \ref{sec:Conformance / Driver Conformance / Network Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Block Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Console Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Entropy Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Traditional Memory Balloon Driver Conformance} or \ref{sec:Conformance / Driver Conformance / SCSI Host Driver Conformance}.
+    \item One of clauses \ref{sec:Conformance / Driver Conformance / Network Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Block Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Console Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Entropy Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Traditional Memory Balloon Driver Conformance}, \ref{sec:Conformance / Driver Conformance / SCSI Host Driver Conformance}, or \ref{sec:Conformance / Driver Conformance / Socket Driver Conformance}.
   \end{itemize}
 \item[Device] A device MUST conform to three conformance clauses:
   \begin{itemize}
     \item Clause \ref{sec:Conformance / Device Conformance},
     \item One of clauses \ref{sec:Conformance / Device Conformance / PCI Device Conformance}, \ref{sec:Conformance / Device Conformance / MMIO Device Conformance} or \ref{sec:Conformance / Device Conformance / Channel I/O Device Conformance}.
-    \item One of clauses \ref{sec:Conformance / Device Conformance / Network Device Conformance}, \ref{sec:Conformance / Device Conformance / Block Device Conformance}, \ref{sec:Conformance / Device Conformance / Console Device Conformance}, \ref{sec:Conformance / Device Conformance / Entropy Device Conformance}, \ref{sec:Conformance / Device Conformance / Traditional Memory Balloon Device Conformance} or \ref{sec:Conformance / Device Conformance / SCSI Host Device Conformance}.
+    \item One of clauses \ref{sec:Conformance / Device Conformance / Network Device Conformance}, \ref{sec:Conformance / Device Conformance / Block Device Conformance}, \ref{sec:Conformance / Device Conformance / Console Device Conformance}, \ref{sec:Conformance / Device Conformance / Entropy Device Conformance}, \ref{sec:Conformance / Device Conformance / Traditional Memory Balloon Device Conformance}, \ref{sec:Conformance / Device Conformance / SCSI Host Device Conformance}, or \ref{sec:Conformance / Device Conformance / Socket Device Conformance}.
   \end{itemize}
 \end{description}
 
@@ -162,6 +162,16 @@ A Crypto driver MUST conform to the following normative statements:
 \item \ref{drivernormative:Device Types / Crypto Device / Device Operation / AEAD Service Operation}
 \end{itemize}
 
+\subsection{Socket Driver Conformance}\label{sec:Conformance / Driver Conformance / Socket Driver Conformance}
+
+A socket driver MUST conform to the following normative statements:
+
+\begin{itemize}
+\item \ref{drivernormative:Device Types / Socket Device / Device Operation / Buffer Space Management}
+\item \ref{drivernormative:Device Types / Socket Device / Device Operation / Receive and Transmit}
+\item \ref{drivernormative:Device Types / Socket Device / Device Operation / Device Events}
+\end{itemize}
+
 \section{Device Conformance}\label{sec:Conformance / Device Conformance}
 
 A device MUST conform to the following normative statements:
@@ -297,6 +307,15 @@ A Crypto device MUST conform to the following normative statements:
 \item \ref{devicenormative:Device Types / Crypto Device / Device Operation / AEAD Service Operation}
 \end{itemize}
 
+\subsection{Socket Device Conformance}\label{sec:Conformance / Device Conformance / Socket Device Conformance}
+
+A socket device MUST conform to the following normative statements:
+
+\begin{itemize}
+\item \ref{devicenormative:Device Types / Socket Device / Device Operation / Buffer Space Management}
+\item \ref{devicenormative:Device Types / Socket Device / Device Operation / Receive and Transmit}
+\end{itemize}
+
 \section{Legacy Interface: Transitional Device and
 Transitional Driver Conformance}\label{sec:Conformance / Legacy
 Interface: Transitional Device and 
content.tex +1 -0
index c346183..3bb21c0 100644
@@ -5431,6 +5431,7 @@ descriptor for the \field{sense_len}, \field{residual},
 
 \input{virtio-gpu.tex}
 \input{virtio-crypto.tex}
+\input{virtio-vsock.tex}
 
 \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 
virtio-vsock.tex new file +279 -0

279 lines not on this page · raw message

Signature · 6 lines
2.19.1


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
#1 lore raw
Quoted 19 lines · On Thu, 29 Nov 2018 18:16:59 +0000 Stefan Hajnoczi <[email protected]> wrote:

The virtio vsock device is a zero-configuration socket communications device. It is designed as a guest<->host management channel suitable for communicating with guest agents.

vsock is designed with the sockets API in mind and the driver is typically implemented as an address family (at the same level as AF_INET). Applications written for the sockets API can be ported with minimal changes (similar amount of effort as adding IPv6 support to an IPv4 application).

Unlike the existing console device, which is also used for guest<->host communication, multiple clients can connect to a server at the same time over vsock. This limitation requires console-based users to arbitrate access through a single client. In vsock they can connect directly and do not have to synchronize with each other.

Unlike network devices, no configuration is necessary because the device comes with its address in the configuration space.

Quoted 6 lines

The vsock device was prototyped by Gerd Hoffmann and Asias He. I picked the code and design up from them.

I have not reviewed it in detail; but in general, the spec looks good to me.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

#2 lore raw
In reply to Stefan Hajnoczi

virtio-vsock.tex line 21

Quoted 5 lines · Stefan Hajnoczi

+\subsection{Feature bits}\label{sec:Device Types / Socket Device / Feature bits}

virtio-vsock.tex new file +4 -0
+
+\begin{description}
+There are currently no feature bits defined for this device.
+\end{description}

this breaks latex: \item must be used within description. I have dropped description environment.
Pls make sure to build document before posting.

Signature · 5 lines
MST

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
#3 lore raw
Quoted 10 lines · Michael S. Tsirkin

virtio-vsock.tex line 21

Quoted 5 lines · Stefan Hajnoczi

+\subsection{Feature bits}\label{sec:Device Types / Socket Device / Feature bits}

virtio-vsock.tex new file +4 -0
+
+\begin{description}
+There are currently no feature bits defined for this device.
+\end{description}

this breaks latex: \item must be used within description. I have dropped description environment.
Pls make sure to build document before posting.

Sorry, I was unable to run ./makepdf.sh without the Microsoft fonts and thought ./makehtml.sh alone would catch errors (but it didn't!).

Will fix.

Stefan