-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce vhost-user-blk-test-server
This is a test vhost-user blk server that uses libvhost combined with libaio basically acting as a proxy between a virtual disk and an actual file on disk or a block device. It has near native bare-metal performance when measured using fio+io_uring in a linux guest on QEMU vs bare-metal fio on a physical nvme namespace. Signed-off-by: Daniil Tatianin <[email protected]>
- Loading branch information
1 parent
22403f5
commit 8815511
Showing
4 changed files
with
1,251 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
libaio = cc.find_library('aio', required: true) | ||
libpthread = cc.find_library('pthread', required: true) | ||
|
||
vhost_user_blk_test_server_includes = include_directories( | ||
'../' | ||
) | ||
|
||
vhost_user_blk_test_server = executable( | ||
'vhost-user-blk-test-server', | ||
'vhost_user_blk_test_server.c', | ||
link_with: libvhost, | ||
dependencies: [libaio, libpthread], | ||
include_directories: [ | ||
vhost_user_blk_test_server_includes, | ||
libvhost_includes | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <stdarg.h> | ||
#include <stdio.h> | ||
#include <sys/time.h> | ||
#include <time.h> | ||
#include "vhost/server.h" | ||
|
||
/* Normally we pass LOG_VERBOSITY from make */ | ||
#ifndef LOG_VERBOSITY | ||
# define LOG_VERBOSITY LOG_INFO | ||
#endif | ||
|
||
/* Log function for tests */ | ||
static const char *log_level_str[] = { | ||
"ERROR", | ||
"WARNING", | ||
"INFO", | ||
"DEBUG" | ||
}; | ||
|
||
__attribute__((format(printf, 2, 3))) | ||
static inline void vhd_log_stderr(enum LogLevel level, const char *fmt, ...) | ||
{ | ||
va_list args; | ||
va_start(args, fmt); | ||
if (level <= LOG_VERBOSITY) { | ||
char timestr[64]; | ||
struct timeval tv; | ||
|
||
gettimeofday(&tv, NULL); | ||
strftime(timestr, sizeof(timestr), "%F %T", localtime(&tv.tv_sec)); | ||
fprintf(stderr, "%s.%03ld [%8s] ", timestr, tv.tv_usec / 1000, | ||
log_level_str[level]); | ||
vfprintf(stderr, fmt, args); | ||
fprintf(stderr, "\n"); | ||
} | ||
va_end(args); | ||
} |
Oops, something went wrong.