forked from vitalif/vitastor
Add RDMA options to the QEMU driver
parent
971aa4ae4f
commit
6a6fd6544d
|
@ -47,6 +47,10 @@ typedef struct VitastorClient
|
||||||
uint64_t pool;
|
uint64_t pool;
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
long readonly;
|
long readonly;
|
||||||
|
char *rdma_device;
|
||||||
|
int rdma_port_num;
|
||||||
|
int rdma_gid_index;
|
||||||
|
int rdma_mtu;
|
||||||
QemuMutex mutex;
|
QemuMutex mutex;
|
||||||
} VitastorClient;
|
} VitastorClient;
|
||||||
|
|
||||||
|
@ -95,7 +99,7 @@ static void qemu_rbd_unescape(char *src)
|
||||||
}
|
}
|
||||||
|
|
||||||
// vitastor[:key=value]*
|
// vitastor[:key=value]*
|
||||||
// vitastor:etcd_host=127.0.0.1:inode=1:pool=1
|
// vitastor:etcd_host=127.0.0.1:inode=1:pool=1[:rdma_gid_index=3]
|
||||||
static void vitastor_parse_filename(const char *filename, QDict *options, Error **errp)
|
static void vitastor_parse_filename(const char *filename, QDict *options, Error **errp)
|
||||||
{
|
{
|
||||||
const char *start;
|
const char *start;
|
||||||
|
@ -123,7 +127,12 @@ static void vitastor_parse_filename(const char *filename, QDict *options, Error
|
||||||
qemu_rbd_unescape(name);
|
qemu_rbd_unescape(name);
|
||||||
value = qemu_rbd_next_tok(p, ':', &p);
|
value = qemu_rbd_next_tok(p, ':', &p);
|
||||||
qemu_rbd_unescape(value);
|
qemu_rbd_unescape(value);
|
||||||
if (!strcmp(name, "inode") || !strcmp(name, "pool") || !strcmp(name, "size"))
|
if (!strcmp(name, "inode") ||
|
||||||
|
!strcmp(name, "pool") ||
|
||||||
|
!strcmp(name, "size") ||
|
||||||
|
!strcmp(name, "rdma_port_num") ||
|
||||||
|
!strcmp(name, "rdma_gid_index") ||
|
||||||
|
!strcmp(name, "rdma_mtu"))
|
||||||
{
|
{
|
||||||
unsigned long long num_val;
|
unsigned long long num_val;
|
||||||
if (parse_uint_full(value, &num_val, 0))
|
if (parse_uint_full(value, &num_val, 0))
|
||||||
|
@ -191,7 +200,14 @@ static int vitastor_file_open(BlockDriverState *bs, QDict *options, int flags, E
|
||||||
qemu_mutex_init(&client->mutex);
|
qemu_mutex_init(&client->mutex);
|
||||||
client->etcd_host = g_strdup(qdict_get_try_str(options, "etcd_host"));
|
client->etcd_host = g_strdup(qdict_get_try_str(options, "etcd_host"));
|
||||||
client->etcd_prefix = g_strdup(qdict_get_try_str(options, "etcd_prefix"));
|
client->etcd_prefix = g_strdup(qdict_get_try_str(options, "etcd_prefix"));
|
||||||
client->proxy = vitastor_proxy_create(bdrv_get_aio_context(bs), client->etcd_host, client->etcd_prefix);
|
client->rdma_device = g_strdup(qdict_get_try_str(options, "rdma_device"));
|
||||||
|
client->rdma_port_num = qdict_get_int(options, "rdma_port_num");
|
||||||
|
client->rdma_gid_index = qdict_get_int(options, "rdma_gid_index");
|
||||||
|
client->rdma_mtu = qdict_get_int(options, "rdma_mtu");
|
||||||
|
client->proxy = vitastor_proxy_create(
|
||||||
|
bdrv_get_aio_context(bs), client->etcd_host, client->etcd_prefix,
|
||||||
|
client->rdma_device, client->rdma_port_num, client->rdma_gid_index, client->rdma_mtu
|
||||||
|
);
|
||||||
client->image = g_strdup(qdict_get_try_str(options, "image"));
|
client->image = g_strdup(qdict_get_try_str(options, "image"));
|
||||||
client->readonly = (flags & BDRV_O_RDWR) ? 1 : 0;
|
client->readonly = (flags & BDRV_O_RDWR) ? 1 : 0;
|
||||||
if (client->image)
|
if (client->image)
|
||||||
|
@ -241,6 +257,10 @@ static int vitastor_file_open(BlockDriverState *bs, QDict *options, int flags, E
|
||||||
}
|
}
|
||||||
bs->total_sectors = client->size / BDRV_SECTOR_SIZE;
|
bs->total_sectors = client->size / BDRV_SECTOR_SIZE;
|
||||||
//client->aio_context = bdrv_get_aio_context(bs);
|
//client->aio_context = bdrv_get_aio_context(bs);
|
||||||
|
qdict_del(options, "rdma_mtu");
|
||||||
|
qdict_del(options, "rdma_gid_index");
|
||||||
|
qdict_del(options, "rdma_port_num");
|
||||||
|
qdict_del(options, "rdma_device");
|
||||||
qdict_del(options, "etcd_host");
|
qdict_del(options, "etcd_host");
|
||||||
qdict_del(options, "etcd_prefix");
|
qdict_del(options, "etcd_prefix");
|
||||||
qdict_del(options, "image");
|
qdict_del(options, "image");
|
||||||
|
|
|
@ -34,12 +34,17 @@ public:
|
||||||
cluster_client_t *cli;
|
cluster_client_t *cli;
|
||||||
AioContext *ctx;
|
AioContext *ctx;
|
||||||
|
|
||||||
QemuProxy(AioContext *ctx, const char *etcd_host, const char *etcd_prefix)
|
QemuProxy(AioContext *ctx, const char *etcd_host, const char *etcd_prefix,
|
||||||
|
const char *rdma_device, int rdma_port_num, int rdma_gid_index, int rdma_mtu)
|
||||||
{
|
{
|
||||||
this->ctx = ctx;
|
this->ctx = ctx;
|
||||||
json11::Json cfg = json11::Json::object {
|
json11::Json cfg = json11::Json::object {
|
||||||
{ "etcd_address", std::string(etcd_host) },
|
{ "etcd_address", std::string(etcd_host) },
|
||||||
{ "etcd_prefix", std::string(etcd_prefix ? etcd_prefix : "/vitastor") },
|
{ "etcd_prefix", std::string(etcd_prefix ? etcd_prefix : "/vitastor") },
|
||||||
|
{ "rdma_device", std::string(rdma_device ? rdma_device : "") },
|
||||||
|
{ "rdma_port_num", rdma_port_num },
|
||||||
|
{ "rdma_gid_index", rdma_gid_index },
|
||||||
|
{ "rdma_mtu", rdma_mtu },
|
||||||
};
|
};
|
||||||
tfd = new timerfd_manager_t([this](int fd, bool wr, std::function<void(int, int)> callback) { set_fd_handler(fd, wr, callback); });
|
tfd = new timerfd_manager_t([this](int fd, bool wr, std::function<void(int, int)> callback) { set_fd_handler(fd, wr, callback); });
|
||||||
cli = new cluster_client_t(NULL, tfd, cfg);
|
cli = new cluster_client_t(NULL, tfd, cfg);
|
||||||
|
@ -80,9 +85,10 @@ public:
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
void* vitastor_proxy_create(AioContext *ctx, const char *etcd_host, const char *etcd_prefix)
|
void* vitastor_proxy_create(AioContext *ctx, const char *etcd_host, const char *etcd_prefix,
|
||||||
|
const char *rdma_device, int rdma_port_num, int rdma_gid_index, int rdma_mtu)
|
||||||
{
|
{
|
||||||
QemuProxy *p = new QemuProxy(ctx, etcd_host, etcd_prefix);
|
QemuProxy *p = new QemuProxy(ctx, etcd_host, etcd_prefix, rdma_device, rdma_port_num, rdma_gid_index, rdma_mtu);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ extern "C" {
|
||||||
|
|
||||||
// Our exports
|
// Our exports
|
||||||
typedef void VitastorIOHandler(long retval, void *opaque);
|
typedef void VitastorIOHandler(long retval, void *opaque);
|
||||||
void* vitastor_proxy_create(AioContext *ctx, const char *etcd_host, const char *etcd_prefix);
|
void* vitastor_proxy_create(AioContext *ctx, const char *etcd_host, const char *etcd_prefix,
|
||||||
|
const char *rdma_device, int rdma_port_num, int rdma_gid_index, int rdma_mtu);
|
||||||
void vitastor_proxy_destroy(void *client);
|
void vitastor_proxy_destroy(void *client);
|
||||||
void vitastor_proxy_rw(int write, void *client, uint64_t inode, uint64_t offset, uint64_t len,
|
void vitastor_proxy_rw(int write, void *client, uint64_t inode, uint64_t offset, uint64_t len,
|
||||||
struct iovec *iov, int iovcnt, VitastorIOHandler cb, void *opaque);
|
struct iovec *iov, int iovcnt, VitastorIOHandler cb, void *opaque);
|
||||||
|
|
Loading…
Reference in New Issue