From patchwork Fri Apr 8 02:23:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 8779711 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 B3E7AC0553 for ; Fri, 8 Apr 2016 02:25:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8583B20263 for ; Fri, 8 Apr 2016 02:25:57 +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 558522025B for ; Fri, 8 Apr 2016 02:25:56 +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-00058c-TX; Fri, 08 Apr 2016 02:23:56 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoM5T-000581-Gd for xen-devel@lists.xenproject.org; Fri, 08 Apr 2016 02:23:55 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id B9/A8-09532-A3617075; Fri, 08 Apr 2016 02:23:54 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHIsWRWlGSWpSXmKPExsXiVRvkomslxh5 uMP08m8X3LZOZHBg9Dn+4whLAGMWamZeUX5HAmvFw5VPmgmafio136hsYb5h3MXJxCAlMZZQ4 uGMbSxcjJweLwBpWiTMXqkASEgKXWCUaJu1mAklICMRI7G5azwZhl0nMWD0ZzBYSUJG4uX0VE 4S9mElixRkeEFtYQE/iyNEf7BB2hMStu3OYQWw2AQOJNzv2soLYIgJKEvdWTQbrZRaolFjf+J cd4ghViZt7roPN5xWwk1h/4zTYcZwC9hLX/94DmsMBtMtO4uoDOZCwqICcxMrLLawQ5YISJ2c +YQEpYRbQlFi/Sx9iurzE9rdzmCcwisxCUjULoWoWkqoFjMyrGNWLU4vKUot0jfWSijLTM0py EzNzdA0NzPRyU4uLE9NTcxKTivWS83M3MQLDngEIdjB2/HM6xCjJwaQkyuvDxx4uxJeUn1KZk VicEV9UmpNafIhRhoNDSYL3lwhQTrAoNT21Ii0zBxiBMGkJDh4lEV5BUaA0b3FBYm5xZjpE6h SjLseWqffWMgmx5OXnpUqJ84qDFAmAFGWU5sGNgCWDS4yyUsK8jEBHCfEUpBblZpagyr9iFOd gVBLmNQWZwpOZVwK36RXQEUxAR1zgZwM5oiQRISXVwBjJ/S/+28qW5fffFk2f+cR23fd9E7PV JmRtm7Wqdsfm+xWz7ukoWjTcW5HtfjzeMFDiw4yT9oZqTN7TP07k0HVSSPrvaiq3bEugvzvLf eHjzydlyr8wuLqidMpVe+ZlUsZeFTpaLBKT08oTVDPWWp2xrTgUcOqw0JnvISppt69vYLiY/D TgRa8SS3FGoqEWc1FxIgB45uPaAQMAAA== X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1460082233!8258500!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 54541 invoked from network); 8 Apr 2016 02:23:54 -0000 Received: from mail-wm0-f68.google.com (HELO mail-wm0-f68.google.com) (74.125.82.68) by server-13.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 8 Apr 2016 02:23:54 -0000 Received: by mail-wm0-f68.google.com with SMTP id n3so957409wmn.1 for ; Thu, 07 Apr 2016 19:23:54 -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=9gCcq5SurEcjWeHSFYJ1M7SAOszROhGVSkUV42yYyE4=; b=UaR1NHQiT4NSZR0XTz1pkLc/DztrfaI3jih6/pN/6jYmCeeq+IJFuBfNzzJls8O3rK pkX+I4qaOLq6HLrDbmyN2etBzVfRMJaThKP9mczFEakr64S/8/rhBd4YoRP3kPGvhKGO wuNhm99ZHhlsqAa73LZXy+gu54injAGX+piWoPsTwXx7XBccX3Xf9V/AEIDZ4w0Rq7QB 1BiqPckR89FHGVLxm537Q7SNwTeZizjbmu5bRL5qBx2rRt8SOiEgyyE5wtswgHIrqvU6 w6sTQLURCiKDM4x++wZRELrEldJRPmilk08bFRK3WJZiE37rIg8uy8c+BG87gtXNTl7F hJIg== 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=9gCcq5SurEcjWeHSFYJ1M7SAOszROhGVSkUV42yYyE4=; b=J52H9LkyE9zDWVdHGZTgarZE/KPvJ9goKvQoJpPuaKryF75VdNHhGRjuAob8Z2bwIC Pu/uBRi6iP56CftWhDvw8Dy56VxzLSgdfN3IA8L8ZiuqkW9gSds0fGPNS559QlTrA/J8 LWA/n1E+nMOcPVeW1ZrX/CytWs1A9pX9PyrN/oW0dHFNmsOff0RN59VUfOjeKjzGJpLZ OT9gNPm/IRj2W/3WqNVueOs+Qf3xsTyxFwlG8uHi1TJlDend5rgswbimYlFyKM1YXNRK mQHcFIc9tUraRXDjiA0FWJMhP6h4nIyVr0iLeZaE/rOQDBVAtwm+uzBia8OokSJgeqV2 XMmQ== X-Gm-Message-State: AD7BkJLVHv/nDbIgSKL/4RdpYSNnkaL6RVDdYriMeBDAwOKmFnMhx+txiynnoqsSjvXwug== X-Received: by 10.194.71.70 with SMTP id s6mr6517862wju.1.1460082233805; Thu, 07 Apr 2016 19:23:53 -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 lz5sm11138430wjb.5.2016.04.07.19.23.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Apr 2016 19:23:53 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Fri, 08 Apr 2016 04:23:50 +0200 Message-ID: <20160408022350.9058.31805.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 3/6] xl: improve exit codes of some of the domain handling 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 From: Harmandeep Kaur by making them more consistent with other examples in xl. Affected functions are the ones related to console, vnc, dump, destroy, shutdown, list, domid and domname. Signed-off-by: Harmandeep Kaur Signed-off-by: Dario Fagggioli Acked-by: Wei Liu --- Cc: Ian Jackson Cc: Wei Liu --- V3: This is patches 4, 5, 6 and 9 squashed into one. Shorten changelog. V2: Add autoconnect_vncviewer(). --- tools/libxl/xl_cmdimpl.c | 72 +++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 9cd3144..4a560d7 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -174,7 +174,7 @@ static uint32_t find_domain(const char *p) rc = libxl_domain_qualifier_to_domid(ctx, p, &domid); if (rc) { fprintf(stderr, "%s is an invalid domain identifier (rc=%d)\n", p, rc); - exit(2); + exit(EXIT_FAILURE); } common_domname = libxl_domid_to_name(ctx, domid); return domid; @@ -221,7 +221,7 @@ static void autoconnect_vncviewer(uint32_t domid, int autopass) sleep(1); vncviewer(domid, autopass); - _exit(1); + _exit(EXIT_FAILURE); } static int acquire_lock(void) @@ -435,7 +435,7 @@ static void flush_stream(FILE *fh) if (ferror(fh) || fflush(fh)) { perror(fh_name); - exit(-1); + exit(EXIT_FAILURE); } } @@ -3735,7 +3735,7 @@ int main_console(int argc, char **argv) type = LIBXL_CONSOLE_TYPE_SERIAL; else { fprintf(stderr, "console type supported are: pv, serial\n"); - return 2; + return EXIT_FAILURE; } break; case 'n': @@ -3749,7 +3749,7 @@ int main_console(int argc, char **argv) else libxl_console_exec(ctx, domid, num, type); fprintf(stderr, "Unable to attach console\n"); - return 1; + return EXIT_FAILURE; } int main_vncviewer(int argc, char **argv) @@ -3771,8 +3771,8 @@ int main_vncviewer(int argc, char **argv) domid = find_domain(argv[optind]); if (vncviewer(domid, autopass)) - return 1; - return 0; + return EXIT_FAILURE; + return EXIT_SUCCESS; } static void pcilist(uint32_t domid) @@ -4010,10 +4010,10 @@ static void destroy_domain(uint32_t domid, int force) fprintf(stderr, "Not destroying domain 0; use -f to force.\n" "This can only be done when using a disaggregated " "hardware domain and toolstack.\n\n"); - exit(-1); + exit(EXIT_FAILURE); } rc = libxl_domain_destroy(ctx, domid, 0); - if (rc) { fprintf(stderr,"destroy failed (rc=%d)\n",rc); exit(-1); } + if (rc) { fprintf(stderr,"destroy failed (rc=%d)\n",rc); exit(EXIT_FAILURE); } } static void wait_for_domain_deaths(libxl_evgen_domain_death **deathws, int nr) @@ -4025,7 +4025,7 @@ static void wait_for_domain_deaths(libxl_evgen_domain_death **deathws, int nr) rc = libxl_event_wait(ctx, &event, LIBXL_EVENTMASK_ALL, 0,0); if (rc) { LOG("Failed to get event, quitting (rc=%d)", rc); - exit(-1); + exit(EXIT_FAILURE); } switch (event->type) { @@ -4070,14 +4070,14 @@ static void shutdown_domain(uint32_t domid, } if (rc) { - fprintf(stderr,"shutdown failed (rc=%d)\n",rc);exit(-1); + fprintf(stderr,"shutdown failed (rc=%d)\n",rc);exit(EXIT_FAILURE); } if (deathw) { rc = libxl_evenable_domain_death(ctx, domid, for_user, deathw); if (rc) { fprintf(stderr,"wait for death failed (evgen, rc=%d)\n",rc); - exit(-1); + exit(EXIT_FAILURE); } } } @@ -4101,14 +4101,14 @@ static void reboot_domain(uint32_t domid, libxl_evgen_domain_death **deathw, } } if (rc) { - fprintf(stderr,"reboot failed (rc=%d)\n",rc);exit(-1); + fprintf(stderr,"reboot failed (rc=%d)\n",rc);exit(EXIT_FAILURE); } if (deathw) { rc = libxl_evenable_domain_death(ctx, domid, for_user, deathw); if (rc) { fprintf(stderr,"wait for death failed (evgen, rc=%d)\n",rc); - exit(-1); + exit(EXIT_FAILURE); } } } @@ -4241,12 +4241,12 @@ static void list_domains(bool verbose, bool context, bool claim, bool numa, if (numa) { if (libxl_node_bitmap_alloc(ctx, &nodemap, 0)) { fprintf(stderr, "libxl_node_bitmap_alloc_failed.\n"); - exit(1); + exit(EXIT_FAILURE); } if (libxl_get_physinfo(ctx, &physinfo) != 0) { fprintf(stderr, "libxl_physinfo failed.\n"); libxl_bitmap_dispose(&nodemap); - exit(1); + exit(EXIT_FAILURE); } printf(" NODE Affinity"); @@ -4310,7 +4310,7 @@ static void list_vm(void) if (!info) { fprintf(stderr, "libxl_list_vm failed.\n"); - exit(1); + exit(EXIT_FAILURE); } printf("UUID ID name\n"); for (i = 0; i < nb_vm; i++) { @@ -4327,7 +4327,7 @@ static void core_dump_domain(uint32_t domid, const char *filename) int rc; rc=libxl_domain_core_dump(ctx, domid, filename, NULL); - if (rc) { fprintf(stderr,"core dump failed (rc=%d)\n",rc);exit(-1); } + if (rc) { fprintf(stderr,"core dump failed (rc=%d)\n",rc);exit(EXIT_FAILURE); } } #ifndef LIBXL_HAVE_NO_SUSPEND_RESUME @@ -5118,7 +5118,7 @@ int main_dump_core(int argc, char **argv) } core_dump_domain(find_domain(argv[optind]), argv[optind + 1]); - return 0; + return EXIT_SUCCESS; } int main_pause(int argc, char **argv) @@ -5131,7 +5131,7 @@ int main_pause(int argc, char **argv) pause_domain(find_domain(argv[optind])); - return 0; + return EXIT_SUCCESS; } int main_unpause(int argc, char **argv) @@ -5144,7 +5144,7 @@ int main_unpause(int argc, char **argv) unpause_domain(find_domain(argv[optind])); - return 0; + return EXIT_SUCCESS; } int main_destroy(int argc, char **argv) @@ -5159,7 +5159,7 @@ int main_destroy(int argc, char **argv) } destroy_domain(find_domain(argv[optind]), force); - return 0; + return EXIT_SUCCESS; } static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv) @@ -5191,7 +5191,7 @@ static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv) if (!argv[optind] && !all) { fprintf(stderr, "You must specify -a or a domain id.\n\n"); - return opt; + return EXIT_FAILURE; } if (all) { @@ -5199,7 +5199,7 @@ static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv) libxl_evgen_domain_death **deathws = NULL; if (!(dominfo = libxl_list_domain(ctx, &nb_domain))) { fprintf(stderr, "libxl_list_domain failed.\n"); - return -1; + return EXIT_FAILURE; } if (wait_for_it) @@ -5230,7 +5230,7 @@ static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv) } - return 0; + return EXIT_SUCCESS; } int main_shutdown(int argc, char **argv) @@ -5288,7 +5288,7 @@ int main_list(int argc, char **argv) info = libxl_list_domain(ctx, &nb_domain); if (!info) { fprintf(stderr, "libxl_list_domain failed.\n"); - return 1; + return EXIT_FAILURE; } info_free = info; } else if (optind == argc-1) { @@ -5297,17 +5297,17 @@ int main_list(int argc, char **argv) if (rc == ERROR_DOMAIN_NOTFOUND) { fprintf(stderr, "Error: Domain \'%s\' does not exist.\n", argv[optind]); - return -rc; + return EXIT_FAILURE; } if (rc) { fprintf(stderr, "libxl_domain_info failed (code %d).\n", rc); - return -rc; + return EXIT_FAILURE; } info = &info_buf; nb_domain = 1; } else { help("list"); - return 2; + return EXIT_FAILURE; } if (details) @@ -5321,7 +5321,7 @@ int main_list(int argc, char **argv) libxl_dominfo_dispose(&info_buf); - return 0; + return EXIT_SUCCESS; } int main_vm_list(int argc, char **argv) @@ -5333,7 +5333,7 @@ int main_vm_list(int argc, char **argv) } list_vm(); - return 0; + return EXIT_SUCCESS; } static void string_realloc_append(char **accumulate, const char *more) @@ -6980,12 +6980,12 @@ int main_domid(int argc, char **argv) if (libxl_name_to_domid(ctx, domname, &domid)) { fprintf(stderr, "Can't get domid of domain name '%s', maybe this domain does not exist.\n", domname); - return 1; + return EXIT_FAILURE; } printf("%d\n", domid); - return 0; + return EXIT_SUCCESS; } int main_domname(int argc, char **argv) @@ -7003,19 +7003,19 @@ int main_domname(int argc, char **argv) if (domid == 0 && !strcmp(endptr, argv[optind])) { /*no digits at all*/ fprintf(stderr, "Invalid domain id.\n\n"); - return 1; + return EXIT_FAILURE; } domname = libxl_domid_to_name(ctx, domid); if (!domname) { fprintf(stderr, "Can't get domain name of domain id '%d', maybe this domain does not exist.\n", domid); - return 1; + return EXIT_FAILURE; } printf("%s\n", domname); free(domname); - return 0; + return EXIT_SUCCESS; } int main_rename(int argc, char **argv)