From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tvo62-00084Y-Nd for qemu-devel@nongnu.org; Thu, 17 Jan 2013 06:57:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tvo5y-0002fG-2d for qemu-devel@nongnu.org; Thu, 17 Jan 2013 06:57:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:63534) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tvo5x-0002f7-Q3 for qemu-devel@nongnu.org; Thu, 17 Jan 2013 06:57:22 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0HBvKZg010660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 17 Jan 2013 06:57:21 -0500 Date: Thu, 17 Jan 2013 09:57:28 -0200 From: Luiz Capitulino Message-ID: <20130117095728.60bf72b8@doriath.home> In-Reply-To: <87mww81c6l.fsf@blackfin.pond.sub.org> References: <9a76a255b7b5e09131dbd8d7503d07b489d7f8d0.1358373940.git.jcody@redhat.com> <87mww81c6l.fsf@blackfin.pond.sub.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] block: do_commit() does not pass along error messages for all errors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: kwolf@redhat.com, Jeff Cody , qemu-devel@nongnu.org, stefanha@redhat.com On Thu, 17 Jan 2013 08:49:38 +0100 Markus Armbruster wrote: > [Cc: Luiz for error stuff] > > Jeff Cody writes: > > > The non-live bdrv_commit() function may return one of the following > > errors: -ENOTSUP, -EBUSY, -EACCES, -EIO. The only error that is > > checked in the HMP handler is -EBUSY, so the monitor command 'commit' > > silently fails for all error cases other than 'Device is in use'. > > > > This patch adds the appropriate error messages for the errors > > explicitely returned by bdrv_commit(). > > > > Signed-off-by: Jeff Cody > > --- > > blockdev.c | 14 ++++++++++++++ > > 1 file changed, 14 insertions(+) > > > > diff --git a/blockdev.c b/blockdev.c > > index d724e2d..7db7d8e 100644 > > --- a/blockdev.c > > +++ b/blockdev.c > > @@ -657,6 +657,20 @@ void do_commit(Monitor *mon, const QDict *qdict) > > qerror_report(QERR_DEVICE_IN_USE, device); > > return; > > } > > + if (ret == -EACCES) { > > + qerror_report(QERR_DEVICE_IS_READ_ONLY, device); > > + return; > > + } > > + if (ret == -EIO) { > > + qerror_report(QERR_IO_ERROR); > > + return; > > + } > > + if (ret == -ENOTSUP) { > > + const char *format = bdrv_get_format_name(bs); > > + qerror_report(QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED, > > + format ? format : "NULL", device, "commit"); > > + > > + } > > } > > } > > A switch could be more obvious than the if cascade. Matter of taste. > > We're trying to avoid QERR_ in new code. This case isn't bad, because > it doesn't add new QERR_ defines. Should we convert the function to > error_setg() instead? Perhaps a few cases could be collapsed into a > single error_setg_errno() then. I'd suggest to convert do_commit() to the qapi. However, we already have block-commit in QMP. So I'm not sure this is a good idea. If it isn't, then maybe we could drop all qerro_report() calls and use monitor_printf() instead (building the error message with strerror()), as do_commit() seems to be used only from HMP.