From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: Re: [PATCH] kvm tool: rewrite kvm__init Date: Thu, 09 Feb 2012 23:17:17 -0500 Message-ID: <1328847437.7150.1.camel@lappy> References: <1328766016-2644-1-git-send-email-hamo.by@gmail.com> <20120209130741.GG5709@moon> <1328849588.3876.1.camel@lappy> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Cyrill Gorcunov , Pekka Enberg , kvm@vger.kernel.org, Asias He , Ingo Molnar To: Yang Bai Return-path: Received: from mail-iy0-f174.google.com ([209.85.210.174]:39410 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758282Ab2BJERU (ORCPT ); Thu, 9 Feb 2012 23:17:20 -0500 Received: by iacb35 with SMTP id b35so3486469iac.19 for ; Thu, 09 Feb 2012 20:17:20 -0800 (PST) In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On Fri, 2012-02-10 at 11:03 +0800, Yang Bai wrote: > On Fri, Feb 10, 2012 at 12:53 PM, Sasha Levin wrote: > > On Fri, 2012-02-10 at 10:34 +0800, Yang Bai wrote: > >> On Thu, Feb 9, 2012 at 9:07 PM, Cyrill Gorcunov wrote: > >> > On Thu, Feb 09, 2012 at 03:01:26PM +0200, Pekka Enberg wrote: > >> >> On Thu, Feb 9, 2012 at 7:40 AM, Yang Bai wrote: > >> >> > Since the different issues have been handled in the > >> >> > internal of kvm__init, it can only return NULL if error > >> >> > happened. > >> >> > > >> >> > Signed-off-by: Yang Bai > >> >> > >> >> Sorry, I don't understand what this patch is attempting to fix? Why do > >> >> you think it's better to drop the explicit error codes and always > >> >> return NULL upon error? > >> >> > >> > >> Ok. Since the different issues have been handled in the internal of > >> this function and the caller does not care about the real error > >> reasons. So just return NULL if error will simplify the error handle > >> of the caller. > > > > Um... why doesn't the caller care about the real error? It's whats being > > sent back to userspace and can help the caller determine whats going on. > > > Reading the source code, I found that the caller handle it as following: > > static int kvm_cmd_run_init(int argc, const char **argv) > { > [snip] > kvm = kvm__init(dev, hugetlbfs_path, ram_size, guest_name); > if (IS_ERR(kvm)) { > r = PTR_ERR(kvm); > goto fail; > } > [snip] > fail: > return r; > } > > int kvm_cmd_run(int argc, const char **argv, const char *prefix) > { > [snip] > r = kvm_cmd_run_init(argc, argv); > if (r < 0) > return r; > [snip] > } >>From what I gather from the code snippet you pasted is that we return the error to the user, which can help him determine whats going on... -- Sasha.