virtio-fs: add virtio file system device
v5 cover virtio-fs: add virtio file system device
v5:
* Explain multiqueue semantics: no ordering, identical functionality on each queue, one FUSE session state shared between all queues
* Explain how the FUSE session is started with a FUSE_INIT request
* Consistently use "submit" vs "made available" and "complete" vs "used" terminology [Michael]
* Explain endianness [Michael]
* Clarify hiprio vs normal queue usage [Michael]
* Move SHOULD, MUST, etc wording into normative sections [Michael]
* Mention that FUSE_INIT negotiated state needs to be transferred during live migration [Michael]
* State that the DAX window is mapped with writeback caching like RAM [Michael]
* Mention DAX window mapping alignment constraints (they are communicated via the FUSE protocol) [Michael]
* Explain that FUSE_SETUPMAPPING fails when device resources are exhausted and that splitting mappings consumes resources too [Michael]
* Clarify access rules to DAX window - only touch memory that has a mapping establised
* Document that DAX data persistence is achieved via FUSE_FSYNC
v4:
* Clarify that there are no request ordering guarantees between requests in a single queue [vgoyal]
* Add explanation of FUSE session endianness detection [dgilbert]
v3:
* Remove notifications virtqueue, it's unimplemented and can be added when needed [Miklos]
* Add Security Considerations and Live Migration Considerations sections [Michael]
v2:
* Clean up core virtio file system device spec
* Add DAX window
These patches add the virtio file system device, which is based on Linux FUSE but includes the DAX window extension. Similar to virtio-scsi, which transports SCSI commands, virtio-fs transports FUSE requests and the protocol documentation is not duplicated here.
The DAX window allows file contents to be accessed directly from shared memory. This eliminates copying of data, reduces the number of vmexits, and reduces the guest's memory footprint. It also allows coherent mmap MAP_SHARED semantics between guests on the same host.
Stefan Hajnoczi (2):
content: add virtio file system device
virtio-fs: add DAX window
content.tex | 1 + introduction.tex | 3 + virtio-fs.tex | 259 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 263 insertions(+) create mode 100644 virtio-fs.tex
Signature · 6 lines
2.21.0 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
PATCH v5 1/2 content: add virtio file system device
The virtio file system device transports Linux FUSE requests between a FUSE daemon running on the host and the FUSE driver inside the guest.
The actual FUSE request definitions are not duplicated in the virtio specification, similar to how virtio-scsi does not document SCSI command details. FUSE request definitions are available here:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/fuse.h
This patch documents the core virtio file system device, which is functional but lacks the DAX feature introduced in the next patch.
--- content.tex | 1 + introduction.tex | 3 + virtio-fs.tex | 214 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 218 insertions(+) create mode 100644 virtio-fs.tex
content.tex +1 -0
@@ -5677,6 +5677,7 @@ \subsubsection{Legacy Interface: Framing Requirements}\label{sec:Device \input{virtio-input.tex} \input{virtio-crypto.tex} \input{virtio-vsock.tex} +\input{virtio-fs.tex} \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
introduction.tex +3 -0
@@ -60,6 +60,9 @@ \section{Normative References}\label{sec:Normative References} \phantomsection\label{intro:SCSI MMC}\textbf{[SCSI MMC]} & SCSI Multimedia Commands, \newline\url{http://www.t10.org/cgi-bin/ac.pl?t=f&f=mmc6r00.pdf}\\ + \phantomsection\label{intro:FUSE}\textbf{[FUSE]} & + Linux FUSE interface, + \newline\url{https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/fuse.h}\\ \end{longtable}
virtio-fs.tex new file +214 -0
214 lines not on this page · raw message
Signature · 6 lines
2.21.0 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [virtio-dev] [PATCH v5 1/2] content: add virtio file system device
Quoted 18 lines · On Fri, 26 Jul 2019 10:53:37 +0100 Stefan Hajnoczi <[email protected]> wrote:
The virtio file system device transports Linux FUSE requests between a FUSE daemon running on the host and the FUSE driver inside the guest.
The actual FUSE request definitions are not duplicated in the virtio specification, similar to how virtio-scsi does not document SCSI command details. FUSE request definitions are available here:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/fuse.hThis patch documents the core virtio file system device, which is functional but lacks the DAX feature introduced in the next patch.
Signed-off-by Stefan Hajnoczi <[email protected]>--- content.tex | 1 + introduction.tex | 3 + virtio-fs.tex | 214 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 218 insertions(+) create mode 100644 virtio-fs.tex
(...)
Quoted 28 lines
+\subsection{Virtqueues}\label{sec:Device Types / File System Device / Virtqueues}
virtio-fs.tex new file +27
-0+ +\begin{description} +\item[0] hiprio +\item[1\ldots n] request queues +\end{description} + +\subsection{Feature bits}\label{sec:Device Types / File System Device / Feature bits} + +There are currently no feature bits defined. + +\subsection{Device configuration layout}\label{sec:Device Types / File System Device / Device configuration layout} + +All fields of this configuration are always available. + +\begin{lstlisting} +struct virtio_fs_config { + char tag[36]; + le32 num_queues; +}; +\end{lstlisting} + +\begin{description} +\item[\field{tag}] is the name associated with this file system. The tag is + encoded in UTF-8 and padded with NUL bytes if shorter than the + available space. This field is not NUL-terminated if the encoded bytes + take up the entire field. +\item[\field{num_queues}] is the total number of request virtqueues exposed by
virtio-fs.tex line 61
Quoted 10 lines
virtio-fs.tex new file +10
-0+ the device. Each virtqueue offers identical functionality and there are no + ordering guarantees between requests made available on different queues. + Use of multiple queues is intended to increase performance. +\end{description} + +\drivernormative{\subsubsection}{Device configuration layout}{Device Types / File System Device / Device configuration layout} + +The driver MUST NOT write to device configuration fields. + +The driver MAY use from one up to \field{num_queues} virtqueues.
s/virtqueues/request virtqueues/ ? I'm still a bit unsure about the requirements for queue usage, see below.
Quoted 11 lines
virtio-fs.tex new file +11
-0+ +\devicenormative{\subsubsection}{Device configuration layout}{Device Types / File System Device / Device configuration layout} + +The device MUST set \field{num_queues} to 1 or greater. + +\subsection{Device Initialization}\label{Device Types / File System Device / Device Initialization} + +On initialization the driver first discovers the device's virtqueues. The FUSE +session is started by sending a FUSE\_INIT request as defined by the FUSE +protocol on one request virtqueue. All virtqueues provide access to the same +FUSE session and therefore only one FUSE\_INIT request is required regardless
virtio-fs.tex line 82
Quoted 10 lines
virtio-fs.tex new file +10
-0+of the number of available virtqueues. + +\subsection{Device Operation}\label{sec:Device Types / File System Device / Device Operation} + +Device operation consists of operating the virtqueues to facilitate file system +access. + +The FUSE request types are as follows: +\begin{itemize} +\item Normal requests are made available by the driver and used by the device.
These go via the normal request queues...
Quoted 2 lines
+\item Interrupt requests are made available by the driver to abort requests
+ that the device has not used yet.
...and these via the hiprio queue?
virtio-fs.tex
Quoted 8 lines
+\end{itemize}
virtio-fs.tex new file +7
-0+ +Note that FUSE notification requests are not supported. + +\subsubsection{Device Operation: Request Queues}\label{sec:Device Types / File System Device / Device Operation / Device Operation: Request Queues} + +The driver enqueues normal requests on an arbitrary request queue and they are +completed by the device on that same queue.
Do we need a device normative statement that requests MUST be completed on the queue they have been submitted on?
virtio-fs.tex line 97
Quoted 6 lines
The device processes requests in
virtio-fs.tex new file +5
-0+any order. The driver is responsible for ensuring that ordering constraints +are met by making available a dependent request only after its prerequisite +request has been used. + +Requests have the following format:
These can be either LE or BE from what is stated below, right? Maybe spell it out here already?
Quoted 41 lines
virtio-fs.tex new file +41
-0+ +\begin{lstlisting} +struct virtio_fs_req { + // Device-readable part + struct fuse_in_header in; + u8 datain[]; + + // Device-writable part + struct fuse_out_header out; + u8 dataout[]; +}; +\end{lstlisting} + +Note that the words "in" and "out" follow the FUSE meaning and do not indicate +the direction of data transfer under VIRTIO. "In" means input to a request and +"out" means output from processing a request. + +\field{in} is the common header for all types of FUSE requests. + +\field{datain} consists of request-specific data, if any. This is identical to +the data read from the /dev/fuse device by a FUSE daemon. + +\field{out} is the completion header common to all types of FUSE requests. + +\field{dataout} consists of request-specific data, if any. This is identical +to the data written to the /dev/fuse device by a FUSE daemon. + +For example, the full layout of a FUSE\_READ request is as follows: + +\begin{lstlisting} +struct virtio_fs_read_req { + // Device-readable part + struct fuse_in_header in; + union { + struct fuse_read_in readin; + u8 datain[sizeof(struct fuse_read_in)]; + }; + + // Device-writable part + struct fuse_out_header out; + u8 dataout[out.len - sizeof(struct fuse_out_header)];
virtio-fs.tex line 148
Quoted 10 lines
virtio-fs.tex new file +10
-0+}; +\end{lstlisting} + +The FUSE protocol documented in \hyperref[intro:FUSE]{FUSE} specifies the set +of request types and their contents. + +The endianness of the FUSE protocol session is detectable by inspecting the +uint32\_t \field{in.opcode} field of the FUSE\_INIT request sent by the driver +to the device. This allows the device to determine whether the session is +little-endian or big-endian.
Do we need a driver normative statement that the driver MUST NOT send a request with a different endianness once it established the session's endianness via FUSE_INIT?
virtio-fs.tex line 154
Quoted 6 lines
virtio-fs.tex new file +6
-0+ +\subsubsection{Device Operation: High Priority Queue}\label{sec:Device Types / File System Device / Device Operation / Device Operation: High Priority Queue} + +The hiprio queue follows the same request format as the request queues. This +queue only contains FUSE\_INTERRUPT, FUSE\_FORGET, and FUSE\_BATCH\_FORGET +requests.
Does this also imply that normal request queues can't be used for interrupt and forget requests? The normative statement below seems to imply that, but I think the text here does not make it clear already.
Quoted 5 lines
virtio-fs.tex new file +5
-0+ +Interrupt and forget requests have a higher priority than normal requests. The +separate hiprio queue is used for these requests to ensure they can be +delivered even when all request queues are full. +
virtio-fs.tex line 169
Quoted 10 lines
virtio-fs.tex new file +10
-0+\devicenormative{\paragraph}{Device Operation: High Priority Queue}{Device Types / File System Device / Device Operation / Device Operation: High Priority Queue} + +The device MUST NOT pause processing of the hiprio queue due to activity on a +normal request queue. + +The device MAY process request queues concurrently with the hiprio queue. + +\drivernormative{\paragraph}{Device Operation: High Priority Queue}{Device Types / File System Device / Device Operation / Device Operation: High Priority Queue} + +The driver MUST submit FUSE\_INTERRUPT, FUSE\_FORGET, and FUSE\_BATCH\_FORGET requests solely on the hiprio queue.
This specifies that the driver MUST submit interrupt and forget request via the hiprio queue, but it does not specify that no other requests may go via the hiprio queue, what the descriptive text above implies.
Review
Quoted 2 lines
(quoted diff) +2
-0+ +The driver MUST anticipate that request queues are processed concurrently with the hiprio queue.
(...)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [virtio-dev] [PATCH v5 1/2] content: add virtio file system device
Quoted 10 lines · Cornelia Huck
virtio-fs.tex line 61
Quoted 5 lines · On Fri, 26 Jul 2019 10:53:37 +0100 Stefan Hajnoczi <[email protected]> wrote:
+\drivernormative{\subsubsection}{Device configuration layout}{Device Types / File System Device / Device configuration layout}
virtio-fs.tex new file +4
-0+ +The driver MUST NOT write to device configuration fields. + +The driver MAY use from one up to \field{num_queues} virtqueues.s/virtqueues/request virtqueues/ ? I'm still a bit unsure about the requirements for queue usage, see below.
Will fix, thanks.
Quoted 25 lines
Quoted 12 lines
virtio-fs.tex new file +11
-0+ +\devicenormative{\subsubsection}{Device configuration layout}{Device Types / File System Device / Device configuration layout} + +The device MUST set \field{num_queues} to 1 or greater. + +\subsection{Device Initialization}\label{Device Types / File System Device / Device Initialization} + +On initialization the driver first discovers the device's virtqueues. The FUSE +session is started by sending a FUSE\_INIT request as defined by the FUSE +protocol on one request virtqueue. All virtqueues provide access to the same +FUSE session and therefore only one FUSE\_INIT request is required regardlessvirtio-fs.tex line 82
Quoted 10 lines
virtio-fs.tex new file +10
-0+of the number of available virtqueues. + +\subsection{Device Operation}\label{sec:Device Types / File System Device / Device Operation} + +Device operation consists of operating the virtqueues to facilitate file system +access. + +The FUSE request types are as follows: +\begin{itemize} +\item Normal requests are made available by the driver and used by the device.These go via the normal request queues...
Quoted 4 lines
Quoted 2 lines
+\item Interrupt requests are made available by the driver to abort requests
+ that the device has not used yet....and these via the hiprio queue?
Yes.
Quoted 12 lines
virtio-fs.tex
Quoted 9 lines
+\end{itemize}
virtio-fs.tex new file +7
-0+ +Note that FUSE notification requests are not supported. + +\subsubsection{Device Operation: Request Queues}\label{sec:Device Types / File System Device / Device Operation / Device Operation: Request Queues} + +The driver enqueues normal requests on an arbitrary request queue and they are +completed by the device on that same queue.Do we need a device normative statement that requests MUST be completed on the queue they have been submitted on?
That would be impossible since the request struct has both IN and OUT elements. virtio-fs is a request+response queue design like virtio-blk/virtio-scsi, not a rx/tx queue design like virtio-net/virtio-vsock.
Quoted 10 lines
virtio-fs.tex line 97
Quoted 7 lines
The device processes requests in
virtio-fs.tex new file +5
-0+any order. The driver is responsible for ensuring that ordering constraints +are met by making available a dependent request only after its prerequisite +request has been used. + +Requests have the following format:These can be either LE or BE from what is stated below, right? Maybe spell it out here already?
I will add "with the endianness chosen by the driver as detailed below".
Quoted 48 lines
Quoted 48 lines
virtio-fs.tex new file +47
-0+ +\begin{lstlisting} +struct virtio_fs_req { + // Device-readable part + struct fuse_in_header in; + u8 datain[]; + + // Device-writable part + struct fuse_out_header out; + u8 dataout[]; +}; +\end{lstlisting} + +Note that the words "in" and "out" follow the FUSE meaning and do not indicate +the direction of data transfer under VIRTIO. "In" means input to a request and +"out" means output from processing a request. + +\field{in} is the common header for all types of FUSE requests. + +\field{datain} consists of request-specific data, if any. This is identical to +the data read from the /dev/fuse device by a FUSE daemon. + +\field{out} is the completion header common to all types of FUSE requests. + +\field{dataout} consists of request-specific data, if any. This is identical +to the data written to the /dev/fuse device by a FUSE daemon. + +For example, the full layout of a FUSE\_READ request is as follows: + +\begin{lstlisting} +struct virtio_fs_read_req { + // Device-readable part + struct fuse_in_header in; + union { + struct fuse_read_in readin; + u8 datain[sizeof(struct fuse_read_in)]; + }; + + // Device-writable part + struct fuse_out_header out; + u8 dataout[out.len - sizeof(struct fuse_out_header)]; +}; +\end{lstlisting} + +The FUSE protocol documented in \hyperref[intro:FUSE]{FUSE} specifies the set +of request types and their contents. +
Quoted 8 lines
virtio-fs.tex line 148
Quoted 4 lines
virtio-fs.tex new file +4
-0+The endianness of the FUSE protocol session is detectable by inspecting the +uint32\_t \field{in.opcode} field of the FUSE\_INIT request sent by the driver +to the device. This allows the device to determine whether the session is +little-endian or big-endian.Do we need a driver normative statement that the driver MUST NOT send a request with a different endianness once it established the session's endianness via
FUSE_INIT?
It is valid to send another FUSE_INIT to switch to a fresh session. In that case the driver could change the endianness again. I think we want this just in case a weird system without fixed endianness has a bootloader running in little-endian and a guest kernel running in big-endian, for example.
I will document this in the next revision.
Quoted 11 lines
virtio-fs.tex line 154
Quoted 7 lines
virtio-fs.tex new file +6
-0+ +\subsubsection{Device Operation: High Priority Queue}\label{sec:Device Types / File System Device / Device Operation / Device Operation: High Priority Queue} + +The hiprio queue follows the same request format as the request queues. This +queue only contains FUSE\_INTERRUPT, FUSE\_FORGET, and FUSE\_BATCH\_FORGET +requests.Does this also imply that normal request queues can't be used for interrupt and forget requests? The normative statement below seems to imply that, but I think the text here does not make it clear already.
Yes, these requests must only be placed on the hiprio queue. Will clarify, thanks!
Quoted 11 lines
Quoted 11 lines
virtio-fs.tex new file +11
-0+ +Interrupt and forget requests have a higher priority than normal requests. The +separate hiprio queue is used for these requests to ensure they can be +delivered even when all request queues are full. + +\devicenormative{\paragraph}{Device Operation: High Priority Queue}{Device Types / File System Device / Device Operation / Device Operation: High Priority Queue} + +The device MUST NOT pause processing of the hiprio queue due to activity on a +normal request queue. + +The device MAY process request queues concurrently with the hiprio queue.
Quoted 8 lines
virtio-fs.tex line 169
Quoted 4 lines
virtio-fs.tex new file +4
-0+ +\drivernormative{\paragraph}{Device Operation: High Priority Queue}{Device Types / File System Device / Device Operation / Device Operation: High Priority Queue} + +The driver MUST submit FUSE\_INTERRUPT, FUSE\_FORGET, and FUSE\_BATCH\_FORGET requests solely on the hiprio queue.This specifies that the driver MUST submit interrupt and forget request via the hiprio queue, but it does not specify that no other requests may go via the hiprio queue, what the descriptive text above implies.
Will clarify.
Thank you for your review!
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [virtio-dev] [PATCH v5 1/2] content: add virtio file system device
Quoted 12 lines · On Fri, 2 Aug 2019 16:49:51 +0100 Stefan Hajnoczi <[email protected]> wrote:
Quoted 10 lines · Cornelia Huck
virtio-fs.tex
Quoted 4 lines · On Fri, 26 Jul 2019 10:53:37 +0100 Stefan Hajnoczi <[email protected]> wrote:
+\subsubsection{Device Operation: Request Queues}\label{sec:Device Types / File System Device / Device Operation / Device Operation: Request Queues}
virtio-fs.tex new file +3
-0+ +The driver enqueues normal requests on an arbitrary request queue and they are +completed by the device on that same queue.Do we need a device normative statement that requests MUST be completed on the queue they have been submitted on?
Quoted 4 lines
That would be impossible since the request struct has both IN and OUT elements. virtio-fs is a request+response queue design like virtio-blk/virtio-scsi, not a rx/tx queue design like virtio-net/virtio-vsock.
Hm, now I'm confused -- what is impossible here? That the requests are completed somewhere else? (If so, we don't need an extra statement.)
Quoted 12 lines
Quoted 11 lines
virtio-fs.tex line 97
Quoted 8 lines
The device processes requests in
virtio-fs.tex new file +5
-0+any order. The driver is responsible for ensuring that ordering constraints +are met by making available a dependent request only after its prerequisite +request has been used. + +Requests have the following format:These can be either LE or BE from what is stated below, right? Maybe spell it out here already?
Quoted 1 line
I will add "with the endianness chosen by the driver as detailed below".
Sounds good.
Quoted 58 lines
Quoted 49 lines
Quoted 49 lines
virtio-fs.tex new file +47
-0+ +\begin{lstlisting} +struct virtio_fs_req { + // Device-readable part + struct fuse_in_header in; + u8 datain[]; + + // Device-writable part + struct fuse_out_header out; + u8 dataout[]; +}; +\end{lstlisting} + +Note that the words "in" and "out" follow the FUSE meaning and do not indicate +the direction of data transfer under VIRTIO. "In" means input to a request and +"out" means output from processing a request. + +\field{in} is the common header for all types of FUSE requests. + +\field{datain} consists of request-specific data, if any. This is identical to +the data read from the /dev/fuse device by a FUSE daemon. + +\field{out} is the completion header common to all types of FUSE requests. + +\field{dataout} consists of request-specific data, if any. This is identical +to the data written to the /dev/fuse device by a FUSE daemon. + +For example, the full layout of a FUSE\_READ request is as follows: + +\begin{lstlisting} +struct virtio_fs_read_req { + // Device-readable part + struct fuse_in_header in; + union { + struct fuse_read_in readin; + u8 datain[sizeof(struct fuse_read_in)]; + }; + + // Device-writable part + struct fuse_out_header out; + u8 dataout[out.len - sizeof(struct fuse_out_header)]; +}; +\end{lstlisting} + +The FUSE protocol documented in \hyperref[intro:FUSE]{FUSE} specifies the set +of request types and their contents. +Quoted 8 lines
virtio-fs.tex line 148
Quoted 4 lines
virtio-fs.tex new file +4
-0+The endianness of the FUSE protocol session is detectable by inspecting the +uint32\_t \field{in.opcode} field of the FUSE\_INIT request sent by the driver +to the device. This allows the device to determine whether the session is +little-endian or big-endian.Do we need a driver normative statement that the driver MUST NOT send a request with a different endianness once it established the session's endianness via
FUSE_INIT?
Quoted 5 lines
It is valid to send another
FUSE_INITto switch to a fresh session. In that case the driver could change the endianness again. I think we want this just in case a weird system without fixed endianness has a bootloader running in little-endian and a guest kernel running in big-endian, for example.
Yes, it's probably a good idea to spell that out.
Quoted 2 lines
I will document this in the next revision.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [virtio-dev] [PATCH v5 1/2] content: add virtio file system device
Quoted 15 lines · * Cornelia Huck ([email protected]) wrote:
Quoted 12 lines · On Fri, 2 Aug 2019 16:49:51 +0100 Stefan Hajnoczi <[email protected]> wrote:
Quoted 10 lines · Cornelia Huck
virtio-fs.tex
Quoted 4 lines · On Fri, 26 Jul 2019 10:53:37 +0100 Stefan Hajnoczi <[email protected]> wrote:
+\subsubsection{Device Operation: Request Queues}\label{sec:Device Types / File System Device / Device Operation / Device Operation: Request Queues}
virtio-fs.tex new file +3
-0+ +The driver enqueues normal requests on an arbitrary request queue and they are +completed by the device on that same queue.Do we need a device normative statement that requests MUST be completed on the queue they have been submitted on?
Quoted 7 lines
Quoted 4 lines
That would be impossible since the request struct has both IN and OUT elements. virtio-fs is a request+response queue design like virtio-blk/virtio-scsi, not a rx/tx queue design like virtio-net/virtio-vsock.
Hm, now I'm confused -- what is impossible here? That the requests are completed somewhere else?
Correct - because the response goes back in elements in the same request struct you can't split them.
Dave
Quoted 77 lines
(If so, we don't need an extra statement.)
Quoted 12 lines
Quoted 11 lines
virtio-fs.tex line 97
Quoted 8 lines
The device processes requests in
virtio-fs.tex new file +5
-0+any order. The driver is responsible for ensuring that ordering constraints +are met by making available a dependent request only after its prerequisite +request has been used. + +Requests have the following format:These can be either LE or BE from what is stated below, right? Maybe spell it out here already?
Quoted 1 line
I will add "with the endianness chosen by the driver as detailed below".
Sounds good.
Quoted 58 lines
Quoted 57 lines
Quoted 43 lines
virtio-fs.tex new file +41
-0+ +\begin{lstlisting} +struct virtio_fs_req { + // Device-readable part + struct fuse_in_header in; + u8 datain[]; + + // Device-writable part + struct fuse_out_header out; + u8 dataout[]; +}; +\end{lstlisting} + +Note that the words "in" and "out" follow the FUSE meaning and do not indicate +the direction of data transfer under VIRTIO. "In" means input to a request and +"out" means output from processing a request. + +\field{in} is the common header for all types of FUSE requests. + +\field{datain} consists of request-specific data, if any. This is identical to +the data read from the /dev/fuse device by a FUSE daemon. + +\field{out} is the completion header common to all types of FUSE requests. + +\field{dataout} consists of request-specific data, if any. This is identical +to the data written to the /dev/fuse device by a FUSE daemon. + +For example, the full layout of a FUSE\_READ request is as follows: + +\begin{lstlisting} +struct virtio_fs_read_req { + // Device-readable part + struct fuse_in_header in; + union { + struct fuse_read_in readin; + u8 datain[sizeof(struct fuse_read_in)]; + }; + + // Device-writable part + struct fuse_out_header out; + u8 dataout[out.len - sizeof(struct fuse_out_header)];virtio-fs.tex line 148
Quoted 10 lines
virtio-fs.tex new file +10
-0+}; +\end{lstlisting} + +The FUSE protocol documented in \hyperref[intro:FUSE]{FUSE} specifies the set +of request types and their contents. + +The endianness of the FUSE protocol session is detectable by inspecting the +uint32\_t \field{in.opcode} field of the FUSE\_INIT request sent by the driver +to the device. This allows the device to determine whether the session is +little-endian or big-endian.Do we need a driver normative statement that the driver MUST NOT send a request with a different endianness once it established the session's endianness via
FUSE_INIT?
Quoted 10 lines
Quoted 5 lines
It is valid to send another
FUSE_INITto switch to a fresh session. In that case the driver could change the endianness again. I think we want this just in case a weird system without fixed endianness has a bootloader running in little-endian and a guest kernel running in big-endian, for example.Yes, it's probably a good idea to spell that out.
Quoted 2 lines
I will document this in the next revision.
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [virtio-dev] [PATCH v5 1/2] content: add virtio file system device
In reply to Stefan HajnocziReview
Quoted 3 lines · Stefan Hajnoczi
+\subsubsection{Live migration considerations}\label{sec:Device Types / File System Device / Live Migration Considerations}
(quoted diff) +2
-0+ +When a guest is migrated to a new host
Please use driver and device here and elsewhere.
Quoted 4 lines
it is necessary to consider the FUSE
virtio-fs.tex new file +3
-0+session and its state. The continuity of FUSE inode numbers (also known as +nodeids) and fh values is necessary so the driver can continue operation +without disruption.
virtio-fs.tex line 214
Quoted 10 lines
virtio-fs.tex new file +10
-0+ +It is possible to maintain the FUSE session across live migration either by +transferring the state or by redirecting requests from the new host to the old +host where the state resides. The details of how to achieve this are +implementation-dependent and are not visible at the device interface level. + +Maintaining version and feature information negotiated by FUSE\_INIT is +necessary so that no FUSE protocol feature changes are visible to the driver +across live migration. The FUSE\_INIT information forms part of the FUSE +session state that needs to be transferred during live migration.
It bothers me that it's implicit, and is not exposed easily at the virtio level, so one has to bind a virtqueue and run buffers over it to even just check whether a given device supports a specific interface and can be migrated to.
How about exposing the version of the device in the config space? Spec can require that it matches the contents of the INIT command.
....
Quoted 7 lines
Signature · 6 lines
2.21.0 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [virtio-dev] [PATCH v5 1/2] content: add virtio file system device
Quoted 6 lines · Michael S. Tsirkin
Review
Quoted 3 lines · Stefan Hajnoczi
+\subsubsection{Live migration considerations}\label{sec:Device Types / File System Device / Live Migration Considerations}
(quoted diff) +2
-0+ +When a guest is migrated to a new hostPlease use driver and device here and elsewhere.
Will fix.
Quoted 20 lines
Quoted 4 lines
it is necessary to consider the FUSE
virtio-fs.tex new file +3
-0+session and its state. The continuity of FUSE inode numbers (also known as +nodeids) and fh values is necessary so the driver can continue operation +without disruption.virtio-fs.tex line 214
Quoted 10 lines
virtio-fs.tex new file +10
-0+ +It is possible to maintain the FUSE session across live migration either by +transferring the state or by redirecting requests from the new host to the old +host where the state resides. The details of how to achieve this are +implementation-dependent and are not visible at the device interface level. + +Maintaining version and feature information negotiated by FUSE\_INIT is +necessary so that no FUSE protocol feature changes are visible to the driver +across live migration. The FUSE\_INIT information forms part of the FUSE +session state that needs to be transferred during live migration.It bothers me that it's implicit, and is not exposed easily at the virtio level, so one has to bind a virtqueue and run buffers over it to even just check whether a given device supports a specific interface and can be migrated to.
Quoted 2 lines
How about exposing the version of the device in the config space? Spec can require that it matches the contents of the INIT command.
FUSE_INIT works like this:
1. The client sends FUSE_INIT with the supported highest protocol version.
2. If the server supports the client's version, it replies with the same version number and fills in the FUSE_INIT parameters.
Otherwise the server lowers the version number and replies to the client, and the client will resend FUSE_INIT with the lower version number to acknowledge that it supports the lower version. Go to step 1.
With regards to live migration the server's FUSE_INIT reply structure needs to be sent to the destination if a FUSE session has been established. If the destination does not support this protocol version then live migration fails.
If management tools want to ensure that migration always succeeds then I think the way to do that is not via virtio config space (they would still need to start a guest in order to access it!).
I don't understand the benefit of exposing the device's version in the config space? Do you mean the negotiated version of the current FUSE session or the highest FUSE protocol version supported by the device?
Re: [virtio-dev] [PATCH v5 1/2] content: add virtio file system device
Quoted 50 lines · Stefan Hajnoczi
Quoted 6 lines · Michael S. Tsirkin
Review
Quoted 3 lines · Stefan Hajnoczi
+\subsubsection{Live migration considerations}\label{sec:Device Types / File System Device / Live Migration Considerations}
(quoted diff) +2
-0+ +When a guest is migrated to a new hostPlease use driver and device here and elsewhere.
Will fix.
Quoted 20 lines
Quoted 4 lines
it is necessary to consider the FUSE
virtio-fs.tex new file +3
-0+session and its state. The continuity of FUSE inode numbers (also known as +nodeids) and fh values is necessary so the driver can continue operation +without disruption.virtio-fs.tex line 214
Quoted 10 lines
virtio-fs.tex new file +10
-0+ +It is possible to maintain the FUSE session across live migration either by +transferring the state or by redirecting requests from the new host to the old +host where the state resides. The details of how to achieve this are +implementation-dependent and are not visible at the device interface level. + +Maintaining version and feature information negotiated by FUSE\_INIT is +necessary so that no FUSE protocol feature changes are visible to the driver +across live migration. The FUSE\_INIT information forms part of the FUSE +session state that needs to be transferred during live migration.It bothers me that it's implicit, and is not exposed easily at the virtio level, so one has to bind a virtqueue and run buffers over it to even just check whether a given device supports a specific interface and can be migrated to.
Quoted 2 lines
How about exposing the version of the device in the config space? Spec can require that it matches the contents of the INIT command.
FUSE_INITworks like this:1. The client sends
FUSE_INITwith the supported highest protocol version.
2. If the server supports the client's version, it replies with the same version number and fills in theFUSE_INITparameters.Otherwise the server lowers the version number and replies to the client, and the client will resend
FUSE_INITwith the lower version number to acknowledge that it supports the lower version. Go to step 1.With regards to live migration the server's
FUSE_INITreply structure needs to be sent to the destination if a FUSE session has been established. If the destination does not support this protocol version then live migration fails.
Quoted 7 lines
If management tools want to ensure that migration always succeeds then I think the way to do that is not via virtio config space (they would still need to start a guest in order to access it!).
I don't understand the benefit of exposing the device's version in the config space? Do you mean the negotiated version of the current FUSE session or the highest FUSE protocol version supported by the device?
The highest version.
The point is to make it crystal clear that for cross version migration the highest version must be consistent.
Otherwise this is something implementers might easily overlook.
Another option is to add non-normative text explaining what must be kept consistent to allow migration between devices.
Generally I think that it is unfortunate that pass-through devices like this one are growing extensions for
feature negotiation outside the spec.
This hurts attempts at generic transport pass-through like vhost-user.
Signature · 5 lines
MST --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [virtio-dev] [PATCH v5 1/2] content: add virtio file system device
Quoted 55 lines · Michael S. Tsirkin
Quoted 54 lines · Stefan Hajnoczi
Quoted 6 lines · Michael S. Tsirkin
Review
Quoted 3 lines · Stefan Hajnoczi
+\subsubsection{Live migration considerations}\label{sec:Device Types / File System Device / Live Migration Considerations}
(quoted diff) +2
-0+ +When a guest is migrated to a new hostPlease use driver and device here and elsewhere.
Will fix.
Quoted 20 lines
Quoted 4 lines
it is necessary to consider the FUSE
virtio-fs.tex new file +3
-0+session and its state. The continuity of FUSE inode numbers (also known as +nodeids) and fh values is necessary so the driver can continue operation +without disruption.virtio-fs.tex line 214
Quoted 10 lines
virtio-fs.tex new file +10
-0+ +It is possible to maintain the FUSE session across live migration either by +transferring the state or by redirecting requests from the new host to the old +host where the state resides. The details of how to achieve this are +implementation-dependent and are not visible at the device interface level. + +Maintaining version and feature information negotiated by FUSE\_INIT is +necessary so that no FUSE protocol feature changes are visible to the driver +across live migration. The FUSE\_INIT information forms part of the FUSE +session state that needs to be transferred during live migration.It bothers me that it's implicit, and is not exposed easily at the virtio level, so one has to bind a virtqueue and run buffers over it to even just check whether a given device supports a specific interface and can be migrated to.
Quoted 2 lines
How about exposing the version of the device in the config space? Spec can require that it matches the contents of the INIT command.
FUSE_INITworks like this:1. The client sends
FUSE_INITwith the supported highest protocol version.
2. If the server supports the client's version, it replies with the same version number and fills in theFUSE_INITparameters.Otherwise the server lowers the version number and replies to the client, and the client will resend
FUSE_INITwith the lower version number to acknowledge that it supports the lower version. Go to step 1.With regards to live migration the server's
FUSE_INITreply structure needs to be sent to the destination if a FUSE session has been established. If the destination does not support this protocol version then live migration fails.If management tools want to ensure that migration always succeeds then I think the way to do that is not via virtio config space (they would still need to start a guest in order to access it!).
Quoted 8 lines
Quoted 3 lines
I don't understand the benefit of exposing the device's version in the config space? Do you mean the negotiated version of the current FUSE session or the highest FUSE protocol version supported by the device?
The highest version.
The point is to make it crystal clear that for cross version migration the highest version must be consistent.
Otherwise this is something implementers might easily overlook.
For migration the current FUSE session's negotiated version must be supported by the destination. That's all. The highest version supported by the device doesn't matter.
Quoted 7 lines
Another option is to add non-normative text explaining what must be kept consistent to allow migration between devices.
Generally I think that it is unfortunate that pass-through devices like this one are growing extensions for
feature negotiation outside the spec.
This hurts attempts at generic transport pass-through like vhost-user.
I'm not sure how we'll implement vhost-user live migration. Currently the vhost-user protocol doesn't allow the slave to provide migration state. But we'll need to do this in order to transfer all the state associated with the virtio-fs device (FUSE_INIT struct, inodes, file locks, etc). It's important to recognize that this state goes way beyond the FUSE_INIT struct, there is a lot of implementation-specific state associated with a FUSE session!
Stefan
Re: [virtio-dev] [PATCH v5 1/2] content: add virtio file system device
In reply to Stefan HajnocziQuoted 1 line · Stefan Hajnoczi
+\subsubsection{Security Considerations}\label{sec:Device Types / File System Device / Security Considerations}
One issue not addressed here at all is sharing the filesystem cache. Is that a security consiteration at all?
A shared resource is often an information sidechannel.
Quoted 4 lines
virtio-fs.tex new file +4
-0+ +The device provides access to a file system containing files owned by one or +more POSIX user ids and group ids. The device has no secure way of +differentiating between users originating requests via the driver. Therefore
virtio-fs.tex line 187
Quoted 10 lines
virtio-fs.tex new file +10
-0+the device accepts the POSIX user ids and group ids provided by the driver and +security is enforced by the driver rather than the device. It is nevertheless +possible for devices to implement POSIX user id and group id mapping or +whitelisting to control the ownership and access available to the driver. + +File systems containing special files including device nodes and setuid +executable files pose a security concern. These properties are defined by the +file type and mode, which are set by the driver when creating new files or by +changes at a later time. These special files present a security risk when the +file system is shared with another system, such as the host or another guest.
is this a risk to someone using the device, another system with which this one is sharing, or both?
Review
Quoted 2 lines
(quoted diff) +2
-0+This issue can be solved on some operating systems using mount options that +ignore special files.
For this to be effective should not device provide a way for device to report that the issue exists?
Quoted 2 lines
It is also possible for devices to implement
+restrictions on special files by refusing their creation.
And then it can safely be mounted without above flags? How would a device do this? The list above is not exhaustive.
virtio-fs.tex line 197
Quoted 7 lines
virtio-fs.tex new file +7
-0+ +When the device provides shared access to a file system, symlink race +conditions, exhausting file system capacity, and overwriting or deleting files +used by others are factors to consider. These issues have a long history in +multi-user operating systems and also apply to virtio-fs. They are typically +managed at the file system administration level by providing shared access only +to mutually trusted users.
Can we be a bit more explicit here? I think this discusses a device accessing a shared filesystem with some other device. I am guessing it's the administrator of the filesystem, right?
Signature · 6 lines
MST --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [virtio-dev] [PATCH v5 1/2] content: add virtio file system device
Quoted 6 lines · Michael S. Tsirkin
Quoted 1 line · Stefan Hajnoczi
+\subsubsection{Security Considerations}\label{sec:Device Types / File System Device / Security Considerations}
One issue not addressed here at all is sharing the filesystem cache. Is that a security consiteration at all?
A shared resource is often an information sidechannel.
Will add to the next revision.
Quoted 9 lines
Quoted 9 lines
virtio-fs.tex new file +9
-0+ +The device provides access to a file system containing files owned by one or +more POSIX user ids and group ids. The device has no secure way of +differentiating between users originating requests via the driver. Therefore +the device accepts the POSIX user ids and group ids provided by the driver and +security is enforced by the driver rather than the device. It is nevertheless +possible for devices to implement POSIX user id and group id mapping or +whitelisting to control the ownership and access available to the driver. +
Quoted 8 lines
virtio-fs.tex line 187
Quoted 5 lines
virtio-fs.tex new file +5
-0+File systems containing special files including device nodes and setuid +executable files pose a security concern. These properties are defined by the +file type and mode, which are set by the driver when creating new files or by +changes at a later time. These special files present a security risk when the +file system is shared with another system, such as the host or another guest.is this a risk to someone using the device, another system with which this one is sharing, or both?
Both. Will add to the next revision.
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+This issue can be solved on some operating systems using mount options that +ignore special files.For this to be effective should not device provide a way for device to report that the issue exists?
Mounting with nosuid,nodev disables these features and therefore eliminates the security issue. The device doesn't need to notify or being involved directly.
Quoted 5 lines
Quoted 2 lines
It is also possible for devices to implement
+restrictions on special files by refusing their creation.And then it can safely be mounted without above flags? How would a device do this? The list above is not exhaustive.
The device would fail mknod and setting the setuid/setgid bits so that clients cannot create these dangerous files. The exact policy is implementation-dependent, for example, the device may allow creation of certain device major:minor nodes if the application depends on them.
Once these dangerous files cannot be created and if we trust that the file system does not already contain them, then the nosuid,nodev mount options are no longer necessary.
Since the details are implementation- and application-dependent I don't want to go into detail in the spec. The current virtiofsd implemenation does not do any of this.
Quoted 11 lines
virtio-fs.tex line 197
Quoted 7 lines
virtio-fs.tex new file +7
-0+ +When the device provides shared access to a file system, symlink race +conditions, exhausting file system capacity, and overwriting or deleting files +used by others are factors to consider. These issues have a long history in +multi-user operating systems and also apply to virtio-fs. They are typically +managed at the file system administration level by providing shared access only +to mutually trusted users.Can we be a bit more explicit here? I think this discusses a device accessing a shared filesystem with some other device. I am guessing it's the administrator of the filesystem, right?
Yes, by "shared" I meant the scenario where multiple systems are accessing the same shared directory tree. I'll reword it in the next revision.
Stefan
PATCH v5 2/2 virtio-fs: add DAX window
In reply to Stefan HajnocziDescribe how shared memory region ID 0 is the DAX window and how FUSE_SETUPMAPPING maps file ranges into the window.
---
Note that this depends on the shared memory resource specification extension that David Gilbert is working on.
https://lists.oasis-open.org/archives/virtio-comment/201901/msg00000.html
The FUSE_SETUPMAPPING message is part of the virtio-fs Linux patches:
https://gitlab.com/virtio-fs/linux/blob/virtio-fs/include/uapi/linux/fuse.h
--- virtio-fs.tex | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
virtio-fs.tex +45 -0
@@ -170,6 +170,51 @@ \subsubsection{Device Operation: High Priority Queue}\label{sec:Device Types / F The driver MUST anticipate that request queues are processed concurrently with the hiprio queue. +\subsubsection{Device Operation: DAX Window}\label{sec:Device Types / File System Device / Device Operation / Device Operation: DAX Window} + +FUSE\_READ and FUSE\_WRITE requests transfer file contents between the +driver-provided buffer and the device. In cases where data transfer is +undesirable, the device can map file contents into the DAX window shared memory +region. The driver then accesses file contents directly in device-owned memory +without a data transfer. + +Shared memory region ID 0 is called the DAX window. Drivers map this shared +memory region with writeback caching as if it were regular RAM. The contents +of the DAX window are undefined unless a mapping exists for that range. + +The driver maps a file range into the DAX window using the FUSE\_SETUPMAPPING +request. Alignment constraints for FUSE\_SETUPMAPPING and FUSE\_REMOVEMAPPING +requests are communicated during FUSE\_INIT negotiation. + +When a FUSE\_SETUPMAPPING request perfectly overlaps a previous mapping, the +previous mapping is replaced. When a mapping partially overlaps a previous +mapping, the previous mapping is split into one or two smaller mappings. When +a mapping is partially unmapped it is also split into one or two smaller +mappings. + +Establishing new mappings or splitting existing mappings consumes resources. +If the device runs out of resources the FUSE\_SETUPMAPPING request fails until +resources are available again following FUSE\_REMOVEMAPPING. + +After FUSE\_SETUPMAPPING has completed successfully the file range is +accessible from the DAX window at the offset provided by the driver in the +request. A mapping is removed using the FUSE\_REMOVEMAPPING request. + +Data is only guaranteed to be persistent when a FUSE\_FSYNC request is used by +the device after having been made available by the driver following the write. + +\devicenormative{\paragraph}{Device Operation: DAX Window}{Device Types / File System Device / Device Operation / Device Operation: DAX Window} + +The device MUST allow mappings that completely or partially overlap existing mappings within the DAX window. + +The device MUST reject mappings that would go beyond the end of the DAX window. + +\drivernormative{\paragraph}{Device Operation: DAX Window}{Device Types / File System Device / Device Operation / Device Operation: DAX Window} + +The driver SHOULD be prepared to find shared memory region ID 0 absent and fall back to FUSE\_READ and FUSE\_WRITE requests. + +The driver MUST NOT access DAX window areas that have not been mapped. + \subsubsection{Security Considerations}\label{sec:Device Types / File System Device / Security Considerations} The device provides access to a file system containing files owned by one or
Signature · 6 lines
2.21.0 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
[virtio-dev] Re: [PATCH v5 2/2] virtio-fs: add DAX window
Quoted 5 lines · Stefan Hajnoczi
Describe how shared memory region ID 0 is the DAX window and how
FUSE_SETUPMAPPINGmaps file ranges into the window.Signed-off-by Stefan Hajnoczi <[email protected]>---
Are there any security considerations with this memory sharing? If yes it might be a good idea to add a chapter about that, and functionality/performance/security tradeoffs involved.
Quoted 68 lines
Note that this depends on the shared memory resource specification extension that David Gilbert is working on.
https://lists.oasis-open.org/archives/virtio-comment/201901/msg00000.htmlThe
FUSE_SETUPMAPPINGmessage is part of the virtio-fs Linux patches:
https://gitlab.com/virtio-fs/linux/blob/virtio-fs/include/uapi/linux/fuse.h--- virtio-fs.tex | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)virtio-fs.tex +45
-0@@ -170,6 +170,51 @@ \subsubsection{Device Operation: High Priority Queue}\label{sec:Device Types / F The driver MUST anticipate that request queues are processed concurrently with the hiprio queue. +\subsubsection{Device Operation: DAX Window}\label{sec:Device Types / File System Device / Device Operation / Device Operation: DAX Window} + +FUSE\_READ and FUSE\_WRITE requests transfer file contents between the +driver-provided buffer and the device. In cases where data transfer is +undesirable, the device can map file contents into the DAX window shared memory +region. The driver then accesses file contents directly in device-owned memory +without a data transfer. + +Shared memory region ID 0 is called the DAX window. Drivers map this shared +memory region with writeback caching as if it were regular RAM. The contents +of the DAX window are undefined unless a mapping exists for that range. + +The driver maps a file range into the DAX window using the FUSE\_SETUPMAPPING +request. Alignment constraints for FUSE\_SETUPMAPPING and FUSE\_REMOVEMAPPING +requests are communicated during FUSE\_INIT negotiation. + +When a FUSE\_SETUPMAPPING request perfectly overlaps a previous mapping, the +previous mapping is replaced. When a mapping partially overlaps a previous +mapping, the previous mapping is split into one or two smaller mappings. When +a mapping is partially unmapped it is also split into one or two smaller +mappings. + +Establishing new mappings or splitting existing mappings consumes resources. +If the device runs out of resources the FUSE\_SETUPMAPPING request fails until +resources are available again following FUSE\_REMOVEMAPPING. + +After FUSE\_SETUPMAPPING has completed successfully the file range is +accessible from the DAX window at the offset provided by the driver in the +request. A mapping is removed using the FUSE\_REMOVEMAPPING request. + +Data is only guaranteed to be persistent when a FUSE\_FSYNC request is used by +the device after having been made available by the driver following the write. + +\devicenormative{\paragraph}{Device Operation: DAX Window}{Device Types / File System Device / Device Operation / Device Operation: DAX Window} + +The device MUST allow mappings that completely or partially overlap existing mappings within the DAX window. + +The device MUST reject mappings that would go beyond the end of the DAX window. + +\drivernormative{\paragraph}{Device Operation: DAX Window}{Device Types / File System Device / Device Operation / Device Operation: DAX Window} + +The driver SHOULD be prepared to find shared memory region ID 0 absent and fall back to FUSE\_READ and FUSE\_WRITE requests. + +The driver MUST NOT access DAX window areas that have not been mapped. + \subsubsection{Security Considerations}\label{sec:Device Types / File System Device / Security Considerations} The device provides access to a file system containing files owned by one orSignature · 1 line
2.21.0
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
[virtio-dev] Re: [PATCH v5 2/2] virtio-fs: add DAX window
Quoted 10 lines · Michael S. Tsirkin
Quoted 5 lines · Stefan Hajnoczi
Describe how shared memory region ID 0 is the DAX window and how
FUSE_SETUPMAPPINGmaps file ranges into the window.Signed-off-by Stefan Hajnoczi <[email protected]>---
Are there any security considerations with this memory sharing? If yes it might be a good idea to add a chapter about that, and functionality/performance/security tradeoffs involved.
I'll add statements about security. In light of recent security attacks we should mention timing side-channel attacks, although the general security model is that each virtio-fs client has full access to the files in the shared directory and therefore a certain level of trust is already required since race conditions and data corruption are possible anyway.
Stefan
Didn't look at the spec yet, but I have a question:
Quoted 5 lines · Stefan Hajnoczi
v5:
* Explain multiqueue semantics: no ordering, identical functionality on each queue, one FUSE session state shared between all queues
* Explain how the FUSE session is started with aFUSE_INITrequest
* Consistently use "submit" vs "made available" and "complete" vs "used" terminology [Michael]
* Explain endianness [Michael]
Quoted 8 lines
* Clarify hiprio vs normal queue usage [Michael]
* Move SHOULD, MUST, etc wording into normative sections [Michael]
* Mention thatFUSE_INITnegotiated state needs to be transferred during live migration [Michael]
* State that the DAX window is mapped with writeback caching like RAM [Michael]
* Mention DAX window mapping alignment constraints (they are communicated via the FUSE protocol) [Michael]
* Explain thatFUSE_SETUPMAPPINGfails when device resources are exhausted and that splitting mappings consumes resources too [Michael]
* Clarify access rules to DAX window - only touch memory that has a mapping establised
* Document that DAX data persistence is achieved viaFUSE_FSYNC
The following was raised during v4 review:
> > > > There is a practical problem that the QEMU process may hit the mmap > > > > limit and be unable to perform its own mmaps due to the DAX Window. A > > > > limit must be enforced on the host so that QEMU's internal mmaps > > > > succeed.
> > >
> > > But number of mmaps are already limited by dax window size which is > > > controlled by virtiofsd. So all user has to do is start with smaller > > > dax window size if this ever becomes a concern.
> >
> > Yes, the DAX Window size sets a hard limit on the number of mappings > > (window_size / page_size). I think we should still communicate a > > maximum number of mappings to provide more control for cases where the > > page size and DAX Window size don't produce a desirable number. > >
> > Consider that window_size = 8 GB and page_size = 4 KB already yields > > 2,097,152 maximum mappings. Oops, that number is too large! >
> Ok, so that's something which will be in virtiofsd where maximum number > of outstanding can be configured by user and if we cross that limit, > FUSE_SETUPMAPPING will be returned with some error?
Yes, virtiofsd will enforce the limit.
The guest driver will also be aware of the limit via VIRTIO configuration space.
was this addressed?
Quoted 28 lines
v4:
* Clarify that there are no request ordering guarantees between requests in a single queue [vgoyal]
* Add explanation of FUSE session endianness detection [dgilbert]v3:
* Remove notifications virtqueue, it's unimplemented and can be added when needed [Miklos]
* Add Security Considerations and Live Migration Considerations sections [Michael]
v2:
* Clean up core virtio file system device spec
* Add DAX windowThese patches add the virtio file system device, which is based on Linux FUSE but includes the DAX window extension. Similar to virtio-scsi, which transports SCSI commands, virtio-fs transports FUSE requests and the protocol documentation is not duplicated here.
The DAX window allows file contents to be accessed directly from shared memory. This eliminates copying of data, reduces the number of vmexits, and reduces the guest's memory footprint. It also allows coherent mmap
MAP_SHAREDsemantics between guests on the same host.Stefan Hajnoczi (2):
content: add virtio file system device
virtio-fs: add DAX window
Quoted 8 lines
content.tex | 1 + introduction.tex | 3 + virtio-fs.tex | 259 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 263 insertions(+) create mode 100644 virtio-fs.texSignature · 1 line
2.21.0
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 41 lines · * Michael S. Tsirkin ([email protected]) wrote:
Didn't look at the spec yet, but I have a question:
Quoted 5 lines · Stefan Hajnoczi
v5:
* Explain multiqueue semantics: no ordering, identical functionality on each queue, one FUSE session state shared between all queues
* Explain how the FUSE session is started with aFUSE_INITrequest
* Consistently use "submit" vs "made available" and "complete" vs "used" terminology [Michael]
* Explain endianness [Michael]Quoted 8 lines
* Clarify hiprio vs normal queue usage [Michael]
* Move SHOULD, MUST, etc wording into normative sections [Michael]
* Mention thatFUSE_INITnegotiated state needs to be transferred during live migration [Michael]
* State that the DAX window is mapped with writeback caching like RAM [Michael]
* Mention DAX window mapping alignment constraints (they are communicated via the FUSE protocol) [Michael]
* Explain thatFUSE_SETUPMAPPINGfails when device resources are exhausted and that splitting mappings consumes resources too [Michael]
* Clarify access rules to DAX window - only touch memory that has a mapping establised
* Document that DAX data persistence is achieved viaFUSE_FSYNCThe following was raised during v4 review:
> > > > There is a practical problem that the QEMU process may hit the mmap > > > > limit and be unable to perform its own mmaps due to the DAX Window. A > > > > limit must be enforced on the host so that QEMU's internal mmaps > > > > succeed.
> > >
> > > But number of mmaps are already limited by dax window size which is > > > controlled by virtiofsd. So all user has to do is start with smaller > > > dax window size if this ever becomes a concern.
> >
> > Yes, the DAX Window size sets a hard limit on the number of mappings > > (window_size/page_size). I think we should still communicate a > > maximum number of mappings to provide more control for cases where the > > page size and DAX Window size don't produce a desirable number. > >
> > Consider thatwindow_size= 8 GB andpage_size= 4 KB already yields > > 2,097,152 maximum mappings. Oops, that number is too large! >
> Ok, so that's something which will be in virtiofsd where maximum number > of outstanding can be configured by user and if we cross that limit, >FUSE_SETUPMAPPINGwill be returned with some error?
Quoted 6 lines
Yes, virtiofsd will enforce the limit.
The guest driver will also be aware of the limit via VIRTIO configuration space.
was this addressed?
In this version Stefan has marked SETUPMAPPING to say it can fail if out of resources.
The tricky problem with specifying a limit is that the limit is more likely to be global than to be per-device, and so specifying it in either the virtio config space or (as looked more appropriate) fuse init doesn't feel right.
IMHO we should never hit the limit in practical use, so it's really just a matter of saying that it can fail and setting a large enough limit that non-abusive drivers dont cause a problem.
Dave
Quoted 29 lines
Quoted 29 lines
v4:
* Clarify that there are no request ordering guarantees between requests in a single queue [vgoyal]
* Add explanation of FUSE session endianness detection [dgilbert]v3:
* Remove notifications virtqueue, it's unimplemented and can be added when needed [Miklos]
* Add Security Considerations and Live Migration Considerations sections [Michael]
v2:
* Clean up core virtio file system device spec
* Add DAX windowThese patches add the virtio file system device, which is based on Linux FUSE but includes the DAX window extension. Similar to virtio-scsi, which transports SCSI commands, virtio-fs transports FUSE requests and the protocol documentation is not duplicated here.
The DAX window allows file contents to be accessed directly from shared memory. This eliminates copying of data, reduces the number of vmexits, and reduces the guest's memory footprint. It also allows coherent mmap
MAP_SHAREDsemantics between guests on the same host.Stefan Hajnoczi (2):
content: add virtio file system device
virtio-fs: add DAX window
Quoted 8 lines
Quoted 8 lines
content.tex | 1 + introduction.tex | 3 + virtio-fs.tex | 259 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 263 insertions(+) create mode 100644 virtio-fs.texSignature · 1 line
2.21.0
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 52 lines · Dr. David Alan Gilbert
Quoted 41 lines · * Michael S. Tsirkin ([email protected]) wrote:
Didn't look at the spec yet, but I have a question:
Quoted 5 lines · Stefan Hajnoczi
v5:
* Explain multiqueue semantics: no ordering, identical functionality on each queue, one FUSE session state shared between all queues
* Explain how the FUSE session is started with aFUSE_INITrequest
* Consistently use "submit" vs "made available" and "complete" vs "used" terminology [Michael]
* Explain endianness [Michael]Quoted 8 lines
* Clarify hiprio vs normal queue usage [Michael]
* Move SHOULD, MUST, etc wording into normative sections [Michael]
* Mention thatFUSE_INITnegotiated state needs to be transferred during live migration [Michael]
* State that the DAX window is mapped with writeback caching like RAM [Michael]
* Mention DAX window mapping alignment constraints (they are communicated via the FUSE protocol) [Michael]
* Explain thatFUSE_SETUPMAPPINGfails when device resources are exhausted and that splitting mappings consumes resources too [Michael]
* Clarify access rules to DAX window - only touch memory that has a mapping establised
* Document that DAX data persistence is achieved viaFUSE_FSYNCThe following was raised during v4 review:
> > > > There is a practical problem that the QEMU process may hit the mmap > > > > limit and be unable to perform its own mmaps due to the DAX Window. A > > > > limit must be enforced on the host so that QEMU's internal mmaps > > > > succeed.
> > >
> > > But number of mmaps are already limited by dax window size which is > > > controlled by virtiofsd. So all user has to do is start with smaller > > > dax window size if this ever becomes a concern.
> >
> > Yes, the DAX Window size sets a hard limit on the number of mappings > > (window_size/page_size). I think we should still communicate a > > maximum number of mappings to provide more control for cases where the > > page size and DAX Window size don't produce a desirable number. > >
> > Consider thatwindow_size= 8 GB andpage_size= 4 KB already yields > > 2,097,152 maximum mappings. Oops, that number is too large! >
> Ok, so that's something which will be in virtiofsd where maximum number > of outstanding can be configured by user and if we cross that limit, >FUSE_SETUPMAPPINGwill be returned with some error?Quoted 6 lines
Yes, virtiofsd will enforce the limit.
The guest driver will also be aware of the limit via VIRTIO configuration space.
was this addressed?
In this version Stefan has marked SETUPMAPPING to say it can fail if out of resources.
Quoted 8 lines
The tricky problem with specifying a limit is that the limit is more likely to be global than to be per-device, and so specifying it in either the virtio config space or (as looked more appropriate) fuse init doesn't feel right.
IMHO we should never hit the limit in practical use, so it's really just a matter of saying that it can fail and setting a large enough limit that non-abusive drivers dont cause a problem.
Yep, I updated the spec to mention that FUSE_SETUPMAPPING fails when there are insufficient resources. Drivers expect that it can happen and will have to unmap existing mappings if they wish to make new ones.
Stefan