mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 18:05:37 +00:00
block/rbd: parse all options via bdrv_parse_filename
Get rid of qemu_rbd_parsename in favor of bdrv_parse_filename. This simplifies a lot of the parsing as well, as we can treat everything a bit simpler since nonexistent options are simply NULL pointers instead of empty strings. An important item to note: Ceph has many extra option values that can be specified as key/value pairs. This was handled previously in the driver by extracting the values that the QEMU driver cared about, and then blindly passing all extra options to rbd after splitting them into key/value pairs, and cleaning up any special character escaping. The practice is continued in this patch; there is an option "keyvalue-pairs" that is populated with all the key/value pairs that the QEMU driver does not care about. These key/value pairs will override any settings in the 'conf' configuration file, just as they did before. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Jeff Cody <jcody@redhat.com>
This commit is contained in:
parent
0f9d252de4
commit
c7cacb3e7a
303
block/rbd.c
303
block/rbd.c
|
@ -18,6 +18,7 @@
|
||||||
#include "block/block_int.h"
|
#include "block/block_int.h"
|
||||||
#include "crypto/secret.h"
|
#include "crypto/secret.h"
|
||||||
#include "qemu/cutils.h"
|
#include "qemu/cutils.h"
|
||||||
|
#include "qapi/qmp/qstring.h"
|
||||||
|
|
||||||
#include <rbd/librbd.h>
|
#include <rbd/librbd.h>
|
||||||
|
|
||||||
|
@ -151,113 +152,134 @@ static void qemu_rbd_unescape(char *src)
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qemu_rbd_parsename(const char *filename,
|
static void qemu_rbd_parse_filename(const char *filename, QDict *options,
|
||||||
char *pool, int pool_len,
|
Error **errp)
|
||||||
char *snap, int snap_len,
|
|
||||||
char *name, int name_len,
|
|
||||||
char *conf, int conf_len,
|
|
||||||
Error **errp)
|
|
||||||
{
|
{
|
||||||
const char *start;
|
const char *start;
|
||||||
char *p, *buf;
|
char *p, *buf, *keypairs;
|
||||||
int ret = 0;
|
|
||||||
char *found_str;
|
char *found_str;
|
||||||
|
size_t max_keypair_size;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
|
||||||
if (!strstart(filename, "rbd:", &start)) {
|
if (!strstart(filename, "rbd:", &start)) {
|
||||||
error_setg(errp, "File name must start with 'rbd:'");
|
error_setg(errp, "File name must start with 'rbd:'");
|
||||||
return -EINVAL;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
max_keypair_size = strlen(start) + 1;
|
||||||
buf = g_strdup(start);
|
buf = g_strdup(start);
|
||||||
|
keypairs = g_malloc0(max_keypair_size);
|
||||||
p = buf;
|
p = buf;
|
||||||
*snap = '\0';
|
|
||||||
*conf = '\0';
|
|
||||||
|
|
||||||
found_str = qemu_rbd_next_tok(pool_len, p,
|
found_str = qemu_rbd_next_tok(RBD_MAX_POOL_NAME_SIZE, p,
|
||||||
'/', "pool name", &p, &local_err);
|
'/', "pool name", &p, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (!p) {
|
if (!p) {
|
||||||
ret = -EINVAL;
|
|
||||||
error_setg(errp, "Pool name is required");
|
error_setg(errp, "Pool name is required");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
qemu_rbd_unescape(found_str);
|
qemu_rbd_unescape(found_str);
|
||||||
g_strlcpy(pool, found_str, pool_len);
|
qdict_put(options, "pool", qstring_from_str(found_str));
|
||||||
|
|
||||||
if (strchr(p, '@')) {
|
if (strchr(p, '@')) {
|
||||||
found_str = qemu_rbd_next_tok(name_len, p,
|
found_str = qemu_rbd_next_tok(RBD_MAX_IMAGE_NAME_SIZE, p,
|
||||||
'@', "object name", &p, &local_err);
|
'@', "object name", &p, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
qemu_rbd_unescape(found_str);
|
qemu_rbd_unescape(found_str);
|
||||||
g_strlcpy(name, found_str, name_len);
|
qdict_put(options, "image", qstring_from_str(found_str));
|
||||||
|
|
||||||
found_str = qemu_rbd_next_tok(snap_len, p,
|
found_str = qemu_rbd_next_tok(RBD_MAX_SNAP_NAME_SIZE, p,
|
||||||
':', "snap name", &p, &local_err);
|
':', "snap name", &p, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
qemu_rbd_unescape(found_str);
|
qemu_rbd_unescape(found_str);
|
||||||
g_strlcpy(snap, found_str, snap_len);
|
qdict_put(options, "snapshot", qstring_from_str(found_str));
|
||||||
} else {
|
} else {
|
||||||
found_str = qemu_rbd_next_tok(name_len, p,
|
found_str = qemu_rbd_next_tok(RBD_MAX_IMAGE_NAME_SIZE, p,
|
||||||
':', "object name", &p, &local_err);
|
':', "object name", &p, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
qemu_rbd_unescape(found_str);
|
qemu_rbd_unescape(found_str);
|
||||||
g_strlcpy(name, found_str, name_len);
|
qdict_put(options, "image", qstring_from_str(found_str));
|
||||||
}
|
}
|
||||||
if (!p) {
|
if (!p) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
found_str = qemu_rbd_next_tok(conf_len, p,
|
found_str = qemu_rbd_next_tok(RBD_MAX_CONF_NAME_SIZE, p,
|
||||||
'\0', "configuration", &p, &local_err);
|
'\0', "configuration", &p, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
g_strlcpy(conf, found_str, conf_len);
|
|
||||||
|
p = found_str;
|
||||||
|
|
||||||
|
/* The following are essentially all key/value pairs, and we treat
|
||||||
|
* 'id' and 'conf' a bit special. Key/value pairs may be in any order. */
|
||||||
|
while (p) {
|
||||||
|
char *name, *value;
|
||||||
|
name = qemu_rbd_next_tok(RBD_MAX_CONF_NAME_SIZE, p,
|
||||||
|
'=', "conf option name", &p, &local_err);
|
||||||
|
if (local_err) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!p) {
|
||||||
|
error_setg(errp, "conf option %s has no value", name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
qemu_rbd_unescape(name);
|
||||||
|
|
||||||
|
value = qemu_rbd_next_tok(RBD_MAX_CONF_VAL_SIZE, p,
|
||||||
|
':', "conf option value", &p, &local_err);
|
||||||
|
if (local_err) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
qemu_rbd_unescape(value);
|
||||||
|
|
||||||
|
if (!strcmp(name, "conf")) {
|
||||||
|
qdict_put(options, "conf", qstring_from_str(value));
|
||||||
|
} else if (!strcmp(name, "id")) {
|
||||||
|
qdict_put(options, "user" , qstring_from_str(value));
|
||||||
|
} else {
|
||||||
|
/* FIXME: This is pretty ugly, and not the right way to do this.
|
||||||
|
* These should be contained in a structure, and then
|
||||||
|
* passed explicitly as individual key/value pairs to
|
||||||
|
* rados. Consider this legacy code that needs to be
|
||||||
|
* updated. */
|
||||||
|
char *tmp = g_malloc0(max_keypair_size);
|
||||||
|
/* only use a delimiter if it is not the first keypair found */
|
||||||
|
/* These are sets of unknown key/value pairs we'll pass along
|
||||||
|
* to ceph */
|
||||||
|
if (keypairs[0]) {
|
||||||
|
snprintf(tmp, max_keypair_size, ":%s=%s", name, value);
|
||||||
|
pstrcat(keypairs, max_keypair_size, tmp);
|
||||||
|
} else {
|
||||||
|
snprintf(keypairs, max_keypair_size, "%s=%s", name, value);
|
||||||
|
}
|
||||||
|
g_free(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keypairs[0]) {
|
||||||
|
qdict_put(options, "keyvalue-pairs", qstring_from_str(keypairs));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
ret = -EINVAL;
|
|
||||||
error_propagate(errp, local_err);
|
error_propagate(errp, local_err);
|
||||||
}
|
}
|
||||||
g_free(buf);
|
g_free(buf);
|
||||||
return ret;
|
g_free(keypairs);
|
||||||
}
|
return;
|
||||||
|
|
||||||
static char *qemu_rbd_parse_clientname(const char *conf, char *clientname)
|
|
||||||
{
|
|
||||||
const char *p = conf;
|
|
||||||
|
|
||||||
while (*p) {
|
|
||||||
int len;
|
|
||||||
const char *end = strchr(p, ':');
|
|
||||||
|
|
||||||
if (end) {
|
|
||||||
len = end - p;
|
|
||||||
} else {
|
|
||||||
len = strlen(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strncmp(p, "id=", 3) == 0) {
|
|
||||||
len -= 3;
|
|
||||||
strncpy(clientname, p + 3, len);
|
|
||||||
clientname[len] = '\0';
|
|
||||||
return clientname;
|
|
||||||
}
|
|
||||||
if (end == NULL) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
p = end + 1;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -280,10 +302,8 @@ static int qemu_rbd_set_auth(rados_t cluster, const char *secretid,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int qemu_rbd_set_keypairs(rados_t cluster, const char *keypairs,
|
||||||
static int qemu_rbd_set_conf(rados_t cluster, const char *conf,
|
Error **errp)
|
||||||
bool only_read_conf_file,
|
|
||||||
Error **errp)
|
|
||||||
{
|
{
|
||||||
char *p, *buf;
|
char *p, *buf;
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -291,7 +311,7 @@ static int qemu_rbd_set_conf(rados_t cluster, const char *conf,
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
buf = g_strdup(conf);
|
buf = g_strdup(keypairs);
|
||||||
p = buf;
|
p = buf;
|
||||||
|
|
||||||
while (p) {
|
while (p) {
|
||||||
|
@ -300,7 +320,6 @@ static int qemu_rbd_set_conf(rados_t cluster, const char *conf,
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
qemu_rbd_unescape(name);
|
|
||||||
|
|
||||||
if (!p) {
|
if (!p) {
|
||||||
error_setg(errp, "conf option %s has no value", name);
|
error_setg(errp, "conf option %s has no value", name);
|
||||||
|
@ -313,28 +332,12 @@ static int qemu_rbd_set_conf(rados_t cluster, const char *conf,
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
qemu_rbd_unescape(value);
|
|
||||||
|
|
||||||
if (strcmp(name, "conf") == 0) {
|
ret = rados_conf_set(cluster, name, value);
|
||||||
/* read the conf file alone, so it doesn't override more
|
if (ret < 0) {
|
||||||
specific settings for a particular device */
|
error_setg_errno(errp, -ret, "invalid conf option %s", name);
|
||||||
if (only_read_conf_file) {
|
ret = -EINVAL;
|
||||||
ret = rados_conf_read_file(cluster, value);
|
break;
|
||||||
if (ret < 0) {
|
|
||||||
error_setg_errno(errp, -ret, "error reading conf file %s",
|
|
||||||
value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (strcmp(name, "id") == 0) {
|
|
||||||
/* ignore, this is parsed by qemu_rbd_parse_clientname() */
|
|
||||||
} else if (!only_read_conf_file) {
|
|
||||||
ret = rados_conf_set(cluster, name, value);
|
|
||||||
if (ret < 0) {
|
|
||||||
error_setg_errno(errp, -ret, "invalid conf option %s", name);
|
|
||||||
ret = -EINVAL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,27 +415,16 @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||||
int64_t bytes = 0;
|
int64_t bytes = 0;
|
||||||
int64_t objsize;
|
int64_t objsize;
|
||||||
int obj_order = 0;
|
int obj_order = 0;
|
||||||
char pool[RBD_MAX_POOL_NAME_SIZE];
|
const char *pool, *name, *conf, *clientname, *keypairs;
|
||||||
char name[RBD_MAX_IMAGE_NAME_SIZE];
|
|
||||||
char snap_buf[RBD_MAX_SNAP_NAME_SIZE];
|
|
||||||
char conf[RBD_MAX_CONF_SIZE];
|
|
||||||
char clientname_buf[RBD_MAX_CONF_SIZE];
|
|
||||||
char *clientname;
|
|
||||||
const char *secretid;
|
const char *secretid;
|
||||||
rados_t cluster;
|
rados_t cluster;
|
||||||
rados_ioctx_t io_ctx;
|
rados_ioctx_t io_ctx;
|
||||||
int ret;
|
QDict *options = NULL;
|
||||||
|
QemuOpts *rbd_opts = NULL;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
secretid = qemu_opt_get(opts, "password-secret");
|
secretid = qemu_opt_get(opts, "password-secret");
|
||||||
|
|
||||||
if (qemu_rbd_parsename(filename, pool, sizeof(pool),
|
|
||||||
snap_buf, sizeof(snap_buf),
|
|
||||||
name, sizeof(name),
|
|
||||||
conf, sizeof(conf), &local_err) < 0) {
|
|
||||||
error_propagate(errp, local_err);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Read out options */
|
/* Read out options */
|
||||||
bytes = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
|
bytes = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
|
||||||
BDRV_SECTOR_SIZE);
|
BDRV_SECTOR_SIZE);
|
||||||
|
@ -440,35 +432,55 @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||||
if (objsize) {
|
if (objsize) {
|
||||||
if ((objsize - 1) & objsize) { /* not a power of 2? */
|
if ((objsize - 1) & objsize) { /* not a power of 2? */
|
||||||
error_setg(errp, "obj size needs to be power of 2");
|
error_setg(errp, "obj size needs to be power of 2");
|
||||||
return -EINVAL;
|
ret = -EINVAL;
|
||||||
|
goto exit;
|
||||||
}
|
}
|
||||||
if (objsize < 4096) {
|
if (objsize < 4096) {
|
||||||
error_setg(errp, "obj size too small");
|
error_setg(errp, "obj size too small");
|
||||||
return -EINVAL;
|
ret = -EINVAL;
|
||||||
|
goto exit;
|
||||||
}
|
}
|
||||||
obj_order = ctz32(objsize);
|
obj_order = ctz32(objsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
clientname = qemu_rbd_parse_clientname(conf, clientname_buf);
|
options = qdict_new();
|
||||||
|
qemu_rbd_parse_filename(filename, options, &local_err);
|
||||||
|
if (local_err) {
|
||||||
|
ret = -EINVAL;
|
||||||
|
error_propagate(errp, local_err);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
rbd_opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
|
||||||
|
qemu_opts_absorb_qdict(rbd_opts, options, &local_err);
|
||||||
|
if (local_err) {
|
||||||
|
error_propagate(errp, local_err);
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
pool = qemu_opt_get(rbd_opts, "pool");
|
||||||
|
conf = qemu_opt_get(rbd_opts, "conf");
|
||||||
|
clientname = qemu_opt_get(rbd_opts, "user");
|
||||||
|
name = qemu_opt_get(rbd_opts, "image");
|
||||||
|
keypairs = qemu_opt_get(rbd_opts, "keyvalue-pairs");
|
||||||
|
|
||||||
ret = rados_create(&cluster, clientname);
|
ret = rados_create(&cluster, clientname);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error_setg_errno(errp, -ret, "error initializing");
|
error_setg_errno(errp, -ret, "error initializing");
|
||||||
return ret;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strstr(conf, "conf=") == NULL) {
|
/* try default location when conf=NULL, but ignore failure */
|
||||||
/* try default location, but ignore failure */
|
ret = rados_conf_read_file(cluster, conf);
|
||||||
rados_conf_read_file(cluster, NULL);
|
if (conf && ret < 0) {
|
||||||
} else if (conf[0] != '\0' &&
|
error_setg_errno(errp, -ret, "error reading conf file %s", conf);
|
||||||
qemu_rbd_set_conf(cluster, conf, true, &local_err) < 0) {
|
|
||||||
error_propagate(errp, local_err);
|
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conf[0] != '\0' &&
|
ret = qemu_rbd_set_keypairs(cluster, keypairs, errp);
|
||||||
qemu_rbd_set_conf(cluster, conf, false, &local_err) < 0) {
|
if (ret < 0) {
|
||||||
error_propagate(errp, local_err);
|
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
@ -499,6 +511,10 @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||||
|
|
||||||
shutdown:
|
shutdown:
|
||||||
rados_shutdown(cluster);
|
rados_shutdown(cluster);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
QDECREF(options);
|
||||||
|
qemu_opts_del(rbd_opts);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,15 +569,10 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
BDRVRBDState *s = bs->opaque;
|
BDRVRBDState *s = bs->opaque;
|
||||||
char pool[RBD_MAX_POOL_NAME_SIZE];
|
const char *pool, *snap, *conf, *clientname, *name, *keypairs;
|
||||||
char snap_buf[RBD_MAX_SNAP_NAME_SIZE];
|
|
||||||
char conf[RBD_MAX_CONF_SIZE];
|
|
||||||
char clientname_buf[RBD_MAX_CONF_SIZE];
|
|
||||||
char *clientname;
|
|
||||||
const char *secretid;
|
const char *secretid;
|
||||||
QemuOpts *opts;
|
QemuOpts *opts;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
const char *filename;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
|
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
|
||||||
|
@ -572,44 +583,36 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
filename = qemu_opt_get(opts, "filename");
|
|
||||||
secretid = qemu_opt_get(opts, "password-secret");
|
secretid = qemu_opt_get(opts, "password-secret");
|
||||||
|
|
||||||
if (qemu_rbd_parsename(filename, pool, sizeof(pool),
|
pool = qemu_opt_get(opts, "pool");
|
||||||
snap_buf, sizeof(snap_buf),
|
conf = qemu_opt_get(opts, "conf");
|
||||||
s->name, sizeof(s->name),
|
snap = qemu_opt_get(opts, "snapshot");
|
||||||
conf, sizeof(conf), errp) < 0) {
|
clientname = qemu_opt_get(opts, "user");
|
||||||
r = -EINVAL;
|
name = qemu_opt_get(opts, "image");
|
||||||
goto failed_opts;
|
keypairs = qemu_opt_get(opts, "keyvalue-pairs");
|
||||||
}
|
|
||||||
|
|
||||||
clientname = qemu_rbd_parse_clientname(conf, clientname_buf);
|
|
||||||
r = rados_create(&s->cluster, clientname);
|
r = rados_create(&s->cluster, clientname);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
error_setg_errno(errp, -r, "error initializing");
|
error_setg_errno(errp, -r, "error initializing");
|
||||||
goto failed_opts;
|
goto failed_opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->snap = NULL;
|
s->snap = g_strdup(snap);
|
||||||
if (snap_buf[0] != '\0') {
|
if (name) {
|
||||||
s->snap = g_strdup(snap_buf);
|
pstrcpy(s->name, RBD_MAX_IMAGE_NAME_SIZE, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strstr(conf, "conf=") == NULL) {
|
/* try default location when conf=NULL, but ignore failure */
|
||||||
/* try default location, but ignore failure */
|
r = rados_conf_read_file(s->cluster, conf);
|
||||||
rados_conf_read_file(s->cluster, NULL);
|
if (conf && r < 0) {
|
||||||
} else if (conf[0] != '\0') {
|
error_setg_errno(errp, -r, "error reading conf file %s", conf);
|
||||||
r = qemu_rbd_set_conf(s->cluster, conf, true, errp);
|
goto failed_shutdown;
|
||||||
if (r < 0) {
|
|
||||||
goto failed_shutdown;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conf[0] != '\0') {
|
r = qemu_rbd_set_keypairs(s->cluster, keypairs, errp);
|
||||||
r = qemu_rbd_set_conf(s->cluster, conf, false, errp);
|
if (r < 0) {
|
||||||
if (r < 0) {
|
goto failed_shutdown;
|
||||||
goto failed_shutdown;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemu_rbd_set_auth(s->cluster, secretid, errp) < 0) {
|
if (qemu_rbd_set_auth(s->cluster, secretid, errp) < 0) {
|
||||||
|
@ -1063,18 +1066,18 @@ static QemuOptsList qemu_rbd_create_opts = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static BlockDriver bdrv_rbd = {
|
static BlockDriver bdrv_rbd = {
|
||||||
.format_name = "rbd",
|
.format_name = "rbd",
|
||||||
.instance_size = sizeof(BDRVRBDState),
|
.instance_size = sizeof(BDRVRBDState),
|
||||||
.bdrv_needs_filename = true,
|
.bdrv_parse_filename = qemu_rbd_parse_filename,
|
||||||
.bdrv_file_open = qemu_rbd_open,
|
.bdrv_file_open = qemu_rbd_open,
|
||||||
.bdrv_close = qemu_rbd_close,
|
.bdrv_close = qemu_rbd_close,
|
||||||
.bdrv_create = qemu_rbd_create,
|
.bdrv_create = qemu_rbd_create,
|
||||||
.bdrv_has_zero_init = bdrv_has_zero_init_1,
|
.bdrv_has_zero_init = bdrv_has_zero_init_1,
|
||||||
.bdrv_get_info = qemu_rbd_getinfo,
|
.bdrv_get_info = qemu_rbd_getinfo,
|
||||||
.create_opts = &qemu_rbd_create_opts,
|
.create_opts = &qemu_rbd_create_opts,
|
||||||
.bdrv_getlength = qemu_rbd_getlength,
|
.bdrv_getlength = qemu_rbd_getlength,
|
||||||
.bdrv_truncate = qemu_rbd_truncate,
|
.bdrv_truncate = qemu_rbd_truncate,
|
||||||
.protocol_name = "rbd",
|
.protocol_name = "rbd",
|
||||||
|
|
||||||
.bdrv_aio_readv = qemu_rbd_aio_readv,
|
.bdrv_aio_readv = qemu_rbd_aio_readv,
|
||||||
.bdrv_aio_writev = qemu_rbd_aio_writev,
|
.bdrv_aio_writev = qemu_rbd_aio_writev,
|
||||||
|
|
Loading…
Reference in a new issue