diff mbox

[2/9,v2] xl: Improve return and exit codes of restore and save related functions.

Message ID 1457463730-4712-3-git-send-email-write.harmandeep@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Harmandeep Kaur March 8, 2016, 7:02 p.m. UTC
save_domain(), main_restore(), main_save() and main_remus() in the file
xl_cmdimpl are fixed.

Signed-off-by: Harmandeep Kaur <write.harmandeep@gmail.com>
---
v2: Add main_remus().
    Remove create_domain().
---
 tools/libxl/xl_cmdimpl.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
diff mbox

Patch

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