]> git.proxmox.com Git - qemu.git/blob - hw/virtio-blk.h
virtio-blk: revert serial number support
[qemu.git] / hw / virtio-blk.h
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
14 #ifndef _QEMU_VIRTIO_BLK_H
15 #define _QEMU_VIRTIO_BLK_H
16
17 #include "virtio.h"
18 #include "block.h"
19
20 /* from Linux's linux/virtio_blk.h */
21
22 /* The ID for virtio_block */
23 #define VIRTIO_ID_BLOCK 2
24
25 /* Feature bits */
26 #define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */
27 #define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */
28 #define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */
29 #define VIRTIO_BLK_F_GEOMETRY 4 /* Indicates support of legacy geometry */
30 #define VIRTIO_BLK_F_RO 5 /* Disk is read-only */
31 #define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/
32 #define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */
33 /* #define VIRTIO_BLK_F_IDENTIFY 8 ATA IDENTIFY supported, DEPRECATED */
34 #define VIRTIO_BLK_F_WCACHE 9 /* write cache enabled */
35
36 struct virtio_blk_config
37 {
38 uint64_t capacity;
39 uint32_t size_max;
40 uint32_t seg_max;
41 uint16_t cylinders;
42 uint8_t heads;
43 uint8_t sectors;
44 uint32_t _blk_size; /* structure pad, currently unused */
45 } __attribute__((packed));
46
47 /* These two define direction. */
48 #define VIRTIO_BLK_T_IN 0
49 #define VIRTIO_BLK_T_OUT 1
50
51 /* This bit says it's a scsi command, not an actual read or write. */
52 #define VIRTIO_BLK_T_SCSI_CMD 2
53
54 /* Flush the volatile write cache */
55 #define VIRTIO_BLK_T_FLUSH 4
56
57 /* Barrier before this op. */
58 #define VIRTIO_BLK_T_BARRIER 0x80000000
59
60 /* This is the first element of the read scatter-gather list. */
61 struct virtio_blk_outhdr
62 {
63 /* VIRTIO_BLK_T* */
64 uint32_t type;
65 /* io priority. */
66 uint32_t ioprio;
67 /* Sector (ie. 512 byte offset) */
68 uint64_t sector;
69 };
70
71 #define VIRTIO_BLK_S_OK 0
72 #define VIRTIO_BLK_S_IOERR 1
73 #define VIRTIO_BLK_S_UNSUPP 2
74
75 /* This is the last element of the write scatter-gather list */
76 struct virtio_blk_inhdr
77 {
78 unsigned char status;
79 };
80
81 /* SCSI pass-through header */
82 struct virtio_scsi_inhdr
83 {
84 uint32_t errors;
85 uint32_t data_len;
86 uint32_t sense_len;
87 uint32_t residual;
88 };
89
90 #ifdef __linux__
91 #define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \
92 DEFINE_VIRTIO_COMMON_FEATURES(_state, _field), \
93 DEFINE_PROP_BIT("scsi", _state, _field, VIRTIO_BLK_F_SCSI, true)
94 #else
95 #define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \
96 DEFINE_VIRTIO_COMMON_FEATURES(_state, _field)
97 #endif
98 #endif