From patchwork Tue Mar 8 19:02:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harmandeep Kaur X-Patchwork-Id: 8536771 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 9F964C0553 for ; Tue, 8 Mar 2016 19:05:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AE60420204 for ; Tue, 8 Mar 2016 19:05:26 +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 C6BC42015E for ; Tue, 8 Mar 2016 19:05:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1adMu3-0000o6-9V; Tue, 08 Mar 2016 19:02:43 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1adMu1-0000mS-Fx for xen-devel@lists.xenproject.org; Tue, 08 Mar 2016 19:02:41 +0000 Received: from [85.158.137.68] by server-17.bemta-3.messagelabs.com id 48/30-03109-1D12FD65; Tue, 08 Mar 2016 19:02:41 +0000 X-Env-Sender: write.harmandeep@gmail.com X-Msg-Ref: server-9.tower-31.messagelabs.com!1457463760!5479525!1 X-Originating-IP: [74.125.82.66] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 2302 invoked from network); 8 Mar 2016 19:02:40 -0000 Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by server-9.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 8 Mar 2016 19:02:40 -0000 Received: by mail-wm0-f66.google.com with SMTP id p65so5915506wmp.1 for ; Tue, 08 Mar 2016 11:02:40 -0800 (PST) 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=rvlRTBizXomCEHiSZij+dMIIz9gX1j/25IQYxQKlNfY=; b=y4QC9B5KMB0Rfnmab8TG+K0fFU4fXOZFM2gV4AGxsXaCb5PCrm3iZ90zQPy6paPYSz w/jRScoPlgJrKO3lawAFuFhd93aIDaJReLCl17BPM7ymb7Zca4p0uwC/DgPMTBjoi/Oy 2F+91skpue7TcxjR178oD367/citqQBf0X07Pq9X8+e7Xqil+zdUB0p3Da9pTFo3Ch7c nsW9MwhYlncNyc2TOyaQ5v8QoOq+9ZIDSG/Zbbrmqzk3SJlE4+uTAoUu6LwLD2RfD8L2 AlI2l3xQpXSzWPfp2vqM54Yd+35yMDDgmK59mWG1j35CcSit3yUK6cA9RQyF7Z4vPfTy zwNA== 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=rvlRTBizXomCEHiSZij+dMIIz9gX1j/25IQYxQKlNfY=; b=ANWJwDCYyQehWa2zhizawCrIo2M6DDfu6cPcjG/KuimcDMsZENEcnruXq/HIYZ1Hgm 2LE4jk8i25W2EjMzIP/1slKdWa+0hzkbUcx3ZmlpW6RO90xH7lDZrIjM81S3QuXWPTvl isPGaq/Lcye0QOnP7PajPkb7hvQtIzu5CO3WO9VmU8/HyZ3AW4EEqdZgU8/0t9r7MPJs PQoBdJ7zUgsVlHkHcwWE0V35FC4WK28OffUliJdkKs0vjNeGT+eoEuJhAk2FboKnUljl x3qeHLkB5PSNGA5zd8B5NwBdVIePTlG7Jb8OYBQ3RfnajywaLCukB1/ICdmDb7xr8iIu VIKw== X-Gm-Message-State: AD7BkJI7sWEV85Fyy1GbOyLzbKsr1moBdAWn96kq8JwhDQRiIGmZgMF2j6cBPR+vl9YNcQ== X-Received: by 10.28.126.4 with SMTP id z4mr15858207wmc.29.1457463760413; Tue, 08 Mar 2016 11:02:40 -0800 (PST) Received: from localhost.localdomain ([124.253.57.150]) by smtp.googlemail.com with ESMTPSA id hu1sm4310795wjb.36.2016.03.08.11.02.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Mar 2016 11:02:39 -0800 (PST) From: Harmandeep Kaur To: xen-devel@lists.xenproject.org Date: Wed, 9 Mar 2016 00:32:03 +0530 Message-Id: <1457463730-4712-3-git-send-email-write.harmandeep@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1457463730-4712-1-git-send-email-write.harmandeep@gmail.com> References: <1457463730-4712-1-git-send-email-write.harmandeep@gmail.com> Cc: wei.liu2@citrix.com, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, dario.faggioli@citrix.com, ian.jackson@eu.citrix.com, Harmandeep Kaur Subject: [Xen-devel] [PATCH 2/9 v2] xl: Improve return and exit codes of restore and save 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no 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 save_domain(), main_restore(), main_save() and main_remus() in the file xl_cmdimpl are fixed. Signed-off-by: Harmandeep Kaur --- v2: Add main_remus(). Remove create_domain(). --- tools/libxl/xl_cmdimpl.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 088971e..690eb91 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -4131,7 +4131,7 @@ static int save_domain(uint32_t domid, const char *filename, int checkpoint, fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644); if (fd < 0) { fprintf(stderr, "Failed to open temp file %s for writing\n", filename); - exit(2); + exit(EXIT_FAILURE); } save_domain_core_writeconfig(fd, filename, config_data, config_len); @@ -4151,7 +4151,7 @@ static int save_domain(uint32_t domid, const char *filename, int checkpoint, else libxl_domain_destroy(ctx, domid, 0); - exit(rc < 0 ? 1 : 0); + exit(rc < 0 ? EXIT_FAILURE : EXIT_SUCCESS); } static pid_t create_migration_child(const char *rune, int *send_fd, @@ -4625,7 +4625,7 @@ int main_restore(int argc, char **argv) checkpoint_file = argv[optind + 1]; } else { help("restore"); - return 2; + return EXIT_FAILURE; } memset(&dom_info, 0, sizeof(dom_info)); @@ -4642,9 +4642,9 @@ int main_restore(int argc, char **argv) rc = create_domain(&dom_info); if (rc < 0) - return -rc; + return EXIT_FAILURE; - return 0; + return EXIT_SUCCESS; } int main_migrate_receive(int argc, char **argv) @@ -4700,7 +4700,7 @@ int main_save(int argc, char **argv) if (argc-optind > 3) { help("save"); - return 2; + return EXIT_FAILURE; } domid = find_domain(argv[optind]); @@ -4709,7 +4709,7 @@ int main_save(int argc, char **argv) config_filename = argv[optind + 2]; save_domain(domid, filename, checkpoint, leavepaused, config_filename); - return 0; + return EXIT_SUCCESS; } int main_migrate(int argc, char **argv) @@ -8085,7 +8085,7 @@ int main_remus(int argc, char **argv) send_fd = open("/dev/null", O_RDWR, 0644); if (send_fd < 0) { perror("failed to open /dev/null"); - exit(-1); + exit(EXIT_FAILURE); } } else { @@ -8102,7 +8102,7 @@ int main_remus(int argc, char **argv) if (!config_len) { fprintf(stderr, "No config file stored for running domain and " "none supplied - cannot start remus.\n"); - exit(1); + exit(EXIT_FAILURE); } child = create_migration_child(rune, &send_fd, &recv_fd); @@ -8123,7 +8123,7 @@ int main_remus(int argc, char **argv) if (libxl_domain_info(ctx, 0, domid)) { fprintf(stderr, "Remus: Primary domain has been destroyed.\n"); close(send_fd); - return 0; + return EXIT_SUCCESS; } /* If we are here, it means remus setup/domain suspend/backup has @@ -8138,7 +8138,7 @@ int main_remus(int argc, char **argv) } close(send_fd); - return -ERROR_FAIL; + return EXIT_FAILURE; } #endif