From patchwork Fri Apr 1 12:40:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paulina Szubarczyk X-Patchwork-Id: 8723571 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 72D41C0555 for ; Fri, 1 Apr 2016 12:43:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8AA6020303 for ; Fri, 1 Apr 2016 12:43:48 +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 C85EC203B7 for ; Fri, 1 Apr 2016 12:43:46 +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 1alyOF-0001JJ-Gr; Fri, 01 Apr 2016 12:41:27 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1alyOE-0001I2-CL for xen-devel@lists.xenproject.org; Fri, 01 Apr 2016 12:41:26 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 25/4A-29237-57C6EF65; Fri, 01 Apr 2016 12:41:25 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsVyMfTmGt2SnH9 hBjf+mFp83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBnL1qcWHFaq+Pn9FUsD4wXJLkYuDiGBmYwS 0+8cYgZxWAReskhsWHaUHcSREOhnlXi9eQ5rFyMnkBMjMXHpCRYIu1Ji5/ZnjCC2kICWxKWVK 1ggRk1jkmj/tIoNJMEmYCYxc/JPsAYRgXCJt/07wFYwCzQwSvy7s5gJJCEsYCdx9ekpMJtFQF XizPfjYFN5Bbwl7q25ywaxTU7i5LHJYFdwCvhI/Nl0EWozUM3ZzWwTGAUWMDKsYlQvTi0qSy3 SNdZLKspMzyjJTczM0TU0MNPLTS0uTkxPzUlMKtZLzs/dxAgMLQYg2MHY8c/pEKMkB5OSKO8b u39hQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4C7OBcoJFqempFWmZOcAgh0lLcPAoifC6gqR5i wsSc4sz0yFSpxiNObb8vraWiWPb1HtrmYRY8vLzUqXEebtBSgVASjNK8+AGwaLvEqOslDAvI9 BpQjwFqUW5mSWo8q8YxTkYlYR5q0Gm8GTmlcDtewV0ChPQKR3SYKeUJCKkpBoYD2hoCsR2Vl/ 3SxeaxW4tVpKUlv1GcKn+lkPsiwuWnt7SVv7e1msSx8ybLz1m329ZeirtXlvCroSzFgfl561U 6649p3XbPagvlz/pxudNItfn8k9OCJvL1r29bqp2sdTGkEd7L0sEZ98/v/r/b07FtJl865/N0 j66NfmmyDdZNtXbF5cs77vFpcRSnJFoqMVcVJwIACvy4jq5AgAA X-Env-Sender: paulinaszubarczyk@gmail.com X-Msg-Ref: server-16.tower-21.messagelabs.com!1459514484!2635500!1 X-Originating-IP: [209.85.217.172] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43552 invoked from network); 1 Apr 2016 12:41:24 -0000 Received: from mail-lb0-f172.google.com (HELO mail-lb0-f172.google.com) (209.85.217.172) by server-16.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 1 Apr 2016 12:41:24 -0000 Received: by mail-lb0-f172.google.com with SMTP id vo2so71250171lbb.1 for ; Fri, 01 Apr 2016 05:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HH4iB02CXaQ1kFnvTE90sr0bT1b0KmU34aEGeVWsKJ0=; b=YmoqjDBqPY/FqaIE8rCLumQy5P5nXKYHuIX/7mWpiNBPfwIyZgH7Mo9No0TKrME4h5 mKYnuygQEJ49EWSe8ZVsw0lEEvwVYWo65cn/LXtvkGDXnCeDBm7AJnz8IaKUcgk6N3KT L+yBo1xEA5ugPkiYLQW3zpkhovgRWUzf0xoPHgoHZ8DxSV31dlT8wGD/ciYO6Af8nDd6 4MVQ6jWpqp3eDWfBbhlStJgRG0bSdASqxaRNDZ7fySfN+6c4BWE9L3BLehd8l1rcFU6A ZgP3ICoN2o58kfnk+cRzJfRVbtxD4OzKLCha39NLcVFDcGMhDx0ikvcG4hoG36ysgcnD 65fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HH4iB02CXaQ1kFnvTE90sr0bT1b0KmU34aEGeVWsKJ0=; b=cHJ/yb19KIvE8pMhCLMeYf58D3LPRxTWgxaoUXLgkzw3+gcTvOmwPCXHP3U6TBWMY4 4PIiBRRs79DEVozo+pXbx2sX0q4WTBRI8hzjxhGm06y9g9AS04+FgTZMG2VpfPu5NyK5 QPKlSKBTuinW34+UeD6OSXyRv9hwwDrC0KZMtHEEaZEtXgbS79kLMsPsiL49K8J5k6fh b00nBSM6fk6fw4ese0lIxo7dLgloYecHFzAF8jV6M6IexRZklB6pje3DQCkj8GuRho8p JeJ1Sajps9rlgKHZD+1jzblaruGrjcjfVSF4qXJDQ8BZfnea4pVEzRJAaxMzU12JjDur arrQ== X-Gm-Message-State: AD7BkJKHFMV9jfiN8nh3rbbwXpuDSA26ONv8u4adEdx2OdcAEsgibtA8qDhfWAHMXKSnVw== X-Received: by 10.112.170.68 with SMTP id ak4mr1842138lbc.94.1459514484263; Fri, 01 Apr 2016 05:41:24 -0700 (PDT) Received: from localhost.localdomain (84-10-74-207.static.chello.pl. [84.10.74.207]) by smtp.gmail.com with ESMTPSA id do4sm2134801lbc.35.2016.04.01.05.41.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Apr 2016 05:41:23 -0700 (PDT) From: Paulina Szubarczyk To: xen-devel@lists.xenproject.org, roger.pau@citrix.com, George.Dunlap@eu.citrix.com Date: Fri, 1 Apr 2016 14:40:11 +0200 Message-Id: <1459514413-18682-9-git-send-email-paulinaszubarczyk@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1459514413-18682-1-git-send-email-paulinaszubarczyk@gmail.com> References: <1459514413-18682-1-git-send-email-paulinaszubarczyk@gmail.com> Cc: Paulina Szubarczyk , dario.faggioli@citrix.com, wei.liu2@citrix.com, ian.campbell@citrix.com Subject: [Xen-devel] [PATCH 08/10] libxl: improve main_tmem_* return codes 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: , MIME-Version: 1.0 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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 Functions libxl_tmem_freeze(), libxl_tmem_thaw(), libxl_tmem_set() and libxl_tmem_shared_auth() located in libxl.c file return ERROR_FAIL/ERROR_INVAL or internal error codes from libxc library. Improve main_tmem_* return codes by returning EXIT_{SUCCESS/FAILURE} accordingly to return codes of those functions. Signed-off-by: Paulina Szubarczyk Acked-by: Roger Pau Monné Reviewed-by: Konrad Rzeszutek Wilk , albeit --- tools/libxl/xl_cmdimpl.c | 51 ++++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 38129f4..52c3b9b 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -7519,7 +7519,7 @@ int main_tmem_freeze(int argc, char **argv) if (!dom && all == 0) { fprintf(stderr, "You must specify -a or a domain id.\n\n"); help("tmem-freeze"); - return 1; + return EXIT_FAILURE; } if (all) @@ -7527,8 +7527,11 @@ int main_tmem_freeze(int argc, char **argv) else domid = find_domain(dom); - libxl_tmem_freeze(ctx, domid); - return 0; + if (libxl_tmem_freeze(ctx, domid) < 0) { + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; } int main_tmem_thaw(int argc, char **argv) @@ -7548,7 +7551,7 @@ int main_tmem_thaw(int argc, char **argv) if (!dom && all == 0) { fprintf(stderr, "You must specify -a or a domain id.\n\n"); help("tmem-thaw"); - return 1; + return EXIT_FAILURE; } if (all) @@ -7556,8 +7559,11 @@ int main_tmem_thaw(int argc, char **argv) else domid = find_domain(dom); - libxl_tmem_thaw(ctx, domid); - return 0; + if (libxl_tmem_thaw(ctx, domid) < 0) { + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; } int main_tmem_set(int argc, char **argv) @@ -7568,6 +7574,7 @@ int main_tmem_set(int argc, char **argv) int opt_w = 0, opt_c = 0, opt_p = 0; int all = 0; int opt; + int r = 0; SWITCH_FOREACH_OPT(opt, "aw:c:p:", NULL, "tmem-set", 0) { case 'a': @@ -7591,7 +7598,7 @@ int main_tmem_set(int argc, char **argv) if (!dom && all == 0) { fprintf(stderr, "You must specify -a or a domain id.\n\n"); help("tmem-set"); - return 1; + return EXIT_FAILURE; } if (all) @@ -7602,17 +7609,21 @@ int main_tmem_set(int argc, char **argv) if (!opt_w && !opt_c && !opt_p) { fprintf(stderr, "No set value specified.\n\n"); help("tmem-set"); - return 1; + return EXIT_FAILURE; } if (opt_w) - libxl_tmem_set(ctx, domid, "weight", weight); + r = libxl_tmem_set(ctx, domid, "weight", weight); if (opt_c) - libxl_tmem_set(ctx, domid, "cap", cap); + r = libxl_tmem_set(ctx, domid, "cap", cap); if (opt_p) - libxl_tmem_set(ctx, domid, "compress", compress); + r = libxl_tmem_set(ctx, domid, "compress", compress); - return 0; + if (r < 0) { + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; } int main_tmem_shared_auth(int argc, char **argv) @@ -7642,7 +7653,7 @@ int main_tmem_shared_auth(int argc, char **argv) if (!dom && all == 0) { fprintf(stderr, "You must specify -a or a domain id.\n\n"); help("tmem-shared-auth"); - return 1; + return EXIT_FAILURE; } if (all) @@ -7653,18 +7664,20 @@ int main_tmem_shared_auth(int argc, char **argv) if (uuid == NULL || autharg == NULL) { fprintf(stderr, "No uuid or auth specified.\n\n"); help("tmem-shared-auth"); - return 1; + return EXIT_FAILURE; } auth = strtol(autharg, &endptr, 10); if (*endptr != '\0') { fprintf(stderr, "Invalid auth, valid auth are <0|1>.\n\n"); - return 1; + return EXIT_FAILURE; } - libxl_tmem_shared_auth(ctx, domid, uuid, auth); + if (libxl_tmem_shared_auth(ctx, domid, uuid, auth) < 0) { + return EXIT_FAILURE; + } - return 0; + return EXIT_SUCCESS; } int main_tmem_freeable(int argc, char **argv) @@ -7678,10 +7691,10 @@ int main_tmem_freeable(int argc, char **argv) mb = libxl_tmem_freeable(ctx); if (mb == -1) - return -1; + return EXIT_FAILURE; printf("%d\n", mb); - return 0; + return EXIT_SUCCESS; } int main_cpupoolcreate(int argc, char **argv)