rbd.c (af91062ee1408f7f5bb58389d355d29a5040c648) rbd.c (a3699de4dde82bc76b33a83798a9da82c2336cce)
1/*
2 * QEMU Block driver for RADOS (Ceph)
3 *
4 * Copyright (C) 2010-2011 Christian Brunner <chb@muc.de>,
5 * Josh Durgin <josh.durgin@dreamhost.com>
6 *
7 * This work is licensed under the terms of the GNU GPL, version 2. See
8 * the COPYING file in the top-level directory.

--- 226 unchanged lines hidden (view full) ---

235static void qemu_rbd_refresh_limits(BlockDriverState *bs, Error **errp)
236{
237 /* XXX Does RBD support AIO on less than 512-byte alignment? */
238 bs->bl.request_alignment = 512;
239}
240
241
242static int qemu_rbd_set_auth(rados_t cluster, const char *secretid,
1/*
2 * QEMU Block driver for RADOS (Ceph)
3 *
4 * Copyright (C) 2010-2011 Christian Brunner <chb@muc.de>,
5 * Josh Durgin <josh.durgin@dreamhost.com>
6 *
7 * This work is licensed under the terms of the GNU GPL, version 2. See
8 * the COPYING file in the top-level directory.

--- 226 unchanged lines hidden (view full) ---

235static void qemu_rbd_refresh_limits(BlockDriverState *bs, Error **errp)
236{
237 /* XXX Does RBD support AIO on less than 512-byte alignment? */
238 bs->bl.request_alignment = 512;
239}
240
241
242static int qemu_rbd_set_auth(rados_t cluster, const char *secretid,
243 BlockdevOptionsRbd *opts,
243 Error **errp)
244{
244 Error **errp)
245{
245 if (secretid == 0) {
246 return 0;
246 char *acr;
247 int r;
248 GString *accu;
249 RbdAuthModeList *auth;
250
251 if (secretid) {
252 gchar *secret = qcrypto_secret_lookup_as_base64(secretid,
253 errp);
254 if (!secret) {
255 return -1;
256 }
257
258 rados_conf_set(cluster, "key", secret);
259 g_free(secret);
247 }
248
260 }
261
249 gchar *secret = qcrypto_secret_lookup_as_base64(secretid,
250 errp);
251 if (!secret) {
252 return -1;
262 if (opts->has_auth_client_required) {
263 accu = g_string_new("");
264 for (auth = opts->auth_client_required; auth; auth = auth->next) {
265 if (accu->str[0]) {
266 g_string_append_c(accu, ';');
267 }
268 g_string_append(accu, RbdAuthMode_str(auth->value));
269 }
270 acr = g_string_free(accu, FALSE);
271 r = rados_conf_set(cluster, "auth_client_required", acr);
272 g_free(acr);
273 if (r < 0) {
274 error_setg_errno(errp, -r,
275 "Could not set 'auth_client_required'");
276 return r;
277 }
253 }
254
278 }
279
255 rados_conf_set(cluster, "key", secret);
256 g_free(secret);
257
258 return 0;
259}
260
261static int qemu_rbd_set_keypairs(rados_t cluster, const char *keypairs_json,
262 Error **errp)
263{
264 QList *keypairs;
265 QString *name;

--- 314 unchanged lines hidden (view full) ---

580
581 if (mon_host) {
582 r = rados_conf_set(*cluster, "mon_host", mon_host);
583 if (r < 0) {
584 goto failed_shutdown;
585 }
586 }
587
280 return 0;
281}
282
283static int qemu_rbd_set_keypairs(rados_t cluster, const char *keypairs_json,
284 Error **errp)
285{
286 QList *keypairs;
287 QString *name;

--- 314 unchanged lines hidden (view full) ---

602
603 if (mon_host) {
604 r = rados_conf_set(*cluster, "mon_host", mon_host);
605 if (r < 0) {
606 goto failed_shutdown;
607 }
608 }
609
588 if (qemu_rbd_set_auth(*cluster, secretid, errp) < 0) {
610 if (qemu_rbd_set_auth(*cluster, secretid, opts, errp) < 0) {
589 r = -EIO;
590 goto failed_shutdown;
591 }
592
593 /*
594 * Fallback to more conservative semantics if setting cache
595 * options fails. Ignore errors from setting rbd_cache because the
596 * only possible error is that the option does not exist, and

--- 590 unchanged lines hidden ---
611 r = -EIO;
612 goto failed_shutdown;
613 }
614
615 /*
616 * Fallback to more conservative semantics if setting cache
617 * options fails. Ignore errors from setting rbd_cache because the
618 * only possible error is that the option does not exist, and

--- 590 unchanged lines hidden ---