Re: [Qemu-block] [PATCH] MAINTAINERS: update RBD block maintainer

2019-06-28 Thread Josh Durgin

On 6/28/19 6:55 AM, jdill...@redhat.com wrote:

From: Jason Dillaman 

Remove Josh as per his request since he is no longer the upstream RBD
tech lead. Add myself as the maintainer since I am the current RBD tech
lead.

Signed-off-by: Jason Dillaman 
---
  MAINTAINERS | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index cad58b9487..47694cd02f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2367,7 +2367,7 @@ S: Supported
  F: block/vmdk.c
  
  RBD

-M: Josh Durgin 
+M: Jason Dillaman 
  L: qemu-block@nongnu.org
  S: Supported
  F: block/rbd.c



Reviewed-by: Josh Durgin 



Re: [Qemu-block] [Qemu-devel] [PATCH v2] rbd:change error_setg() to error_setg_errno()

2016-05-17 Thread Josh Durgin

On 05/09/2016 12:51 AM, Vikhyat Umrao wrote:

Ceph RBD block driver does not use error_setg_errno() where
it is possible to use. This patch replaces error_setg()
from error_setg_errno().

Signed-off-by: Vikhyat Umrao 
---
  block/rbd.c | 38 +++---
  1 file changed, 23 insertions(+), 15 deletions(-)


Looks good, thanks!

Reviewed-by: Josh Durgin 


diff --git a/block/rbd.c b/block/rbd.c
index 5bc5b32..5226b6f 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -290,7 +290,8 @@ static int qemu_rbd_set_conf(rados_t cluster, const char 
*conf,
  if (only_read_conf_file) {
  ret = rados_conf_read_file(cluster, value);
  if (ret < 0) {
-error_setg(errp, "error reading conf file %s", value);
+error_setg_errno(errp, -ret, "error reading conf file %s",
+ value);
  break;
  }
  }
@@ -299,7 +300,7 @@ static int qemu_rbd_set_conf(rados_t cluster, const char 
*conf,
  } else if (!only_read_conf_file) {
  ret = rados_conf_set(cluster, name, value);
  if (ret < 0) {
-error_setg(errp, "invalid conf option %s", name);
+error_setg_errno(errp, -ret, "invalid conf option %s", name);
  ret = -EINVAL;
  break;
  }
@@ -354,9 +355,10 @@ static int qemu_rbd_create(const char *filename, QemuOpts 
*opts, Error **errp)
  }

  clientname = qemu_rbd_parse_clientname(conf, clientname_buf);
-if (rados_create(&cluster, clientname) < 0) {
-error_setg(errp, "error initializing");
-return -EIO;
+ret = rados_create(&cluster, clientname);
+if (ret < 0) {
+error_setg_errno(errp, -ret, "error initializing");
+return ret;
  }

  if (strstr(conf, "conf=") == NULL) {
@@ -381,21 +383,27 @@ static int qemu_rbd_create(const char *filename, QemuOpts 
*opts, Error **errp)
  return -EIO;
  }

-if (rados_connect(cluster) < 0) {
-error_setg(errp, "error connecting");
+ret = rados_connect(cluster);
+if (ret < 0) {
+error_setg_errno(errp, -ret, "error connecting");
  rados_shutdown(cluster);
-return -EIO;
+return ret;
  }

-if (rados_ioctx_create(cluster, pool, &io_ctx) < 0) {
-error_setg(errp, "error opening pool %s", pool);
+ret = rados_ioctx_create(cluster, pool, &io_ctx);
+if (ret < 0) {
+error_setg_errno(errp, -ret, "error opening pool %s", pool);
  rados_shutdown(cluster);
-return -EIO;
+return ret;
  }

  ret = rbd_create(io_ctx, name, bytes, &obj_order);
  rados_ioctx_destroy(io_ctx);
  rados_shutdown(cluster);
+if (ret < 0) {
+error_setg_errno(errp, -ret, "error rbd create");
+return ret;
+}

  return ret;
  }
@@ -500,7 +508,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict 
*options, int flags,
  clientname = qemu_rbd_parse_clientname(conf, clientname_buf);
  r = rados_create(&s->cluster, clientname);
  if (r < 0) {
-error_setg(errp, "error initializing");
+error_setg_errno(errp, -r, "error initializing");
  goto failed_opts;
  }

@@ -546,19 +554,19 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict 
*options, int flags,

  r = rados_connect(s->cluster);
  if (r < 0) {
-error_setg(errp, "error connecting");
+error_setg_errno(errp, -r, "error connecting");
  goto failed_shutdown;
  }

  r = rados_ioctx_create(s->cluster, pool, &s->io_ctx);
  if (r < 0) {
-error_setg(errp, "error opening pool %s", pool);
+error_setg_errno(errp, -r, "error opening pool %s", pool);
  goto failed_shutdown;
  }

  r = rbd_open(s->io_ctx, s->name, &s->image, s->snap);
  if (r < 0) {
-error_setg(errp, "error reading header from %s", s->name);
+error_setg_errno(errp, -r, "error reading header from %s", s->name);
  goto failed_open;
  }







Re: [Qemu-block] [PATCH] block/rbd: add .bdrv_reopen_prepare() stub

2016-05-17 Thread Josh Durgin

On 05/17/2016 03:03 AM, Sebastian Färber wrote:

Hi Kevin,


A correct reopen implementation must consider all options and flags that
.bdrv_open() looked at.

The options are okay, as both "filename" and "password-secret" aren't
things that we want to allow a reopen to change. However, in the flags
BDRV_O_NOCACHE makes a difference:

 if (flags & BDRV_O_NOCACHE) {
 rados_conf_set(s->cluster, "rbd_cache", "false");
 } else {
 rados_conf_set(s->cluster, "rbd_cache", "true");
 }

A reopen must either update the setting, or if it can't (e.g. because
librbd doesn't support it) any attempt to change the flag must fail.


Updating this setting on an open image won't do anything, but if you
rbd_close() and rbd_open() it again the setting will take effect.
rbd_close() will force a flush of any pending I/O in librbd and
free the memory for librbd's ImageCtx, which may or may not be desired
here.


Thanks for the feedback.
As far as i can tell it's not possible to update the cache settings
without reconnecting. I've added a check in the following patch.
Would be great if someone who knows the internals of ceph/rbd could
have a look as well.


There's no need to reset the librados state, so connections to the
cluster can stick around. I'm a bit unclear on the bdrv_reopen_*
functions though - what is their intended use and semantics?


Sebastian

-- >8 --
Subject: [PATCH] block/rbd: add .bdrv_reopen_prepare() stub

Add support for reopen() by adding the .bdrv_reopen_prepare() stub

Signed-off-by: Sebastian Färber 
---
  block/rbd.c | 14 ++
  1 file changed, 14 insertions(+)

diff --git a/block/rbd.c b/block/rbd.c
index 5bc5b32..8ecf096 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -577,6 +577,19 @@ failed_opts:
  return r;
  }

+/* Note that this will not re-establish a connection with the Ceph cluster
+   - it is effectively a NOP.  */
+static int qemu_rbd_reopen_prepare(BDRVReopenState *state,
+   BlockReopenQueue *queue, Error **errp)
+{
+if (state->flags & BDRV_O_NOCACHE &&
+((state->bs->open_flags & BDRV_O_NOCACHE) == 0)) {
+error_setg(errp, "Cannot turn off rbd_cache during reopen");
+return -EINVAL;
+}
+return 0;
+}
+
  static void qemu_rbd_close(BlockDriverState *bs)
  {
  BDRVRBDState *s = bs->opaque;
@@ -976,6 +989,7 @@ static BlockDriver bdrv_rbd = {
  .instance_size  = sizeof(BDRVRBDState),
  .bdrv_needs_filename = true,
  .bdrv_file_open = qemu_rbd_open,
+.bdrv_reopen_prepare = qemu_rbd_reopen_prepare,
  .bdrv_close = qemu_rbd_close,
  .bdrv_create= qemu_rbd_create,
  .bdrv_has_zero_init = bdrv_has_zero_init_1,
--
1.8.3.1






Re: [Qemu-block] [PATCH v2 1/3] rbd: add support for getting password from QCryptoSecret object

2015-12-21 Thread Josh Durgin

On 12/21/2015 06:59 AM, Daniel P. Berrange wrote:

Currently RBD passwords must be provided on the command line
via

   $QEMU -drive file=rbd:pool/image:id=myname:\
key=QVFDVm41aE82SHpGQWhBQXEwTkN2OGp0SmNJY0UrSE9CbE1RMUE=:\
auth_supported=cephx

This is insecure because the key is visible in the OS process
listing.

This adds support for an 'passwordid' parameter in the RBD
parameters that can be used with the QCryptoSecret object to
provide the password via a file:

   echo "QVFDVm41aE82SHpGQWhBQXEwTkN2OGp0SmNJY0UrSE9CbE1RMUE=" > poolkey.b64
   $QEMU -object secret,id=secret0,file=poolkey.b64,format=base64 \
 -drive driver=rbd,filename=rbd:pool/image:id=myname:\
auth_supported=cephx,passwordid=secret0

Signed-off-by: Daniel P. Berrange 


Looks good to me, thanks!

Reviewed-by: Josh Durgin 


---
  block/rbd.c | 47 +++
  1 file changed, 47 insertions(+)

diff --git a/block/rbd.c b/block/rbd.c
index a60a19d..dc4db0a 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -16,6 +16,7 @@
  #include "qemu-common.h"
  #include "qemu/error-report.h"
  #include "block/block_int.h"
+#include "crypto/secret.h"

  #include 

@@ -228,6 +229,27 @@ static char *qemu_rbd_parse_clientname(const char *conf, 
char *clientname)
  return NULL;
  }

+
+static int qemu_rbd_set_auth(rados_t cluster, const char *passwordid,
+ Error **errp)
+{
+if (passwordid == 0) {
+return 0;
+}
+
+gchar *secret = qcrypto_secret_lookup_as_base64(passwordid,
+errp);
+if (!secret) {
+return -1;
+}
+
+rados_conf_set(cluster, "key", secret);
+g_free(secret);
+
+return 0;
+}
+
+
  static int qemu_rbd_set_conf(rados_t cluster, const char *conf,
   bool only_read_conf_file,
   Error **errp)
@@ -299,10 +321,13 @@ static int qemu_rbd_create(const char *filename, QemuOpts 
*opts, Error **errp)
  char conf[RBD_MAX_CONF_SIZE];
  char clientname_buf[RBD_MAX_CONF_SIZE];
  char *clientname;
+const char *passwordid;
  rados_t cluster;
  rados_ioctx_t io_ctx;
  int ret;

+passwordid = qemu_opt_get(opts, "passwordid");
+
  if (qemu_rbd_parsename(filename, pool, sizeof(pool),
 snap_buf, sizeof(snap_buf),
 name, sizeof(name),
@@ -350,6 +375,11 @@ static int qemu_rbd_create(const char *filename, QemuOpts 
*opts, Error **errp)
  return -EIO;
  }

+if (qemu_rbd_set_auth(cluster, passwordid, errp) < 0) {
+rados_shutdown(cluster);
+return -EIO;
+}
+
  if (rados_connect(cluster) < 0) {
  error_setg(errp, "error connecting");
  rados_shutdown(cluster);
@@ -423,6 +453,11 @@ static QemuOptsList runtime_opts = {
  .type = QEMU_OPT_STRING,
  .help = "Specification of the rbd image",
  },
+{
+.name = "passwordid",
+.type = QEMU_OPT_STRING,
+.help = "ID of secret providing the password",
+},
  { /* end of list */ }
  },
  };
@@ -436,6 +471,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict 
*options, int flags,
  char conf[RBD_MAX_CONF_SIZE];
  char clientname_buf[RBD_MAX_CONF_SIZE];
  char *clientname;
+const char *passwordid;
  QemuOpts *opts;
  Error *local_err = NULL;
  const char *filename;
@@ -450,6 +486,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict 
*options, int flags,
  }

  filename = qemu_opt_get(opts, "filename");
+passwordid = qemu_opt_get(opts, "passwordid");

  if (qemu_rbd_parsename(filename, pool, sizeof(pool),
 snap_buf, sizeof(snap_buf),
@@ -488,6 +525,11 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict 
*options, int flags,
  }
  }

+if (qemu_rbd_set_auth(s->cluster, passwordid, errp) < 0) {
+r = -EIO;
+goto failed_shutdown;
+}
+
  /*
   * Fallback to more conservative semantics if setting cache
   * options fails. Ignore errors from setting rbd_cache because the
@@ -919,6 +961,11 @@ static QemuOptsList qemu_rbd_create_opts = {
  .type = QEMU_OPT_SIZE,
  .help = "RBD object size"
  },
+{
+.name = "passwordid",
+.type = QEMU_OPT_STRING,
+.help = "ID of secret providing the password",
+},
  { /* end of list */ }
  }
  };






Re: [Qemu-block] [Qemu-devel] [PATCH 03/17] rbd: add support for getting password from QCryptoSecret object

2015-10-19 Thread Josh Durgin

On 10/19/2015 08:09 AM, Daniel P. Berrange wrote:

Currently RBD passwords must be provided on the command line
via

   $QEMU -drive file=rbd:pool/image:id=myname:\
 key=QVFDVm41aE82SHpGQWhBQXEwTkN2OGp0SmNJY0UrSE9CbE1RMUE=:\
 auth_supported=cephx

This is insecure because the key is visible in the OS process
listing.

This adds support for an 'authsecret' parameter in the RBD
parameters that can be used with the QCryptoSecret object to
provide the password via a file:

   echo "QVFDVm41aE82SHpGQWhBQXEwTkN2OGp0SmNJY0UrSE9CbE1RMUE=" > poolkey.b64
   $QEMU -object secret,id=secret0,file=poolkey.b64,format=base64 \
   -drive file=rbd:pool/image:id=myname:\
   auth_supported=cephx,authsecret=secret0

Signed-off-by: Daniel P. Berrange 
---


Looks good in general, thanks for fixing this! Just one thing to fix
below.


  block/rbd.c | 42 ++
  1 file changed, 42 insertions(+)

diff --git a/block/rbd.c b/block/rbd.c
index a60a19d..0acf777 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -16,6 +16,7 @@
  #include "qemu-common.h"
  #include "qemu/error-report.h"
  #include "block/block_int.h"
+#include "crypto/secret.h"

  #include 

@@ -228,6 +229,23 @@ static char *qemu_rbd_parse_clientname(const char *conf, 
char *clientname)
  return NULL;
  }

+
+static int qemu_rbd_set_auth(rados_t cluster, const char *secretid,
+ Error **errp)
+{
+gchar *secret = qcrypto_secret_lookup_as_base64(secretid,
+errp);
+if (!secret) {
+return -1;
+}


It looks like this fails if no authsecret is provided. Ceph auth can be
disabled, so it seems like we should skip the qemu_rbd_set_auth() calls
in this case.


+
+rados_conf_set(cluster, "key", secret);
+g_free(secret);
+
+return 0;
+}
+
+
  static int qemu_rbd_set_conf(rados_t cluster, const char *conf,
   bool only_read_conf_file,
   Error **errp)
@@ -299,10 +317,13 @@ static int qemu_rbd_create(const char *filename, QemuOpts 
*opts, Error **errp)
  char conf[RBD_MAX_CONF_SIZE];
  char clientname_buf[RBD_MAX_CONF_SIZE];
  char *clientname;
+const char *secretid;
  rados_t cluster;
  rados_ioctx_t io_ctx;
  int ret;

+secretid = qemu_opt_get(opts, "authsecret");
+
  if (qemu_rbd_parsename(filename, pool, sizeof(pool),
 snap_buf, sizeof(snap_buf),
 name, sizeof(name),
@@ -350,6 +371,11 @@ static int qemu_rbd_create(const char *filename, QemuOpts 
*opts, Error **errp)
  return -EIO;
  }

+if (qemu_rbd_set_auth(cluster, secretid, errp) < 0) {
+rados_shutdown(cluster);
+return -EIO;
+}
+
  if (rados_connect(cluster) < 0) {
  error_setg(errp, "error connecting");
  rados_shutdown(cluster);
@@ -423,6 +449,11 @@ static QemuOptsList runtime_opts = {
  .type = QEMU_OPT_STRING,
  .help = "Specification of the rbd image",
  },
+{
+.name = "authsecret",
+.type = QEMU_OPT_STRING,
+.help = "ID of secret providing the password",
+},
  { /* end of list */ }
  },
  };
@@ -436,6 +467,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict 
*options, int flags,
  char conf[RBD_MAX_CONF_SIZE];
  char clientname_buf[RBD_MAX_CONF_SIZE];
  char *clientname;
+const char *secretid;
  QemuOpts *opts;
  Error *local_err = NULL;
  const char *filename;
@@ -450,6 +482,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict 
*options, int flags,
  }

  filename = qemu_opt_get(opts, "filename");
+secretid = qemu_opt_get(opts, "authsecret");

  if (qemu_rbd_parsename(filename, pool, sizeof(pool),
 snap_buf, sizeof(snap_buf),
@@ -488,6 +521,10 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict 
*options, int flags,
  }
  }

+if (qemu_rbd_set_auth(s->cluster, secretid, errp) < 0) {
+goto failed_shutdown;
+}
+
  /*
   * Fallback to more conservative semantics if setting cache
   * options fails. Ignore errors from setting rbd_cache because the
@@ -919,6 +956,11 @@ static QemuOptsList qemu_rbd_create_opts = {
  .type = QEMU_OPT_SIZE,
  .help = "RBD object size"
  },
+{
+.name = "authsecret",
+.type = QEMU_OPT_STRING,
+.help = "ID of secret providing the password",
+},
  { /* end of list */ }
  }
  };





Re: [Qemu-block] [Qemu-devel] [PATCH 0/4] rbd cleanup and settings precedence fixes

2015-07-14 Thread Josh Durgin

On 07/14/2015 07:20 AM, Kevin Wolf wrote:

Am 09.07.2015 um 11:59 hat Stefan Hajnoczi geschrieben:

On Tue, Jun 30, 2015 at 11:28:18AM -0700, Josh Durgin wrote:

Ping

On 06/10/2015 08:28 PM, Josh Durgin wrote:

Patches 1 and 2 are simple cleanups. 3 and 4 fix the precedence of
cache options and ceph settings. The cache option precedence in
particular is important due to the potential for misconfigurations
(ceph.conf setting rbd_cache=true, qemu setting cache=none) to
accidentally put data at risk.

Josh Durgin (4):
   rbd: remove unused constants and fields
   MAINTAINERS: update email address
   rbd: make qemu's cache setting override any ceph setting
   rbd: fix ceph settings precedence

  MAINTAINERS |  2 +-
  block/rbd.c | 64 +
  2 files changed, 36 insertions(+), 30 deletions(-)


This should go via Jeff:

   $ scripts/get_maintainer.pl -f block/rbd.c
   Josh Durgin  (supporter:RBD)
   Jeff Cody  (supporter:RBD)
   Kevin Wolf  (supporter:Block layer core)
   qemu-block@nongnu.org (open list:RBD)

Jeff is currently on vacation but will be back before the QEMU 2.4-rc1
tag is made.


Considering that Josh is the primary maintainer for rbd and Jeff is just
merging patches for him, and that Jeff has already given R-b for patches
1 to 3, and that Jeff doesn't seem to be back yet, and that the patches
look good to me, I'm taking this through my tree for -rc1.

(I guess this is my longest "thanks, applied" sentence so far...)


Thanks!
Josh




Re: [Qemu-block] [Qemu-devel] [PATCH 0/4] rbd cleanup and settings precedence fixes

2015-06-30 Thread Josh Durgin

Ping

On 06/10/2015 08:28 PM, Josh Durgin wrote:

Patches 1 and 2 are simple cleanups. 3 and 4 fix the precedence of
cache options and ceph settings. The cache option precedence in
particular is important due to the potential for misconfigurations
(ceph.conf setting rbd_cache=true, qemu setting cache=none) to
accidentally put data at risk.

Josh Durgin (4):
   rbd: remove unused constants and fields
   MAINTAINERS: update email address
   rbd: make qemu's cache setting override any ceph setting
   rbd: fix ceph settings precedence

  MAINTAINERS |  2 +-
  block/rbd.c | 64 +
  2 files changed, 36 insertions(+), 30 deletions(-)






[Qemu-block] [PATCH 0/4] rbd cleanup and settings precedence fixes

2015-06-10 Thread Josh Durgin
Patches 1 and 2 are simple cleanups. 3 and 4 fix the precedence of
cache options and ceph settings. The cache option precedence in
particular is important due to the potential for misconfigurations
(ceph.conf setting rbd_cache=true, qemu setting cache=none) to
accidentally put data at risk.

Josh Durgin (4):
  rbd: remove unused constants and fields
  MAINTAINERS: update email address
  rbd: make qemu's cache setting override any ceph setting
  rbd: fix ceph settings precedence

 MAINTAINERS |  2 +-
 block/rbd.c | 64 +
 2 files changed, 36 insertions(+), 30 deletions(-)

-- 
1.9.1




[Qemu-block] [PATCH 4/4] rbd: fix ceph settings precedence

2015-06-10 Thread Josh Durgin
Apply the ceph settings from a config file before any ceph settings
from the command line. Since the ceph config file location may be
specified on the command line, parse it once to read the config file,
and do a second pass to apply the rest of the command line ceph
options.

Signed-off-by: Josh Durgin 
---
 block/rbd.c | 32 
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/block/rbd.c b/block/rbd.c
index 00d027d..a60a19d 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -228,7 +228,9 @@ static char *qemu_rbd_parse_clientname(const char *conf, 
char *clientname)
 return NULL;
 }
 
-static int qemu_rbd_set_conf(rados_t cluster, const char *conf, Error **errp)
+static int qemu_rbd_set_conf(rados_t cluster, const char *conf,
+ bool only_read_conf_file,
+ Error **errp)
 {
 char *p, *buf;
 char name[RBD_MAX_CONF_NAME_SIZE];
@@ -260,14 +262,18 @@ static int qemu_rbd_set_conf(rados_t cluster, const char 
*conf, Error **errp)
 qemu_rbd_unescape(value);
 
 if (strcmp(name, "conf") == 0) {
-ret = rados_conf_read_file(cluster, value);
-if (ret < 0) {
-error_setg(errp, "error reading conf file %s", value);
-break;
+/* read the conf file alone, so it doesn't override more
+   specific settings for a particular device */
+if (only_read_conf_file) {
+ret = rados_conf_read_file(cluster, value);
+if (ret < 0) {
+error_setg(errp, "error reading conf file %s", value);
+break;
+}
 }
 } else if (strcmp(name, "id") == 0) {
 /* ignore, this is parsed by qemu_rbd_parse_clientname() */
-} else {
+} else if (!only_read_conf_file) {
 ret = rados_conf_set(cluster, name, value);
 if (ret < 0) {
 error_setg(errp, "invalid conf option %s", name);
@@ -330,10 +336,15 @@ static int qemu_rbd_create(const char *filename, QemuOpts 
*opts, Error **errp)
 if (strstr(conf, "conf=") == NULL) {
 /* try default location, but ignore failure */
 rados_conf_read_file(cluster, NULL);
+} else if (conf[0] != '\0' &&
+   qemu_rbd_set_conf(cluster, conf, true, &local_err) < 0) {
+rados_shutdown(cluster);
+error_propagate(errp, local_err);
+return -EIO;
 }
 
 if (conf[0] != '\0' &&
-qemu_rbd_set_conf(cluster, conf, &local_err) < 0) {
+qemu_rbd_set_conf(cluster, conf, false, &local_err) < 0) {
 rados_shutdown(cluster);
 error_propagate(errp, local_err);
 return -EIO;
@@ -463,10 +474,15 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict 
*options, int flags,
 if (strstr(conf, "conf=") == NULL) {
 /* try default location, but ignore failure */
 rados_conf_read_file(s->cluster, NULL);
+} else if (conf[0] != '\0') {
+r = qemu_rbd_set_conf(s->cluster, conf, true, errp);
+if (r < 0) {
+goto failed_shutdown;
+}
 }
 
 if (conf[0] != '\0') {
-r = qemu_rbd_set_conf(s->cluster, conf, errp);
+r = qemu_rbd_set_conf(s->cluster, conf, false, errp);
 if (r < 0) {
 goto failed_shutdown;
 }
-- 
1.9.1




[Qemu-block] [PATCH 2/4] MAINTAINERS: update email address

2015-06-10 Thread Josh Durgin
The old one still works for now, but will not work indefinitely.

Signed-off-by: Josh Durgin 
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 4ed8215..34eeb88 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1135,7 +1135,7 @@ S: Supported
 F: block/vmdk.c
 
 RBD
-M: Josh Durgin 
+M: Josh Durgin 
 M: Jeff Cody 
 L: qemu-block@nongnu.org
 S: Supported
-- 
1.9.1




[Qemu-block] [PATCH 3/4] rbd: make qemu's cache setting override any ceph setting

2015-06-10 Thread Josh Durgin
To be safe, when cache=none is used ceph settings should not be able
to override it to turn on caching. This was previously possible with
rbd_cache=true in the rbd device configuration or a ceph configuration
file. Similarly, rbd settings could have turned off caching when qemu
requested it, although this would just be a performance problem.

Fix this by changing rbd's cache setting to match qemu after all other
ceph settings have been applied.

Signed-off-by: Josh Durgin 
---
 block/rbd.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/block/rbd.c b/block/rbd.c
index 50b5f6b..00d027d 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -460,6 +460,18 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict 
*options, int flags,
 s->snap = g_strdup(snap_buf);
 }
 
+if (strstr(conf, "conf=") == NULL) {
+/* try default location, but ignore failure */
+rados_conf_read_file(s->cluster, NULL);
+}
+
+if (conf[0] != '\0') {
+r = qemu_rbd_set_conf(s->cluster, conf, errp);
+if (r < 0) {
+goto failed_shutdown;
+}
+}
+
 /*
  * Fallback to more conservative semantics if setting cache
  * options fails. Ignore errors from setting rbd_cache because the
@@ -473,18 +485,6 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict 
*options, int flags,
 rados_conf_set(s->cluster, "rbd_cache", "true");
 }
 
-if (strstr(conf, "conf=") == NULL) {
-/* try default location, but ignore failure */
-rados_conf_read_file(s->cluster, NULL);
-}
-
-if (conf[0] != '\0') {
-r = qemu_rbd_set_conf(s->cluster, conf, errp);
-if (r < 0) {
-goto failed_shutdown;
-}
-}
-
 r = rados_connect(s->cluster);
 if (r < 0) {
 error_setg(errp, "error connecting");
-- 
1.9.1




[Qemu-block] [PATCH 1/4] rbd: remove unused constants and fields

2015-06-10 Thread Josh Durgin
RBDAIOCB.status was only used for cancel, which was removed in
7691e24dbebb46658e89b3f950fda6ec78bbb823.

RBDAIOCB.sector_num was never used.

RADOSCB.done and rcbid were never used.

RBD_FD* are obsolete since the pipe was removed in
e04fb07fd1676e9facd7f3f878c1bbe03bccd26b.

Signed-off-by: Josh Durgin 
---
 block/rbd.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/block/rbd.c b/block/rbd.c
index fbe87e0..50b5f6b 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -74,25 +74,18 @@ typedef struct RBDAIOCB {
 QEMUIOVector *qiov;
 char *bounce;
 RBDAIOCmd cmd;
-int64_t sector_num;
 int error;
 struct BDRVRBDState *s;
-int status;
 } RBDAIOCB;
 
 typedef struct RADOSCB {
-int rcbid;
 RBDAIOCB *acb;
 struct BDRVRBDState *s;
-int done;
 int64_t size;
 char *buf;
 int64_t ret;
 } RADOSCB;
 
-#define RBD_FD_READ 0
-#define RBD_FD_WRITE 1
-
 typedef struct BDRVRBDState {
 rados_t cluster;
 rados_ioctx_t io_ctx;
@@ -405,7 +398,6 @@ static void qemu_rbd_complete_aio(RADOSCB *rcb)
 }
 qemu_vfree(acb->bounce);
 acb->common.cb(acb->common.opaque, (acb->ret > 0 ? 0 : acb->ret));
-acb->status = 0;
 
 qemu_aio_unref(acb);
 }
@@ -621,7 +613,6 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
 acb->error = 0;
 acb->s = s;
 acb->bh = NULL;
-acb->status = -EINPROGRESS;
 
 if (cmd == RBD_AIO_WRITE) {
 qemu_iovec_to_buf(acb->qiov, 0, acb->bounce, qiov->size);
@@ -633,7 +624,6 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
 size = nb_sectors * BDRV_SECTOR_SIZE;
 
 rcb = g_new(RADOSCB, 1);
-rcb->done = 0;
 rcb->acb = acb;
 rcb->buf = buf;
 rcb->s = acb->s;
-- 
1.9.1