The block interface is defined by the structures passed over the
shared memory interface. These structures are either requests (from
the frontend to the backend) or responses (from the backend to the
frontend).
The request structure is defined as follows:
typedef struct blkif_request {
uint8_t operation; /* BLKIF_OP_??? */
uint8_t nr_segments; /* number of segments */
blkif_vdev_t handle; /* only for read/write requests */
uint64_t id; /* private guest value, echoed in resp */
blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
struct blkif_request_segment {
grant_ref_t gref; /* reference to I/O buffer frame */
/* @first_sect: first sector in frame to transfer (inclusive). */
/* @last_sect: last sector in frame to transfer (inclusive). */
uint8_t first_sect, last_sect;
} seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
} blkif_request_t;
The fields are as follows:
- operation
- operation ID: one of the operations described above
- nr_segments
- number of segments for scatter / gather IO
described by this request
- handle
- identifier for a particular virtual device on this
interface
- id
- this value is echoed in the response message for this IO;
the guest may use it to identify the original request
- sector_number
- start sector on the virtal device for this
request
- frame_and_sects
- This array contains structures encoding
scatter-gather IO to be performed:
- gref
- The grant reference for the foreign I/O buffer page.
- first_sect
- First sector to access within the buffer page (0 to 7).
- last_sect
- Last sector to access within the buffer page (0 to 7).
Data will be transferred into frames at an offset determined by the
value of first_sect.