Received: from [140.186.70.92] (port=52040 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OBX2o-0001IQ-3r for qemu-devel@nongnu.org; Mon, 10 May 2010 13:45:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OBX2i-0001pF-5Q for qemu-devel@nongnu.org; Mon, 10 May 2010 13:45:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29504) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OBX2h-0001p2-O6 for qemu-devel@nongnu.org; Mon, 10 May 2010 13:45:24 -0400 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH 1/2] qemu-error: Introduce get_errno_name() References: <1272486729-14771-1-git-send-email-lcapitulino@redhat.com> <1272486729-14771-2-git-send-email-lcapitulino@redhat.com> <4BDECCB3.9000601@codemonkey.ws> <20100504105645.12e34117@redhat.com> <4BE02943.2010304@codemonkey.ws> <20100504173014.30f71418@redhat.com> <4BE09803.5040703@codemonkey.ws> <20100505120023.2c2726a7@redhat.com> Date: Mon, 10 May 2010 19:45:19 +0200 In-Reply-To: <20100505120023.2c2726a7@redhat.com> (Luiz Capitulino's message of "Wed, 5 May 2010 12:00:23 -0300") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: qemu-devel@nongnu.org Luiz Capitulino writes: > On Tue, 04 May 2010 16:56:19 -0500 > Anthony Liguori wrote: > >> On 05/04/2010 03:30 PM, Luiz Capitulino wrote: >> > >> > StateVmSaveFailed is not like CommandFailed, there are five errors >> > in do_savevm() and StateVmSaveFailed happens to be one of them. >> > >> > But I understand what you mean and I have considered doing something >> > like it, one of the problems though is that I'm not sure 'source' is >> > enough to determine where the error has happened. >> > >> > Consider do_savevm() again. We have three 'operations' that might >> > fail: delete an existing snapshot, save the VM state and create the >> > snapshot. All those operations can return -EIO as an error. >> > >> >> Maybe those three operations should return distinct errnos? > > I don't think this is possible, as we would have to guarantee that no > function called by a handler return the same errno. > > Taking the block layer as an example. Most block drivers handlers check > if the driver really exist (-ENOMEDIUM) and if the driver supports the > operation being requested (-ENOTSUP). > > How can we have unique errnos in this case? > > Also remember that we're only talking about the surface. The call > chain is deep. We have almost a hundred handlers, they use functions > from almost all subsystems. > >> That way, we can make more useful QErrors. > > Perhaps, the question boils down to how QErrors should be done. > > Today, we're doing it like this, consider handler foo(), it does the following: > > 1. connect somewhere > 2. send some data > 3. close > > All operations performed can fail and we want to report that. Currently, > afaiu we're doing the following (Markus correct me if I'm wrong): > > 1. ConnectFailed > 2. SendFailed > 3. CloseFailed > > An obvious problem is that we don't say why it has failed. But this is > what errno is for and I thought we could use it someway. The advantage > of this approach is that, errors are high-level. It's easy to identify > what went wrong and we can have very good error messages for them. > > Now, if I got it right, you're suggesting we should do: > > 1. BadFileDescriptor, Interrupted, NoPermission ... > (or anything connect() may return) > 2. IOError ... > 3. IOError, BadFileDescriptor > > This makes sense, but if I'm a user (or a QMP client) I don't want this: > > (qemu) savevm foobar > Bad file descriptor > > I'd prefer this instead: > > (qemu) savevm foobar > Can't delete 'foobar': Bad file descriptor > > Or: > > (qemu) savevm foobar > Can't save VM state: I/O Error These are of the form "what failed: how it failed". Aside: not mentioned, because it's obvious for monitor commands: where it failed. error_report() adds that information, but only when it's not obvious, see error_print_loc(). We keep these parts separate because squashing them together into a single QError class multiplies the classes for no good reason, and makes it needlessly hard to group errors. E.g. sometimes we care only about "what failed". Then a squashed class is most unwelcome, because to recognize the "what failed" part you have to know all the squashed classes, hence all possible how-it-faileds, including the ones that will be invented after your program ships. [...]