xref: /qemu/include/hw/virtio/vhost-user-blk.h (revision cdcb7dcb401757b5853ca99c1967a6d66e1deea5)
100343e4bSChangpeng Liu /*
200343e4bSChangpeng Liu  * vhost-user-blk host device
300343e4bSChangpeng Liu  * Copyright(C) 2017 Intel Corporation.
400343e4bSChangpeng Liu  *
500343e4bSChangpeng Liu  * Authors:
600343e4bSChangpeng Liu  *  Changpeng Liu <changpeng.liu@intel.com>
700343e4bSChangpeng Liu  *
800343e4bSChangpeng Liu  * Based on vhost-scsi.h, Copyright IBM, Corp. 2011
900343e4bSChangpeng Liu  *
1000343e4bSChangpeng Liu  * This work is licensed under the terms of the GNU LGPL, version 2 or later.
1100343e4bSChangpeng Liu  * See the COPYING.LIB file in the top-level directory.
1200343e4bSChangpeng Liu  *
1300343e4bSChangpeng Liu  */
1400343e4bSChangpeng Liu 
1500343e4bSChangpeng Liu #ifndef VHOST_USER_BLK_H
1600343e4bSChangpeng Liu #define VHOST_USER_BLK_H
1700343e4bSChangpeng Liu 
1800343e4bSChangpeng Liu #include "standard-headers/linux/virtio_blk.h"
1900343e4bSChangpeng Liu #include "hw/block/block.h"
2000343e4bSChangpeng Liu #include "chardev/char-fe.h"
2100343e4bSChangpeng Liu #include "hw/virtio/vhost.h"
224d0cf552STiwei Bie #include "hw/virtio/vhost-user.h"
23db1015e9SEduardo Habkost #include "qom/object.h"
2400343e4bSChangpeng Liu 
2500343e4bSChangpeng Liu #define TYPE_VHOST_USER_BLK "vhost-user-blk"
268063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(VHostUserBlk, VHOST_USER_BLK)
2700343e4bSChangpeng Liu 
28a4eef071SStefan Hajnoczi #define VHOST_USER_BLK_AUTO_NUM_QUEUES UINT16_MAX
29a4eef071SStefan Hajnoczi 
30db1015e9SEduardo Habkost struct VHostUserBlk {
3100343e4bSChangpeng Liu     VirtIODevice parent_obj;
3200343e4bSChangpeng Liu     CharBackend chardev;
3300343e4bSChangpeng Liu     int32_t bootindex;
3400343e4bSChangpeng Liu     struct virtio_blk_config blkcfg;
3500343e4bSChangpeng Liu     uint16_t num_queues;
3600343e4bSChangpeng Liu     uint32_t queue_size;
3700343e4bSChangpeng Liu     struct vhost_dev dev;
38a1fe0b8fSXie Yongji     struct vhost_inflight *inflight;
390b99f224SMarc-André Lureau     VhostUserState vhost_user;
4038e245a4SPan Nengyuan     struct vhost_virtqueue *vhost_vqs;
4138e245a4SPan Nengyuan     VirtQueue **virtqs;
42*f5b22d06SDima Stepanov 
43*f5b22d06SDima Stepanov     /*
44*f5b22d06SDima Stepanov      * There are at least two steps of initialization of the
45*f5b22d06SDima Stepanov      * vhost-user device. The first is a "connect" step and
46*f5b22d06SDima Stepanov      * second is a "start" step. Make a separation between
47*f5b22d06SDima Stepanov      * those initialization phases by using two fields.
48*f5b22d06SDima Stepanov      */
49*f5b22d06SDima Stepanov     /* vhost_user_blk_connect/vhost_user_blk_disconnect */
5077542d43SXie Yongji     bool connected;
51*f5b22d06SDima Stepanov     /* vhost_user_blk_start/vhost_user_blk_stop */
52*f5b22d06SDima Stepanov     bool started_vu;
53db1015e9SEduardo Habkost };
5400343e4bSChangpeng Liu 
5500343e4bSChangpeng Liu #endif
56