From patchwork Wed Apr 20 08:04:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paulina Szubarczyk X-Patchwork-Id: 8886791 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 00556BF29F for ; Wed, 20 Apr 2016 08:07:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F3B7720268 for ; Wed, 20 Apr 2016 08:07:41 +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 E263C2024D for ; Wed, 20 Apr 2016 08:07:40 +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 1asn8d-0006Jp-OD; Wed, 20 Apr 2016 08:05:31 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1asn8c-0006Ij-5j for xen-devel@lists.xenproject.org; Wed, 20 Apr 2016 08:05:30 +0000 Received: from [193.109.254.147] by server-12.bemta-14.messagelabs.com id 6B/6F-13115-94837175; Wed, 20 Apr 2016 08:05:29 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrFIsWRWlGSWpSXmKPExsVyMfS6ga6HhXi 4QetPLYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNePHxvPsBT1qFdt2b2JuYDwn08XIxSEkMJNR 4sijU0wgDovALFaJbV/+sYI4EgLbWCV6Fx0DynACOTESr3/shrLLJK7+72cGsYUEtCQurVzBA jFqKpPE55P/GUESbAJmEjMn/2QBsUUEwiXe9u9gBiliFpjDKLH/3VW2LkYODmEBG4mNf9xBal gEVCVWfnrPCmLzCnhLHOpeygyxTE7i5LHJrCDlnAI+Et33g0FMIaCSyztyIaoFJU7OfMICEmY WUJdYP08IJMwsIC/RvHU28wRG4VlIqmYhVM1CUrWAkXkVo3pxalFZapGuuV5SUWZ6RkluYmaO rqGhiV5uanFxYnpqTmJSsV5yfu4mRmCIMwDBDsYvS5wPMUpyMCmJ8qoKiIcL8SXlp1RmJBZnx BeV5qQWH2KU4eBQkuDlNwfKCRalpqdWpGXmAKMNJi3BwaMkwssLkuYtLkjMLc5Mh0idYjTm2P L72lomjm1T761lEmLJy89LlRLnTQIpFQApzSjNgxsESwKXGGWlhHkZgU4T4ilILcrNLEGVf8U ozsGoJMyrBDKFJzOvBG7fK6BTmIBO4b8rCnJKSSJCSqqBkbk4fLlDzuU5VQ72sbrX3i38mnt3 N3fDrYbAjVN/pVjz58y0a2lSvNcnkSW/vCrk/+/MoCXPFAO2Pv4Yv277qjp9pbmrftxK8/AKW fjZYOmsewLZrxXN3x8R+PRwRZ9jjbzGXyfXv83eVfvarO4wvtvQtXrDP+d3PvG2GwO5d4V7XW qXPy9yRomlOCPRUIu5qDgRAAWAQ7P9AgAA X-Env-Sender: paulinaszubarczyk@gmail.com X-Msg-Ref: server-8.tower-27.messagelabs.com!1461139528!33030974!1 X-Originating-IP: [209.85.215.48] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 12494 invoked from network); 20 Apr 2016 08:05:28 -0000 Received: from mail-lf0-f48.google.com (HELO mail-lf0-f48.google.com) (209.85.215.48) by server-8.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 20 Apr 2016 08:05:28 -0000 Received: by mail-lf0-f48.google.com with SMTP id c126so35989613lfb.2 for ; Wed, 20 Apr 2016 01:05:28 -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 :mime-version:content-transfer-encoding; bh=iuhXSh5JX2jRoo/f7+46x/ehdCtakIQ+i0lyWpEWmD4=; b=AtaF3JaL4AybC2s9CUa01wBuAvC8UVVk4VnyrYO0QbMyWzfNMouTSt3jmW6PgiWxRj CuwWBKtBAK5F2rWjq+yJkxEF8Vjqio0Pi3JeO/Y2hJNhg1bxGlZ7fu3pyqv9O3BV2j/o KC9FfZfH8PcPW+8DQv1ShKHpTrTUhX/tpNKF/ZxhogxGlOr2Np5ODsZ13ktddz3kIsSU x36cJTF9eMOrKlGJ0T1UbFL8tSjJthlOjxxh0PVroixp61jpxspuHFTUpgpwPy/8F0WF XwDEc72G+xLcaIepGlC6eEUF9VwfIuWPUorfRLuqsNFr8GGFUXhVYhP+rGvMvFpVKKkt 9mNA== 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:mime-version:content-transfer-encoding; bh=iuhXSh5JX2jRoo/f7+46x/ehdCtakIQ+i0lyWpEWmD4=; b=AJYI93aoM47AQXr3KW0bkiNWzEL9eedeVVc+pqRb/kBRrDZxpicWv7YPUdnGH1ijV0 jHVSXCkc69EgK31VgFL9UmknutDqHf35vusPlb2RJXOjGLTzbfQEy+kscAxRkoltW+aN YO5geC4WNc05thAoo+DNkTUV5SgKEQsxRlvQ+HYZsBhHBjbEMYSYouBdpVPfv8obUArl zsYVw2R/pBTFhns6comQgZnSoI93fl6YRRx6mEvUeIItdNm22WU2gZpNO2QqGCxn8IgV 3LhPo4DuEtbZLE7yuf8KN4yQR8Zbcct7swLLEfn2jQ4TaeH6K/O318LI6tdGtZF/Jy7V RljA== X-Gm-Message-State: AOPr4FXPkq4iDqkrVyRZ6+F1RVP0qGYF6D4rQLKQ1avtQF4H84r+0boXAoHuC01ATHNIaA== X-Received: by 10.25.19.198 with SMTP id 67mr826169lft.58.1461139527927; Wed, 20 Apr 2016 01:05:27 -0700 (PDT) Received: from localhost.localdomain (84-10-74-207.static.chello.pl. [84.10.74.207]) by smtp.gmail.com with ESMTPSA id o10sm820613lbp.47.2016.04.20.01.05.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Apr 2016 01:05:27 -0700 (PDT) From: Paulina Szubarczyk To: xen-devel@lists.xenproject.org, roger.pau@citrix.com, George.Dunlap@eu.citrix.com Date: Wed, 20 Apr 2016 10:04:02 +0200 Message-Id: <1461139444-12342-6-git-send-email-paulinaszubarczyk@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461139444-12342-1-git-send-email-paulinaszubarczyk@gmail.com> References: <1461139444-12342-1-git-send-email-paulinaszubarczyk@gmail.com> MIME-Version: 1.0 Cc: ian.jackson@eu.citrix.com, dario.faggioli@citrix.com, wei.liu2@citrix.com, ian.campbell@citrix.com, Paulina Szubarczyk Subject: [Xen-devel] [PATCH v3 5/7] xl: 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: , 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 Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Dario Faggioli Acked-by: Roger Pau Monné Acked-by: Wei Liu --- tools/libxl/xl_cmdimpl.c | 51 ++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 6bef201..d646927 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -7817,11 +7817,11 @@ int main_tmem_list(int argc, char **argv) buf = libxl_tmem_list(ctx, domid, use_long); if (buf == NULL) - return -1; + return EXIT_FAILURE; printf("%s\n", buf); free(buf); - return 0; + return EXIT_SUCCESS; } int main_tmem_freeze(int argc, char **argv) @@ -7841,7 +7841,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) @@ -7849,8 +7849,10 @@ 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) @@ -7870,7 +7872,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) @@ -7878,8 +7880,10 @@ 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) @@ -7890,6 +7894,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 rc = 0; SWITCH_FOREACH_OPT(opt, "aw:c:p:", NULL, "tmem-set", 0) { case 'a': @@ -7913,7 +7918,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) @@ -7924,17 +7929,20 @@ 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); + rc = libxl_tmem_set(ctx, domid, "weight", weight); if (opt_c) - libxl_tmem_set(ctx, domid, "cap", cap); + rc = libxl_tmem_set(ctx, domid, "cap", cap); if (opt_p) - libxl_tmem_set(ctx, domid, "compress", compress); + rc = libxl_tmem_set(ctx, domid, "compress", compress); - return 0; + if (rc < 0) + return EXIT_FAILURE; + + return EXIT_SUCCESS; } int main_tmem_shared_auth(int argc, char **argv) @@ -7964,7 +7972,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) @@ -7975,18 +7983,19 @@ 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) @@ -8000,10 +8009,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)