From patchwork Fri Apr 8 02:24:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 8779721 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 93AFF9F39A for ; Fri, 8 Apr 2016 02:26:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A851020263 for ; Fri, 8 Apr 2016 02:26:09 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ABC092025B for ; Fri, 8 Apr 2016 02:26:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoM5u-0005Ii-L4; Fri, 08 Apr 2016 02:24:22 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoM5t-0005IG-Sn for xen-devel@lists.xenproject.org; Fri, 08 Apr 2016 02:24:21 +0000 Received: from [193.109.254.147] by server-16.bemta-14.messagelabs.com id 5E/E1-02863-55617075; Fri, 08 Apr 2016 02:24:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrAIsWRWlGSWpSXmKPExsXiVRvkohsixh5 u8Gwbv8X3LZOZHBg9Dn+4whLAGMWamZeUX5HAmnHybVjBfvWKE98esjYwbpTuYuTiEBKYzijx 7tg2NhCHRWANq8TKX2tZQBwJgUusEt33bwI5nEBOjMSOGSvZIOxKiW/HOsFsIQEViZvbVzFBj FrMJPHt606wBmEBPYkjR3+wQ9ghErO6z4HZbAIGEm927GUFsUUElCTurZrMBGIzAw1d3/gXrI ZFQFXi4doZYDW8AnYSp149B4tzCthLXP97j7mLkQNomZ3E1QdyIGFRATmJlZdboMoFJU7OfMI CUsIsoCmxfpc+xHR5ie1v5zBPYBSZhaRqFkLVLCRVCxiZVzGqF6cWlaUW6ZrpJRVlpmeU5CZm 5ugaGpro5aYWFyemp+YkJhXrJefnbmIEhj4DEOxg/DvB+RCjJAeTkiivDx97uBBfUn5KZUZic UZ8UWlOavEhRhkODiUJ3lxRoJxgUWp6akVaZg4wCmHSEhw8SiK8/iBp3uKCxNzizHSI1ClGXY 4tU++tZRJiycvPS5US550GUiQAUpRRmgc3ApYQLjHKSgnzMgIdJcRTkFqUm1mCKv+KUZyDUUm YNw9kCk9mXgncpldARzABHXGBnw3kiJJEhJRUA+NW5ogzkYb/U/eoBKskfFtldfpeZIrAoqrL EwUnPjGqmpvbrCny8RFPzpX/caLGE536dPS0rlT5ql1sOd66blpN/RffUweOHnp661XG7tPPl CwPiB99wrWV82dh5raYyV+b7xVXzKpodPnw2Dx213Ih7q64yXmO0+23bSo/W71N+dOVQq95Hs FKLMUZiYZazEXFiQBU4iOwAwMAAA== X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-7.tower-27.messagelabs.com!1460082259!36313374!1 X-Originating-IP: [74.125.82.68] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64972 invoked from network); 8 Apr 2016 02:24:20 -0000 Received: from mail-wm0-f68.google.com (HELO mail-wm0-f68.google.com) (74.125.82.68) by server-7.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 8 Apr 2016 02:24:20 -0000 Received: by mail-wm0-f68.google.com with SMTP id y144so964121wmd.0 for ; Thu, 07 Apr 2016 19:24:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=1kgGS0EpookG9ydlwOhQPZmIjfqcc6EvHpfVYpMBTm4=; b=z3lm1Q/BcY0YzgrVjwqDmAUmktSzuxj7DNb4nb+r5DujXbPczJJ9kpQWmvoXiMAKhf gyabCyOOYEhc/cnHKV1Tb7Ze3zwk8mKDJY3LkvUtfpxo4quQCNgXiLyvB/yq4pCYk2Ar 7mpakvvGKooWtTnROsDCYxp3PTT+Mysr3komNn6lKG6aslzhmy0e9jRUPfODxbZgHNs2 hCDDC8KeNxvR1IUuMSr7us0fAEyw3hIVzmXoypzpIV1HSdZEU2Y/KxwiNpiEkaiBqWb6 IUWru9TxDzftreNCZvgzH4OLJiZ+ESpqQPx+Vbme4tFdZry7FvSpNrAGslYgsh279Gsc HGPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:from:to:cc:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=1kgGS0EpookG9ydlwOhQPZmIjfqcc6EvHpfVYpMBTm4=; b=f2tNufGCDRgoFuOlZJU8bDXTUU6QisKvUYjroJQxmqoxVY2KzKxmbdP8a46VYIt9Wc aFZdo9XdZwJD0H1/xiQIh31Bv6d6e+1f6NvKaMP+Usf9Y9paUY7n65CG2eDug0zYHaJa oNnzik2wtcPUVgGt39c7YrV0BPKXOF489M/zeWMYGr8jHzmT044dqxScldgTdavIjrWY f5XgxRr3WYzcRGy2wNPHZf5yJiD42zOcPnuehcSQQY+gsxcW87CxXarlHsxjw8UmA/jw AU/tlckfuDdBYUi2pvW5qFtQZkKx9Jhqbkl+MinlSC5ulbZSXNBH5X5us/3Ku1ZjrlFq bPSg== X-Gm-Message-State: AD7BkJI9MwJNtILYRIDGcQ+bsMC6R9FXwY5V+T+22R8C1Y3O7Rm5mu9sSxCCUQ93ZZVJSQ== X-Received: by 10.28.136.211 with SMTP id k202mr802933wmd.93.1460082259732; Thu, 07 Apr 2016 19:24:19 -0700 (PDT) Received: from Solace.fritz.box (net-37-116-155-252.cust.vodafonedsl.it. [37.116.155.252]) by smtp.gmail.com with ESMTPSA id c190sm725903wmd.10.2016.04.07.19.24.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Apr 2016 19:24:18 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Fri, 08 Apr 2016 04:24:17 +0200 Message-ID: <20160408022416.9058.81418.stgit@Solace.fritz.box> In-Reply-To: <20160408022241.9058.86808.stgit@Solace.fritz.box> References: <20160408022241.9058.86808.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: Wei Liu , Ian Jackson , Harmandeep Kaur Subject: [Xen-devel] [PATCH v3 6/6] xl: improve exit codes of domain creation related functions X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, 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 by making them more consistent with other examples in xl. Signed-off-by: Dario Faggioli Signed-off-by: Harmandeep Kaur --- Cc: Ian Jackson Cc: Wei Liu --- v3: In create_domain(), only deal with exit codes, internal returns need more work than what was being done in the original patch. Shorten changelog. v2: Add create_domain() Remove main_sharing() --- tools/libxl/xl_cmdimpl.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index d2ad8c8..31e2f30 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -2964,7 +2964,7 @@ static int create_domain(struct domain_create *dom_info) if (!json) { fprintf(stderr, "Failed to convert domain configuration to JSON\n"); - exit(1); + exit(EXIT_FAILURE); } fputs(json, cfg_print_fh); free(json); @@ -3212,7 +3212,7 @@ out: * already happened in the parent. */ if ( daemonize && !need_daemon ) - exit(ret); + exit(EXIT_SUCCESS); return ret; } @@ -5345,7 +5345,7 @@ static void string_realloc_append(char **accumulate, const char *more) size_t morelen = strlen(more) + 1/*nul*/; if (oldlen > SSIZE_MAX || morelen > SSIZE_MAX - oldlen) { fprintf(stderr,"Additional config data far too large\n"); - exit(-ERROR_FAIL); + exit(EXIT_FAILURE); } *accumulate = xrealloc(*accumulate, oldlen + morelen); @@ -5420,7 +5420,7 @@ int main_create(int argc, char **argv) } else { help("create"); free(dom_info.extra_config); - return 2; + return EXIT_FAILURE; } } @@ -5440,11 +5440,11 @@ int main_create(int argc, char **argv) rc = create_domain(&dom_info); if (rc < 0) { free(dom_info.extra_config); - return -rc; + return EXIT_FAILURE; } free(dom_info.extra_config); - return 0; + return EXIT_SUCCESS; } int main_config_update(int argc, char **argv) @@ -5465,7 +5465,7 @@ int main_config_update(int argc, char **argv) if (argc < 2) { fprintf(stderr, "xl config-update requires a domain argument\n"); help("config-update"); - exit(1); + exit(EXIT_FAILURE); } fprintf(stderr, "WARNING: xl now has better capability to manage domain configuration, " @@ -5497,7 +5497,7 @@ int main_config_update(int argc, char **argv) } else { help("create"); free(extra_config); - return 2; + return EXIT_FAILURE; } } if (filename) { @@ -5506,25 +5506,25 @@ int main_config_update(int argc, char **argv) &config_data, &config_len); if (rc) { fprintf(stderr, "Failed to read config file: %s: %s\n", filename, strerror(errno)); - free(extra_config); return ERROR_FAIL; } + free(extra_config); return EXIT_FAILURE; } if (extra_config && strlen(extra_config)) { if (config_len > INT_MAX - (strlen(extra_config) + 2 + 1)) { fprintf(stderr, "Failed to attach extra configuration\n"); - exit(1); + exit(EXIT_FAILURE); } /* allocate space for the extra config plus two EOLs plus \0 */ config_data = realloc(config_data, config_len + strlen(extra_config) + 2 + 1); if (!config_data) { fprintf(stderr, "Failed to realloc config_data\n"); - exit(1); + exit(EXIT_FAILURE); } config_len += sprintf(config_data + config_len, "\n%s\n", extra_config); } } else { fprintf(stderr, "Config file not specified\n"); - exit(1); + exit(EXIT_FAILURE); } libxl_domain_config_init(&d_config); @@ -5540,7 +5540,7 @@ int main_config_update(int argc, char **argv) config_data, config_len); if (rc) { fprintf(stderr, "failed to update configuration\n"); - exit(1); + exit(EXIT_FAILURE); } } @@ -5548,7 +5548,7 @@ int main_config_update(int argc, char **argv) free(config_data); free(extra_config); - return 0; + return EXIT_SUCCESS; } static void button_press(uint32_t domid, const char *b) @@ -7034,10 +7034,10 @@ int main_rename(int argc, char **argv) domid = find_domain(dom); if (libxl_domain_rename(ctx, domid, common_domname, new_name)) { fprintf(stderr, "Can't rename domain '%s'.\n", dom); - return 1; + return EXIT_FAILURE; } - return 0; + return EXIT_SUCCESS; } int main_trigger(int argc, char **argv)