From patchwork Mon May 2 16:25:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vikhyat Umrao X-Patchwork-Id: 8994181 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5FBA5BF29F for ; Mon, 2 May 2016 18:02:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4233C20222 for ; Mon, 2 May 2016 18:02:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 29BCA20221 for ; Mon, 2 May 2016 18:02:43 +0000 (UTC) Received: from localhost ([::1]:37924 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axIB5-0007gU-1M for patchwork-qemu-devel@patchwork.kernel.org; Mon, 02 May 2016 14:02:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axGfF-0003Ts-83 for qemu-devel@nongnu.org; Mon, 02 May 2016 12:25:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axGf3-0006FF-19 for qemu-devel@nongnu.org; Mon, 02 May 2016 12:25:35 -0400 Received: from mail-oi0-f43.google.com ([209.85.218.43]:34942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axGf2-0006Av-R9 for qemu-devel@nongnu.org; Mon, 02 May 2016 12:25:28 -0400 Received: by mail-oi0-f43.google.com with SMTP id x19so196196891oix.2 for ; Mon, 02 May 2016 09:25:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc; bh=+sYRsW9DdNtWw01Qo+/8p7Wj/erZwpmAmrb4o9p+c1I=; b=ghgoT1zIJzY/a93+v0/9NIfcE1PGJy7QHx+5j/fgenm8lCdzDawqpzB9/DPVOghxIX JZssmxqwmUHga0oyYi1idU0RUL1dJ74Cje45zOm65vqJGXdTQBrqynhdl13EPYJZmIDc /re7m8CupcfwD6bnMX/e7FwhNIMxaI5DltNrrS+n7v5gEs8OLyjUcgUHgckgIf4ZUFiV 6IX91HQmOXEW6/y7z3Oz4H4Ax9kHB4sBBWtEosARW748x3qct+OIN9AYO6CbSUA2Lm7t +TnshqYektQeIEs0nX6CfSgVFbHq4XLtOdMupezt0WUIT6fXdMFUXryMzNCTTyaFMxgN MHEA== X-Gm-Message-State: AOPr4FXdP4LtMLS2xLr/HZisiEG15KTEMxcGKgoIgiRf2Eg7iocqb5dwGORryJQAKFSL9Koro07LxASg/BJFLMXE MIME-Version: 1.0 X-Received: by 10.157.5.184 with SMTP id 53mr16592229otd.60.1462206317223; Mon, 02 May 2016 09:25:17 -0700 (PDT) Received: by 10.202.192.133 with HTTP; Mon, 2 May 2016 09:25:17 -0700 (PDT) Date: Mon, 2 May 2016 21:55:17 +0530 Message-ID: From: Vikhyat Umrao To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.218.43 X-Mailman-Approved-At: Mon, 02 May 2016 14:02:28 -0400 Subject: [Qemu-devel] [PATCH] rbd:change error_setg() to error_setg_errno() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jcody@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From 1c63c246f47a1a65d8740d7ce3725fe3820c0a37 Mon Sep 17 00:00:00 2001 From: Vikhyat Umrao 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 --- 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; } 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;