4 * Copyright IBM, Corp. 2007
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
14 #ifndef _QEMU_VIRTIO_BLK_H
15 #define _QEMU_VIRTIO_BLK_H
20 /* from Linux's linux/virtio_blk.h */
22 /* The ID for virtio_block */
23 #define VIRTIO_ID_BLOCK 2
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 #define VIRTIO_BLK_F_TOPOLOGY 10 /* Topology information is available */
37 struct virtio_blk_config
46 uint8_t physical_block_exp
;
47 uint8_t alignment_offset
;
50 } __attribute__((packed
));
52 /* These two define direction. */
53 #define VIRTIO_BLK_T_IN 0
54 #define VIRTIO_BLK_T_OUT 1
56 /* This bit says it's a scsi command, not an actual read or write. */
57 #define VIRTIO_BLK_T_SCSI_CMD 2
59 /* Flush the volatile write cache */
60 #define VIRTIO_BLK_T_FLUSH 4
62 /* return the device ID string */
63 #define VIRTIO_BLK_T_GET_ID 8
65 /* Barrier before this op. */
66 #define VIRTIO_BLK_T_BARRIER 0x80000000
68 /* This is the first element of the read scatter-gather list. */
69 struct virtio_blk_outhdr
75 /* Sector (ie. 512 byte offset) */
79 #define VIRTIO_BLK_S_OK 0
80 #define VIRTIO_BLK_S_IOERR 1
81 #define VIRTIO_BLK_S_UNSUPP 2
83 /* This is the last element of the write scatter-gather list */
84 struct virtio_blk_inhdr
89 /* SCSI pass-through header */
90 struct virtio_scsi_inhdr
99 #define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \
100 DEFINE_VIRTIO_COMMON_FEATURES(_state, _field), \
101 DEFINE_PROP_BIT("scsi", _state, _field, VIRTIO_BLK_F_SCSI, true)
103 #define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \
104 DEFINE_VIRTIO_COMMON_FEATURES(_state, _field)