]> Git Repo - qemu.git/blame - include/hw/virtio/virtio-blk.h
piix: create host bridge to passthrough
[qemu.git] / include / hw / virtio / virtio-blk.h
CommitLineData
6e02c38d
AL
1/*
2 * Virtio Block Device
3 *
4 * Copyright IBM, Corp. 2007
5 *
6 * Authors:
7 * Anthony Liguori <[email protected]>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
11 *
12 */
13
14#ifndef _QEMU_VIRTIO_BLK_H
15#define _QEMU_VIRTIO_BLK_H
16
907eb3e5 17#include "standard-headers/linux/virtio_blk.h"
0d09e41a
PB
18#include "hw/virtio/virtio.h"
19#include "hw/block/block.h"
48ff2692 20#include "sysemu/iothread.h"
4be74634 21#include "sysemu/block-backend.h"
6e02c38d 22
f574fa8b 23#define TYPE_VIRTIO_BLK "virtio-blk-device"
1c028ddf
FK
24#define VIRTIO_BLK(obj) \
25 OBJECT_CHECK(VirtIOBlock, (obj), TYPE_VIRTIO_BLK)
26
8b91408b 27/* This is the last element of the write scatter-gather list */
6e02c38d
AL
28struct virtio_blk_inhdr
29{
30 unsigned char status;
31};
32
12c5674b
PB
33struct VirtIOBlkConf
34{
35 BlockConf conf;
48ff2692 36 IOThread *iothread;
12c5674b 37 char *serial;
a6c5c84a 38 uint32_t scsi;
8a873ba7 39 uint32_t config_wce;
e72f66a0 40 uint32_t data_plane;
c99495ac 41 uint32_t request_merging;
12c5674b
PB
42};
43
0d09e41a
PB
44struct VirtIOBlockDataPlane;
45
bf4bd461 46struct VirtIOBlockReq;
f1b24e84 47typedef struct VirtIOBlock {
1cc91b7d 48 VirtIODevice parent_obj;
4be74634 49 BlockBackend *blk;
f1b24e84
FK
50 VirtQueue *vq;
51 void *rq;
52 QEMUBH *bh;
2a30307f 53 VirtIOBlkConf conf;
f1b24e84 54 unsigned short sector_mask;
ef5bc962 55 bool original_wce;
f1b24e84 56 VMChangeStateEntry *change;
bf4bd461
FZ
57 /* Function to push to vq and notify guest */
58 void (*complete_request)(struct VirtIOBlockReq *req, unsigned char status);
84db52d0 59 Notifier migration_state_notifier;
0d09e41a 60 struct VirtIOBlockDataPlane *dataplane;
f1b24e84
FK
61} VirtIOBlock;
62
09f64587 63typedef struct VirtIOBlockReq {
95f7142a 64 int64_t sector_num;
09f64587 65 VirtIOBlock *dev;
f897bf75 66 VirtQueueElement elem;
09f64587 67 struct virtio_blk_inhdr *in;
827805a2 68 struct virtio_blk_outhdr out;
09f64587 69 QEMUIOVector qiov;
2a6cdd6d 70 size_t in_len;
09f64587 71 struct VirtIOBlockReq *next;
95f7142a 72 struct VirtIOBlockReq *mr_next;
09f64587
FZ
73 BlockAcctCookie acct;
74} VirtIOBlockReq;
75
95f7142a
PL
76#define VIRTIO_BLK_MAX_MERGE_REQS 32
77
78typedef struct MultiReqBuffer {
79 VirtIOBlockReq *reqs[VIRTIO_BLK_MAX_MERGE_REQS];
80 unsigned int num_reqs;
81 bool is_write;
82} MultiReqBuffer;
83
f897bf75
SH
84VirtIOBlockReq *virtio_blk_alloc_request(VirtIOBlock *s);
85
86void virtio_blk_free_request(VirtIOBlockReq *req);
87
fee65db7
FZ
88void virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb);
89
95f7142a 90void virtio_blk_submit_multireq(BlockBackend *blk, MultiReqBuffer *mrb);
fee65db7 91
6e02c38d 92#endif
This page took 0.84651 seconds and 4 git commands to generate.