]> git.proxmox.com Git - mirror_qemu.git/blame - include/hw/virtio/virtio-blk.h
virtio-net: make VirtIOFeature usable for other virtio devices
[mirror_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 <aliguori@us.ibm.com>
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
2a6a4076
MA
14#ifndef QEMU_VIRTIO_BLK_H
15#define QEMU_VIRTIO_BLK_H
6e02c38d 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;
c99495ac 38 uint32_t request_merging;
84419863 39 uint16_t num_queues;
6040aedd 40 uint16_t queue_size;
12c5674b
PB
41};
42
0d09e41a
PB
43struct VirtIOBlockDataPlane;
44
bf4bd461 45struct VirtIOBlockReq;
f1b24e84 46typedef struct VirtIOBlock {
1cc91b7d 47 VirtIODevice parent_obj;
4be74634 48 BlockBackend *blk;
f1b24e84
FK
49 void *rq;
50 QEMUBH *bh;
2a30307f 51 VirtIOBlkConf conf;
f1b24e84 52 unsigned short sector_mask;
ef5bc962 53 bool original_wce;
f1b24e84 54 VMChangeStateEntry *change;
eb41cf78 55 bool dataplane_disabled;
2906cddf 56 bool dataplane_started;
0d09e41a 57 struct VirtIOBlockDataPlane *dataplane;
bbe8bd4d 58 uint64_t host_features;
f1b24e84
FK
59} VirtIOBlock;
60
09f64587 61typedef struct VirtIOBlockReq {
6aa46d8f 62 VirtQueueElement elem;
95f7142a 63 int64_t sector_num;
09f64587 64 VirtIOBlock *dev;
edaffd9f 65 VirtQueue *vq;
09f64587 66 struct virtio_blk_inhdr *in;
827805a2 67 struct virtio_blk_outhdr out;
09f64587 68 QEMUIOVector qiov;
2a6cdd6d 69 size_t in_len;
09f64587 70 struct VirtIOBlockReq *next;
95f7142a 71 struct VirtIOBlockReq *mr_next;
09f64587
FZ
72 BlockAcctCookie acct;
73} VirtIOBlockReq;
74
95f7142a
PL
75#define VIRTIO_BLK_MAX_MERGE_REQS 32
76
77typedef struct MultiReqBuffer {
78 VirtIOBlockReq *reqs[VIRTIO_BLK_MAX_MERGE_REQS];
79 unsigned int num_reqs;
80 bool is_write;
81} MultiReqBuffer;
82
07931698 83bool virtio_blk_handle_vq(VirtIOBlock *s, VirtQueue *vq);
8a2fad57 84
6e02c38d 85#endif