Skip to content

Commit

Permalink
Introduce vhost-user-blk-test-server
Browse files Browse the repository at this point in the history
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
d-tatianin committed Jan 24, 2024
1 parent 22403f5 commit 8815511
Show file tree
Hide file tree
Showing 4 changed files with 1,251 additions and 0 deletions.
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@ libvhost = static_library(
include_directories: libvhost_includes,
c_args: libvhost_args + libvhost_optional_args + libvhost_defines,
)

subdir('tests')
17 changes: 17 additions & 0 deletions tests/meson.build
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
]
)
37 changes: 37 additions & 0 deletions tests/test_utils.h
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);
}
Loading

0 comments on commit 8815511

Please sign in to comment.