From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:54194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCCMw-0007N2-2A for Qemu-devel@nongnu.org; Mon, 26 Mar 2012 12:02:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SCCMp-0007zw-QP for Qemu-devel@nongnu.org; Mon, 26 Mar 2012 12:02:05 -0400 Received: from mail-yx0-f173.google.com ([209.85.213.173]:49725) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCCMp-0007wk-Mw for Qemu-devel@nongnu.org; Mon, 26 Mar 2012 12:01:59 -0400 Received: by yenr5 with SMTP id r5so4848600yen.4 for ; Mon, 26 Mar 2012 09:01:58 -0700 (PDT) Message-ID: <4F7092F3.9030200@codemonkey.ws> Date: Mon, 26 Mar 2012 11:01:55 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <4F702B56.8030400@redhat.com> <4F707118.1070200@codemonkey.ws> <4F708673.1070503@redhat.com> <4F7087C9.6020205@codemonkey.ws> <4F708C85.5090606@redhat.com> <4F708D66.9010509@codemonkey.ws> <4F709246.6050709@redhat.com> In-Reply-To: <4F709246.6050709@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] Ignoring errno makes QMP errors suck List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: Qemu-devel@nongnu.org, Luiz Capitulino On 03/26/2012 10:59 AM, Kevin Wolf wrote: > Am 26.03.2012 17:38, schrieb Anthony Liguori: >> You can add parameters to Errors in a fully compatible fashion, so just add an >> filename parameter to PermissionDenied. Problem solved. > > So your error types will end up accumulating optional parameters for all > contexts in which they can occur? > > In the long run, PermissionDenied would have an optional file name (for > raw), optional host name, port, sheepdog volume ID (for sheepdog), > optional source and destination block devices (for blkmirror), remote > host and port, local address and port (for UDP chardevs)... I don't see the generalization. > > I could go on forever. Does this really make sense? What's the alternative proposal? If you just add errno to OPEN_FILE_FAILED, then you end up with errors for SHEEP_DOG_ATTACH_VOLUME_FAILED, NBD_CONNECT_FAILED, etc. The proper way to design an error is to make it a verb, and have parameters that correspond to the direct object and/or indirect object. The subject is implied by the command itself. So in the case of block_snapshot_sync, the failure is: The block_snapshot_sync command failed due to insufficient permission when creating foo.img. So the error is "PERMISSION_DENIED", with the data "filename=foo.img" In the case of NBD, the error would be: The block_snapshot_sync command failed because the host localhost:42 could not be contacted. The error is "CONNECTION_REFUSED", with the data "hostname=localhost,port=42". It the block layer returns both of these as EACCESS today, then this is a good argument to refactor the block layer to take an Error object instead of overloading the meaning of EACCESS. Regards, Anthony Liguori > > Kevin