mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 09:13:55 -06:00
Add virtio-blk support
Virtio-blk is a paravirtual block device based on VirtIO. It can be used by specifying the if=virtio parameter to the -drive parameter. When using -enable-kvm, it can achieve very good performance compared to IDE or SCSI. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5870 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
967f97fa00
commit
6e02c38dad
7 changed files with 346 additions and 5 deletions
76
hw/virtio-blk.h
Normal file
76
hw/virtio-blk.h
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Virtio Block Device
|
||||
*
|
||||
* Copyright IBM, Corp. 2007
|
||||
*
|
||||
* Authors:
|
||||
* Anthony Liguori <aliguori@us.ibm.com>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2. See
|
||||
* the COPYING file in the top-level directory.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _QEMU_VIRTIO_BLK_H
|
||||
#define _QEMU_VIRTIO_BLK_H
|
||||
|
||||
#include "virtio.h"
|
||||
#include "block.h"
|
||||
#include "pci.h"
|
||||
|
||||
/* from Linux's linux/virtio_blk.h */
|
||||
|
||||
/* The ID for virtio_block */
|
||||
#define VIRTIO_ID_BLOCK 2
|
||||
|
||||
/* Feature bits */
|
||||
#define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */
|
||||
#define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */
|
||||
#define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */
|
||||
#define VIRTIO_BLK_F_GEOMETRY 4 /* Indicates support of legacy geometry */
|
||||
|
||||
struct virtio_blk_config
|
||||
{
|
||||
uint64_t capacity;
|
||||
uint32_t size_max;
|
||||
uint32_t seg_max;
|
||||
uint16_t cylinders;
|
||||
uint8_t heads;
|
||||
uint8_t sectors;
|
||||
} __attribute__((packed));
|
||||
|
||||
/* These two define direction. */
|
||||
#define VIRTIO_BLK_T_IN 0
|
||||
#define VIRTIO_BLK_T_OUT 1
|
||||
|
||||
/* This bit says it's a scsi command, not an actual read or write. */
|
||||
#define VIRTIO_BLK_T_SCSI_CMD 2
|
||||
|
||||
/* Barrier before this op. */
|
||||
#define VIRTIO_BLK_T_BARRIER 0x80000000
|
||||
|
||||
/* This is the first element of the read scatter-gather list. */
|
||||
struct virtio_blk_outhdr
|
||||
{
|
||||
/* VIRTIO_BLK_T* */
|
||||
uint32_t type;
|
||||
/* io priority. */
|
||||
uint32_t ioprio;
|
||||
/* Sector (ie. 512 byte offset) */
|
||||
uint64_t sector;
|
||||
};
|
||||
|
||||
#define VIRTIO_BLK_S_OK 0
|
||||
#define VIRTIO_BLK_S_IOERR 1
|
||||
#define VIRTIO_BLK_S_UNSUPP 2
|
||||
|
||||
/* This is the first element of the write scatter-gather list */
|
||||
struct virtio_blk_inhdr
|
||||
{
|
||||
unsigned char status;
|
||||
};
|
||||
|
||||
void *virtio_blk_init(PCIBus *bus, uint16_t vendor, uint16_t device,
|
||||
BlockDriverState *bs);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue