aboutsummaryrefslogtreecommitdiff
path: root/block/export/virtio-blk-handler.h
blob: 150d44cff249f45d6f89eac43969f40fcd0d3028 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * Handler for virtio-blk I/O
 *
 * Copyright (C) 2022 Bytedance Inc. and/or its affiliates. All rights reserved.
 *
 * Author:
 *   Xie Yongji <xieyongji@bytedance.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2 or
 * later.  See the COPYING file in the top-level directory.
 */

#ifndef VIRTIO_BLK_HANDLER_H
#define VIRTIO_BLK_HANDLER_H

#include "sysemu/block-backend.h"

#define VIRTIO_BLK_SECTOR_BITS 9
#define VIRTIO_BLK_SECTOR_SIZE (1ULL << VIRTIO_BLK_SECTOR_BITS)

#define VIRTIO_BLK_MAX_DISCARD_SECTORS 32768
#define VIRTIO_BLK_MAX_WRITE_ZEROES_SECTORS 32768

typedef struct {
    BlockBackend *blk;
    char *serial;
    uint32_t logical_block_size;
    bool writable;
} VirtioBlkHandler;

int coroutine_fn virtio_blk_process_req(VirtioBlkHandler *handler,
                                        struct iovec *in_iov,
                                        struct iovec *out_iov,
                                        unsigned int in_num,
                                        unsigned int out_num);

#endif /* VIRTIO_BLK_HANDLER_H */