forked from TheNewNormal/libxhyve
-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
mirage_block_c.h
62 lines (50 loc) · 1.94 KB
/
mirage_block_c.h
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// +build qcow2
/*
* C interface to the mirage-block subsystem
*
* Rules for usage:
* - do not mix with other libraries which embed OCaml runtimes
* - before calling any other function, call `mirage_block_init` from one
* thread: this initialises the runtime
* - before calling open, register your thread with `mirage_block_register_thread`
*/
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
/* Initialise the mirage-block subsystem. This must be called before calling
mirage_block_register_thread. */
extern void
mirage_block_init(void);
/* Every thread that uses a mirage-block device must be registered with the
runtime system. Call this on every thread you will use, after calling
mirage_block_init once in one thread. */
extern void
mirage_block_register_thread(void);
/* When a thread has finished using mirage-block devices, call this to free
associated resources. */
extern void
mirage_block_unregister_thread(void);
/* An opened mirage-block device */
typedef int mirage_block_handle;
/* Open a mirage block device with the given string configuration. */
extern mirage_block_handle
mirage_block_open(const char *config);
/* Query a mirage block device. */
extern int
mirage_block_stat(mirage_block_handle h, struct stat *buf);
/* Read data from a mirage block device. Note the offset must be sector-aligned
and the memory buffers must also be sector-aligned. */
extern ssize_t
mirage_block_preadv(mirage_block_handle h,
const struct iovec *iov, int iovcnt, off_t offset);
/* Write data to a mirage block device. Note the offset must be sector-aligned
and the memory buffers must also be sector-aligned. */
extern ssize_t
mirage_block_pwritev(mirage_block_handle h,
const struct iovec *iov, int iovcnt, off_t offset);
/* Flush any outstanding I/O */
extern
int mirage_block_flush(mirage_block_handle h);
/* Close an open device; subsequent I/O requests will fail. */
extern
int mirage_block_close(mirage_block_handle h);