diff mbox

rbd:change error_setg() to error_setg_errno()

Message ID CACkKZgcZ8KJPuDf4bRUaa7b_EnM-ekxFX3Jr9E7mBvmj__KeyQ@mail.gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vikhyat Umrao May 2, 2016, 4:25 p.m. UTC
From 1c63c246f47a1a65d8740d7ce3725fe3820c0a37 Mon Sep 17 00:00:00 2001
From: Vikhyat Umrao <vumrao@redhat.com>
Date: Mon, 2 May 2016 21:47:31 +0530
Subject: [PATCH] rbd:change error_setg() to error_setg_errno()

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 <vumrao@redhat.com>
---
 block/rbd.c | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

                 }
             }
@@ -299,7 +299,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 +354,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 +382,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 +507,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 +553,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;
     }

Comments

Stefan Hajnoczi May 5, 2016, 5:45 p.m. UTC | #1
On Mon, May 02, 2016 at 09:55:17PM +0530, Vikhyat Umrao wrote:
> From 1c63c246f47a1a65d8740d7ce3725fe3820c0a37 Mon Sep 17 00:00:00 2001
> From: Vikhyat Umrao <vumrao@redhat.com>
> Date: Mon, 2 May 2016 21:47:31 +0530
> Subject: [PATCH] rbd:change error_setg() to error_setg_errno()
> 
> 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 <vumrao@redhat.com>
> ---
>  block/rbd.c | 37 ++++++++++++++++++++++---------------
>  1 file changed, 22 insertions(+), 15 deletions(-)
> 
> diff --git a/block/rbd.c b/block/rbd.c
> index 5bc5b32..c286b32 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c
> @@ -290,7 +290,7 @@ 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);

Please use scripts/checkpatch.pl to scan patches for coding style
violations.  This line exceeds the maximum line length.
Jeff Cody May 5, 2016, 7:06 p.m. UTC | #2
On Thu, May 05, 2016 at 06:45:15PM +0100, Stefan Hajnoczi wrote:
> On Mon, May 02, 2016 at 09:55:17PM +0530, Vikhyat Umrao wrote:
> > From 1c63c246f47a1a65d8740d7ce3725fe3820c0a37 Mon Sep 17 00:00:00 2001
> > From: Vikhyat Umrao <vumrao@redhat.com>
> > Date: Mon, 2 May 2016 21:47:31 +0530
> > Subject: [PATCH] rbd:change error_setg() to error_setg_errno()
> > 
> > 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 <vumrao@redhat.com>
> > ---
> >  block/rbd.c | 37 ++++++++++++++++++++++---------------
> >  1 file changed, 22 insertions(+), 15 deletions(-)
> > 
> > diff --git a/block/rbd.c b/block/rbd.c
> > index 5bc5b32..c286b32 100644
> > --- a/block/rbd.c
> > +++ b/block/rbd.c
> > @@ -290,7 +290,7 @@ 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);
> 
> Please use scripts/checkpatch.pl to scan patches for coding style
> violations.  This line exceeds the maximum line length.


Also, if you can use something like git send-email, it formats the patch
emails much nicer -- which makes it easier to review & apply.

Thanks,
Jeff
Fam Zheng May 6, 2016, 12:44 a.m. UTC | #3
On Thu, 05/05 15:06, Jeff Cody wrote:
> On Thu, May 05, 2016 at 06:45:15PM +0100, Stefan Hajnoczi wrote:
> > On Mon, May 02, 2016 at 09:55:17PM +0530, Vikhyat Umrao wrote:
> > > From 1c63c246f47a1a65d8740d7ce3725fe3820c0a37 Mon Sep 17 00:00:00 2001
> > > From: Vikhyat Umrao <vumrao@redhat.com>
> > > Date: Mon, 2 May 2016 21:47:31 +0530
> > > Subject: [PATCH] rbd:change error_setg() to error_setg_errno()
> > > 
> > > 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 <vumrao@redhat.com>
> > > ---
> > >  block/rbd.c | 37 ++++++++++++++++++++++---------------
> > >  1 file changed, 22 insertions(+), 15 deletions(-)
> > > 
> > > diff --git a/block/rbd.c b/block/rbd.c
> > > index 5bc5b32..c286b32 100644
> > > --- a/block/rbd.c
> > > +++ b/block/rbd.c
> > > @@ -290,7 +290,7 @@ 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);
> > 
> > Please use scripts/checkpatch.pl to scan patches for coding style
> > violations.  This line exceeds the maximum line length.
> 
> 
> Also, if you can use something like git send-email, it formats the patch
> emails much nicer -- which makes it easier to review & apply.

Also please use ./scripts/get_maintainer.pl to get a more complete recipient
list (for example it will report qemu-block@nongnu.org and other block
layer maintainers).

Fam
Vikhyat Umrao May 6, 2016, 5:14 a.m. UTC | #4
On Fri, May 6, 2016 at 6:14 AM, Fam Zheng <famz@redhat.com> wrote:

> On Thu, 05/05 15:06, Jeff Cody wrote:
> > On Thu, May 05, 2016 at 06:45:15PM +0100, Stefan Hajnoczi wrote:
> > > On Mon, May 02, 2016 at 09:55:17PM +0530, Vikhyat Umrao wrote:
> > > > From 1c63c246f47a1a65d8740d7ce3725fe3820c0a37 Mon Sep 17 00:00:00
> 2001
> > > > From: Vikhyat Umrao <vumrao@redhat.com>
> > > > Date: Mon, 2 May 2016 21:47:31 +0530
> > > > Subject: [PATCH] rbd:change error_setg() to error_setg_errno()
> > > >
> > > > 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 <vumrao@redhat.com>
> > > > ---
> > > >  block/rbd.c | 37 ++++++++++++++++++++++---------------
> > > >  1 file changed, 22 insertions(+), 15 deletions(-)
> > > >
> > > > diff --git a/block/rbd.c b/block/rbd.c
> > > > index 5bc5b32..c286b32 100644
> > > > --- a/block/rbd.c
> > > > +++ b/block/rbd.c
> > > > @@ -290,7 +290,7 @@ 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);
> > >
> > > Please use scripts/checkpatch.pl to scan patches for coding style
> > > violations.  This line exceeds the maximum line length.
> >
> >
> > Also, if you can use something like git send-email, it formats the patch
> > emails much nicer -- which makes it easier to review & apply.
>
> Also please use ./scripts/get_maintainer.pl to get a more complete
> recipient
> list (for example it will report qemu-block@nongnu.org and other block
> layer maintainers).
>
> Fam
>

Thank you everyone for your inputs. Sure I will fix the current patch and
will check it with given scripts and then will send patch v2.
Stefan Hajnoczi May 6, 2016, 4:29 p.m. UTC | #5
On Fri, May 06, 2016 at 10:44:41AM +0530, Vikhyat Umrao wrote:
> On Fri, May 6, 2016 at 6:14 AM, Fam Zheng <famz@redhat.com> wrote:
> 
> > On Thu, 05/05 15:06, Jeff Cody wrote:
> > > On Thu, May 05, 2016 at 06:45:15PM +0100, Stefan Hajnoczi wrote:
> > > > On Mon, May 02, 2016 at 09:55:17PM +0530, Vikhyat Umrao wrote:
> > > > > From 1c63c246f47a1a65d8740d7ce3725fe3820c0a37 Mon Sep 17 00:00:00
> > 2001
> > > > > From: Vikhyat Umrao <vumrao@redhat.com>
> > > > > Date: Mon, 2 May 2016 21:47:31 +0530
> > > > > Subject: [PATCH] rbd:change error_setg() to error_setg_errno()
> > > > >
> > > > > 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 <vumrao@redhat.com>
> > > > > ---
> > > > >  block/rbd.c | 37 ++++++++++++++++++++++---------------
> > > > >  1 file changed, 22 insertions(+), 15 deletions(-)
> > > > >
> > > > > diff --git a/block/rbd.c b/block/rbd.c
> > > > > index 5bc5b32..c286b32 100644
> > > > > --- a/block/rbd.c
> > > > > +++ b/block/rbd.c
> > > > > @@ -290,7 +290,7 @@ 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);
> > > >
> > > > Please use scripts/checkpatch.pl to scan patches for coding style
> > > > violations.  This line exceeds the maximum line length.
> > >
> > >
> > > Also, if you can use something like git send-email, it formats the patch
> > > emails much nicer -- which makes it easier to review & apply.
> >
> > Also please use ./scripts/get_maintainer.pl to get a more complete
> > recipient
> > list (for example it will report qemu-block@nongnu.org and other block
> > layer maintainers).
> >
> > Fam
> >
> 
> Thank you everyone for your inputs. Sure I will fix the current patch and
> will check it with given scripts and then will send patch v2.

This page has the guidelines for submitting patches:
http://qemu-project.org/Contribute/SubmitAPatch

Stefan
Vikhyat Umrao May 9, 2016, 7:56 a.m. UTC | #6
Thank you Stefan. I have sent v2 of my patch following all earlier
suggestions and link shared by you.

On Fri, May 6, 2016 at 9:59 PM, Stefan Hajnoczi <stefanha@gmail.com> wrote:

> On Fri, May 06, 2016 at 10:44:41AM +0530, Vikhyat Umrao wrote:
> > On Fri, May 6, 2016 at 6:14 AM, Fam Zheng <famz@redhat.com> wrote:
> >
> > > On Thu, 05/05 15:06, Jeff Cody wrote:
> > > > On Thu, May 05, 2016 at 06:45:15PM +0100, Stefan Hajnoczi wrote:
> > > > > On Mon, May 02, 2016 at 09:55:17PM +0530, Vikhyat Umrao wrote:
> > > > > > From 1c63c246f47a1a65d8740d7ce3725fe3820c0a37 Mon Sep 17 00:00:00
> > > 2001
> > > > > > From: Vikhyat Umrao <vumrao@redhat.com>
> > > > > > Date: Mon, 2 May 2016 21:47:31 +0530
> > > > > > Subject: [PATCH] rbd:change error_setg() to error_setg_errno()
> > > > > >
> > > > > > 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 <vumrao@redhat.com>
> > > > > > ---
> > > > > >  block/rbd.c | 37 ++++++++++++++++++++++---------------
> > > > > >  1 file changed, 22 insertions(+), 15 deletions(-)
> > > > > >
> > > > > > diff --git a/block/rbd.c b/block/rbd.c
> > > > > > index 5bc5b32..c286b32 100644
> > > > > > --- a/block/rbd.c
> > > > > > +++ b/block/rbd.c
> > > > > > @@ -290,7 +290,7 @@ 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);
> > > > >
> > > > > Please use scripts/checkpatch.pl to scan patches for coding style
> > > > > violations.  This line exceeds the maximum line length.
> > > >
> > > >
> > > > Also, if you can use something like git send-email, it formats the
> patch
> > > > emails much nicer -- which makes it easier to review & apply.
> > >
> > > Also please use ./scripts/get_maintainer.pl to get a more complete
> > > recipient
> > > list (for example it will report qemu-block@nongnu.org and other block
> > > layer maintainers).
> > >
> > > Fam
> > >
> >
> > Thank you everyone for your inputs. Sure I will fix the current patch and
> > will check it with given scripts and then will send patch v2.
>
> This page has the guidelines for submitting patches:
> http://qemu-project.org/Contribute/SubmitAPatch
>
> Stefan
>
diff mbox

Patch

diff --git a/block/rbd.c b/block/rbd.c
index 5bc5b32..c286b32 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -290,7 +290,7 @@  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;