1 /* 2 * Handler for virtio-blk I/O 3 * 4 * Copyright (C) 2022 Bytedance Inc. and/or its affiliates. All rights reserved. 5 * 6 * Author: 7 * Xie Yongji <xieyongji@bytedance.com> 8 * 9 * This work is licensed under the terms of the GNU GPL, version 2 or 10 * later. See the COPYING file in the top-level directory. 11 */ 12 13 #ifndef VIRTIO_BLK_HANDLER_H 14 #define VIRTIO_BLK_HANDLER_H 15 16 #include "sysemu/block-backend.h" 17 18 #define VIRTIO_BLK_SECTOR_BITS 9 19 #define VIRTIO_BLK_SECTOR_SIZE (1ULL << VIRTIO_BLK_SECTOR_BITS) 20 21 #define VIRTIO_BLK_MAX_DISCARD_SECTORS 32768 22 #define VIRTIO_BLK_MAX_WRITE_ZEROES_SECTORS 32768 23 24 typedef struct { 25 BlockBackend *blk; 26 char *serial; 27 uint32_t logical_block_size; 28 bool writable; 29 } VirtioBlkHandler; 30 31 int coroutine_fn virtio_blk_process_req(VirtioBlkHandler *handler, 32 struct iovec *in_iov, 33 struct iovec *out_iov, 34 unsigned int in_num, 35 unsigned int out_num); 36 37 #endif /* VIRTIO_BLK_HANDLER_H */ 38