All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] xl: convert scheduling related return codes to EXIT_[SUCCESS|FAILURE]
@ 2015-10-23  7:48 Harmandeep Kaur
  2015-10-23  7:48 ` [PATCH 2/3] xl: convert vcpu " Harmandeep Kaur
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Harmandeep Kaur @ 2015-10-23  7:48 UTC (permalink / raw)
  To: xen-devel
  Cc: stefano.stebellini, wei.liu2, ian.campbell, dario.faggioli,
	ian.jackson, george.dunlap, Harmandeep Kaur

turning scheduling related functions xl exit codes towards using the
EXIT_[SUCCESS|FAILURE] macros, instead of instead of arbitrary numbers
or libxl return codes.

Signed-off-by: Harmandeep Kaur <write.harmandeep@gmail.com>
---
 tools/libxl/xl_cmdimpl.c | 67 ++++++++++++++++++++++++------------------------
 1 file changed, 33 insertions(+), 34 deletions(-)

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 365798b..c215c14 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -5851,13 +5851,13 @@ static int sched_credit_domain_output(int domid)
 
     if (domid < 0) {
         printf("%-33s %4s %6s %4s\n", "Name", "ID", "Weight", "Cap");
-        return 0;
+        return EXIT_SUCCESS;
     }
 
     libxl_domain_sched_params_init(&scinfo);
     rc = sched_domain_get(LIBXL_SCHEDULER_CREDIT, domid, &scinfo);
     if (rc)
-        return rc;
+        return EXIT_FAILURE;
     domname = libxl_domid_to_name(ctx, domid);
     printf("%-33s %4d %6d %4d\n",
         domname,
@@ -5866,7 +5866,7 @@ static int sched_credit_domain_output(int domid)
         scinfo.cap);
     free(domname);
     libxl_domain_sched_params_dispose(&scinfo);
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 static int sched_credit_pool_output(uint32_t poolid)
@@ -5887,7 +5887,7 @@ static int sched_credit_pool_output(uint32_t poolid)
                scparam.ratelimit_us);
     }
     free(poolname);
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 static int sched_credit2_domain_output(
@@ -5899,13 +5899,13 @@ static int sched_credit2_domain_output(
 
     if (domid < 0) {
         printf("%-33s %4s %6s\n", "Name", "ID", "Weight");
-        return 0;
+        return EXIT_SUCCESS;
     }
 
     libxl_domain_sched_params_init(&scinfo);
     rc = sched_domain_get(LIBXL_SCHEDULER_CREDIT2, domid, &scinfo);
     if (rc)
-        return rc;
+        return EXIT_FAILURE;
     domname = libxl_domid_to_name(ctx, domid);
     printf("%-33s %4d %6d\n",
         domname,
@@ -5913,7 +5913,7 @@ static int sched_credit2_domain_output(
         scinfo.weight);
     free(domname);
     libxl_domain_sched_params_dispose(&scinfo);
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 static int sched_rtds_domain_output(
@@ -5925,13 +5925,14 @@ static int sched_rtds_domain_output(
 
     if (domid < 0) {
         printf("%-33s %4s %9s %9s\n", "Name", "ID", "Period", "Budget");
-        return 0;
+        return EXIT_SUCCESS;
     }
 
     libxl_domain_sched_params_init(&scinfo);
     rc = sched_domain_get(LIBXL_SCHEDULER_RTDS, domid, &scinfo);
     if (rc)
-        goto out;
+        libxl_domain_sched_params_dispose(&scinfo);
+        return EXIT_FAILURE;
 
     domname = libxl_domid_to_name(ctx, domid);
     printf("%-33s %4d %9d %9d\n",
@@ -5940,10 +5941,8 @@ static int sched_rtds_domain_output(
         scinfo.period,
         scinfo.budget);
     free(domname);
-
-out:
     libxl_domain_sched_params_dispose(&scinfo);
-    return rc;
+    return EXIT_SUCCESS;
 }
 
 static int sched_rtds_pool_output(uint32_t poolid)
@@ -5954,7 +5953,7 @@ static int sched_rtds_pool_output(uint32_t poolid)
     printf("Cpupool %s: sched=RTDS\n", poolname);
 
     free(poolname);
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 static int sched_default_pool_output(uint32_t poolid)
@@ -5965,7 +5964,7 @@ static int sched_default_pool_output(uint32_t poolid)
     printf("Cpupool %s:\n",
            poolname);
     free(poolname);
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 static int sched_domain_output(libxl_scheduler sched, int (*output)(int),
@@ -5981,14 +5980,14 @@ static int sched_domain_output(libxl_scheduler sched, int (*output)(int),
         if (libxl_cpupool_qualifier_to_cpupoolid(ctx, cpupool, &poolid, NULL) ||
             !libxl_cpupoolid_is_valid(ctx, poolid)) {
             fprintf(stderr, "unknown cpupool \'%s\'\n", cpupool);
-            return -ERROR_FAIL;
+            return EXIT_FAILURE;
         }
     }
 
     info = libxl_list_domain(ctx, &nb_domain);
     if (!info) {
         fprintf(stderr, "libxl_list_domain failed.\n");
-        return 1;
+        return EXIT_FAILURE;
     }
     poolinfo = libxl_list_cpupool(ctx, &n_pools);
     if (!poolinfo) {
@@ -6016,7 +6015,7 @@ static int sched_domain_output(libxl_scheduler sched, int (*output)(int),
 
     libxl_cpupoolinfo_list_free(poolinfo, n_pools);
     libxl_dominfo_list_free(info, nb_domain);
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 /* 
@@ -6080,16 +6079,16 @@ int main_sched_credit(int argc, char **argv)
     if ((cpupool || opt_s) && (dom || opt_w || opt_c)) {
         fprintf(stderr, "Specifying a cpupool or schedparam is not "
                 "allowed with domain options.\n");
-        return 1;
+        return EXIT_FAILURE;
     }
     if (!dom && (opt_w || opt_c)) {
         fprintf(stderr, "Must specify a domain.\n");
-        return 1;
+        return EXIT_FAILURE;
     }
     if (!opt_s && (opt_t || opt_r)) {
         fprintf(stderr, "Must specify schedparam to set schedule "
                 "parameter values.\n");
-        return 1;
+        return EXIT_FAILURE;
     }
 
     if (opt_s) {
@@ -6101,7 +6100,7 @@ int main_sched_credit(int argc, char **argv)
                                                      &poolid, NULL) ||
                 !libxl_cpupoolid_is_valid(ctx, poolid)) {
                 fprintf(stderr, "unknown cpupool \'%s\'\n", cpupool);
-                return -ERROR_FAIL;
+                return EXIT_FAILURE;
             }
         }
 
@@ -6110,7 +6109,7 @@ int main_sched_credit(int argc, char **argv)
         } else { /* Set scheduling parameters*/
             rc = sched_credit_params_get(poolid, &scparam);
             if (rc)
-                return -rc;
+                return EXIT_FAILURE;
 
             if (opt_t)
                 scparam.tslice_ms = tslice;
@@ -6120,7 +6119,7 @@ int main_sched_credit(int argc, char **argv)
 
             rc = sched_credit_params_set(poolid, &scparam);
             if (rc)
-                return -rc;
+                return EXIT_FAILURE;
         }
     } else if (!dom) { /* list all domain's credit scheduler info */
         return -sched_domain_output(LIBXL_SCHEDULER_CREDIT,
@@ -6144,11 +6143,11 @@ int main_sched_credit(int argc, char **argv)
             rc = sched_domain_set(domid, &scinfo);
             libxl_domain_sched_params_dispose(&scinfo);
             if (rc)
-                return -rc;
+                return EXIT_FAILURE;
         }
     }
 
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 int main_sched_credit2(int argc, char **argv)
@@ -6180,11 +6179,11 @@ int main_sched_credit2(int argc, char **argv)
     if (cpupool && (dom || opt_w)) {
         fprintf(stderr, "Specifying a cpupool is not allowed with other "
                 "options.\n");
-        return 1;
+        return EXIT_FAILURE;
     }
     if (!dom && opt_w) {
         fprintf(stderr, "Must specify a domain.\n");
-        return 1;
+        return EXIT_FAILURE;
     }
 
     if (!dom) { /* list all domain's credit scheduler info */
@@ -6207,11 +6206,11 @@ int main_sched_credit2(int argc, char **argv)
             rc = sched_domain_set(domid, &scinfo);
             libxl_domain_sched_params_dispose(&scinfo);
             if (rc)
-                return -rc;
+                return EXIT_FAILURE;
         }
     }
 
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 /*
@@ -6256,15 +6255,15 @@ int main_sched_rtds(int argc, char **argv)
     if (cpupool && (dom || opt_p || opt_b)) {
         fprintf(stderr, "Specifying a cpupool is not allowed with "
                 "other options.\n");
-        return 1;
+        return EXIT_FAILURE;
     }
     if (!dom && (opt_p || opt_b)) {
         fprintf(stderr, "Must specify a domain.\n");
-        return 1;
+        return EXIT_FAILURE;
     }
     if (opt_p != opt_b) {
         fprintf(stderr, "Must specify period and budget\n");
-        return 1;
+        return EXIT_FAILURE;
     }
 
     if (!dom) { /* list all domain's rt scheduler info */
@@ -6287,11 +6286,11 @@ int main_sched_rtds(int argc, char **argv)
             rc = sched_domain_set(domid, &scinfo);
             libxl_domain_sched_params_dispose(&scinfo);
             if (rc)
-                return -rc;
+                return EXIT_FAILURE;
         }
     }
 
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 int main_domid(int argc, char **argv)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/3] xl: convert vcpu related return codes to EXIT_[SUCCESS|FAILURE]
  2015-10-23  7:48 [PATCH 1/3] xl: convert scheduling related return codes to EXIT_[SUCCESS|FAILURE] Harmandeep Kaur
@ 2015-10-23  7:48 ` Harmandeep Kaur
  2015-10-23 10:41   ` Dario Faggioli
  2015-10-23  7:48 ` [PATCH 3/3] xl: convert cpupool " Harmandeep Kaur
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Harmandeep Kaur @ 2015-10-23  7:48 UTC (permalink / raw)
  To: xen-devel
  Cc: stefano.stebellini, wei.liu2, ian.campbell, dario.faggioli,
	ian.jackson, george.dunlap, Harmandeep Kaur

turning vcpu manipulation functions xl exit codes toward using the
EXIT_[SUCCESS|FAILURE] macros, instead of instead of arbitrary numbers
or libxl return codes.

Signed-off-by: Harmandeep Kaur <write.harmandeep@gmail.com>
---
 tools/libxl/xl_cmdimpl.c | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index c215c14..2cb4fe8 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -946,11 +946,11 @@ static void parse_vcpu_affinity(libxl_domain_build_info *b_info,
             libxl_bitmap_init(&vcpu_affinity_array[j]);
             if (libxl_cpu_bitmap_alloc(ctx, &vcpu_affinity_array[j], 0)) {
                 fprintf(stderr, "Unable to allocate cpumap for vcpu %d\n", j);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
 
             if (cpurange_parse(buf, &vcpu_affinity_array[j]))
-                exit(1);
+                exit(EXIT_FAILURE);
 
             j++;
         }
@@ -963,17 +963,17 @@ static void parse_vcpu_affinity(libxl_domain_build_info *b_info,
         libxl_bitmap_init(&vcpu_affinity_array[0]);
         if (libxl_cpu_bitmap_alloc(ctx, &vcpu_affinity_array[0], 0)) {
             fprintf(stderr, "Unable to allocate cpumap for vcpu 0\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         if (cpurange_parse(buf, &vcpu_affinity_array[0]))
-            exit(1);
+            exit(EXIT_FAILURE);
 
         for (i = 1; i < b_info->max_vcpus; i++) {
             libxl_bitmap_init(&vcpu_affinity_array[i]);
             if (libxl_cpu_bitmap_alloc(ctx, &vcpu_affinity_array[i], 0)) {
                 fprintf(stderr, "Unable to allocate cpumap for vcpu %d\n", i);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             libxl_bitmap_copy(ctx, &vcpu_affinity_array[i],
                               &vcpu_affinity_array[0]);
@@ -1086,7 +1086,7 @@ static void parse_vnuma_config(const XLU_Config *config,
     if (libxl_get_physinfo(ctx, &physinfo) != 0) {
         libxl_physinfo_dispose(&physinfo);
         fprintf(stderr, "libxl_get_physinfo failed\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     nr_nodes = physinfo.nr_nodes;
@@ -1105,7 +1105,7 @@ static void parse_vnuma_config(const XLU_Config *config,
         libxl_bitmap_init(&vcpu_parsed[i]);
         if (libxl_cpu_bitmap_alloc(ctx, &vcpu_parsed[i], b_info->max_vcpus)) {
             fprintf(stderr, "libxl_node_bitmap_alloc failed.\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -1130,7 +1130,7 @@ static void parse_vnuma_config(const XLU_Config *config,
         xlu_cfg_value_get_list(config, vnode_spec, &vnode_config_list, 0);
         if (!vnode_config_list) {
             fprintf(stderr, "xl: cannot get vnode config option list\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         for (conf_count = 0;
@@ -1152,7 +1152,7 @@ static void parse_vnuma_config(const XLU_Config *config,
                                            &value_untrimmed)) {
                     fprintf(stderr, "xl: failed to split \"%s\" into pair\n",
                             buf);
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 trim(isspace, option_untrimmed, &option);
                 trim(isspace, value_untrimmed, &value);
@@ -1162,7 +1162,7 @@ static void parse_vnuma_config(const XLU_Config *config,
                     if (val >= nr_nodes) {
                         fprintf(stderr,
                                 "xl: invalid pnode number: %lu\n", val);
-                        exit(1);
+                        exit(EXIT_FAILURE);
                     }
                     p->pnode = val;
                     libxl_defbool_set(&b_info->numa_placement, false);
@@ -1218,20 +1218,20 @@ static void parse_vnuma_config(const XLU_Config *config,
     if (b_info->max_vcpus != 0) {
         if (b_info->max_vcpus != max_vcpus) {
             fprintf(stderr, "xl: vnuma vcpus and maxvcpus= mismatch\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     } else {
         int host_cpus = libxl_get_online_cpus(ctx);
 
         if (host_cpus < 0) {
             fprintf(stderr, "Failed to get online cpus\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         if (host_cpus < max_vcpus) {
             fprintf(stderr, "xl: vnuma specifies more vcpus than pcpus, "\
                     "use maxvcpus= to override this check.\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         b_info->max_vcpus = max_vcpus;
@@ -1241,7 +1241,7 @@ static void parse_vnuma_config(const XLU_Config *config,
     if (b_info->max_memkb != LIBXL_MEMKB_DEFAULT &&
         b_info->max_memkb != max_memkb) {
         fprintf(stderr, "xl: maxmem and vnuma memory size mismatch\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     } else
         b_info->max_memkb = max_memkb;
 
@@ -5316,7 +5316,7 @@ int main_vcpulist(int argc, char **argv)
     }
 
     vcpulist(argc - optind, argv + optind);
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 int main_vcpupin(int argc, char **argv)
@@ -5407,7 +5407,7 @@ int main_vcpupin(int argc, char **argv)
 
         if (ferror(stdout) || fflush(stdout)) {
             perror("stdout");
-            exit(-1);
+            exit(EXIT_FAILURE);
         }
 
         rc = 0;
@@ -5434,7 +5434,7 @@ int main_vcpupin(int argc, char **argv)
  out:
     libxl_bitmap_dispose(&cpumap_soft);
     libxl_bitmap_dispose(&cpumap_hard);
-    return rc;
+    return rc ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
 static int vcpuset(uint32_t domid, const char* nr_vcpus, int check_host)
@@ -5448,7 +5448,7 @@ static int vcpuset(uint32_t domid, const char* nr_vcpus, int check_host)
     max_vcpus = strtoul(nr_vcpus, &endptr, 10);
     if (nr_vcpus == endptr) {
         fprintf(stderr, "Error: Invalid argument.\n");
-        return 1;
+        return EXIT_FAILURE;
     }
 
     /*
@@ -5461,7 +5461,7 @@ static int vcpuset(uint32_t domid, const char* nr_vcpus, int check_host)
 
         rc = libxl_domain_info(ctx, &dominfo, domid);
         if (rc)
-            return 1;
+            return EXIT_FAILURE;
 
         if (max_vcpus > dominfo.vcpu_online && max_vcpus > host_cpu) {
             fprintf(stderr, "You are overcommmitting! You have %d physical" \
@@ -5471,12 +5471,12 @@ static int vcpuset(uint32_t domid, const char* nr_vcpus, int check_host)
         }
         libxl_dominfo_dispose(&dominfo);
         if (rc)
-            return 1;
+            return EXIT_FAILURE;
     }
     rc = libxl_cpu_bitmap_alloc(ctx, &cpumap, max_vcpus);
     if (rc) {
         fprintf(stderr, "libxl_cpu_bitmap_alloc failed, rc: %d\n", rc);
-        return 1;
+        return EXIT_FAILURE;
     }
     for (i = 0; i < max_vcpus; i++)
         libxl_bitmap_set(&cpumap, i);
@@ -5489,7 +5489,7 @@ static int vcpuset(uint32_t domid, const char* nr_vcpus, int check_host)
                 " rc: %d\n", domid, max_vcpus, rc);
 
     libxl_bitmap_dispose(&cpumap);
-    return rc ? 1 : 0;
+    return rc ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
 int main_vcpuset(int argc, char **argv)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/3] xl: convert cpupool related return codes to EXIT_[SUCCESS|FAILURE]
  2015-10-23  7:48 [PATCH 1/3] xl: convert scheduling related return codes to EXIT_[SUCCESS|FAILURE] Harmandeep Kaur
  2015-10-23  7:48 ` [PATCH 2/3] xl: convert vcpu " Harmandeep Kaur
@ 2015-10-23  7:48 ` Harmandeep Kaur
  2015-10-23 12:10   ` Dario Faggioli
  2015-10-23  8:30 ` [PATCH 1/3] xl: convert scheduling " Dario Faggioli
  2015-10-23 10:16 ` Dario Faggioli
  3 siblings, 1 reply; 11+ messages in thread
From: Harmandeep Kaur @ 2015-10-23  7:48 UTC (permalink / raw)
  To: xen-devel
  Cc: stefano.stebellini, wei.liu2, ian.campbell, dario.faggioli,
	ian.jackson, george.dunlap, Harmandeep Kaur

turning  cpupools related functions xl exit codes towards using the
EXIT_[SUCCESS|FAILURE] macros, instead of instead of arbitrary numbers
or libxl return codes.

Signed-off-by: Harmandeep Kaur <write.harmandeep@gmail.com>
---
 tools/libxl/xl_cmdimpl.c | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 2cb4fe8..c7009cf 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -7497,7 +7497,7 @@ out:
     free(name);
     free(config_data);
     free(extra_config);
-    return rc;
+    return rc ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
 int main_cpupoollist(int argc, char **argv)
@@ -7524,14 +7524,14 @@ int main_cpupoollist(int argc, char **argv)
         pool = argv[optind];
         if (libxl_name_to_cpupoolid(ctx, pool, &poolid)) {
             fprintf(stderr, "Pool \'%s\' does not exist\n", pool);
-            return 1;
+            return EXIT_FAILURE;
         }
     }
 
     poolinfo = libxl_list_cpupool(ctx, &n_pools);
     if (!poolinfo) {
         fprintf(stderr, "error getting cpupool info\n");
-        return 1;
+        return EXIT_FAILURE;
     }
 
     printf("%-19s", "Name");
@@ -7562,7 +7562,7 @@ int main_cpupoollist(int argc, char **argv)
 
     libxl_cpupoolinfo_list_free(poolinfo, n_pools);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 int main_cpupooldestroy(int argc, char **argv)
@@ -7580,13 +7580,13 @@ int main_cpupooldestroy(int argc, char **argv)
     if (libxl_cpupool_qualifier_to_cpupoolid(ctx, pool, &poolid, NULL) ||
         !libxl_cpupoolid_is_valid(ctx, poolid)) {
         fprintf(stderr, "unknown cpupool '%s'\n", pool);
-        return 1;
+        return EXIT_FAILURE;
     }
 
     if (libxl_cpupool_destroy(ctx, poolid))
-        return 1;
+        return EXIT_FAILURE;
 
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 int main_cpupoolrename(int argc, char **argv)
@@ -7605,17 +7605,17 @@ int main_cpupoolrename(int argc, char **argv)
     if (libxl_cpupool_qualifier_to_cpupoolid(ctx, pool, &poolid, NULL) ||
         !libxl_cpupoolid_is_valid(ctx, poolid)) {
         fprintf(stderr, "unknown cpupool '%s'\n", pool);
-        return 1;
+        return EXIT_FAILURE;
     }
 
     new_name = argv[optind];
 
     if (libxl_cpupool_rename(ctx, new_name, poolid)) {
         fprintf(stderr, "Can't rename cpupool '%s'\n", pool);
-        return 1;
+        return EXIT_FAILURE;
     }
 
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 int main_cpupoolcpuadd(int argc, char **argv)
@@ -7633,7 +7633,7 @@ int main_cpupoolcpuadd(int argc, char **argv)
     libxl_bitmap_init(&cpumap);
     if (libxl_cpu_bitmap_alloc(ctx, &cpumap, 0)) {
         fprintf(stderr, "Unable to allocate cpumap");
-        return 1;
+        return EXIT_FAILURE;
     }
 
     pool = argv[optind++];
@@ -7653,7 +7653,7 @@ int main_cpupoolcpuadd(int argc, char **argv)
 
 out:
     libxl_bitmap_dispose(&cpumap);
-    return rc;
+    return rc ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
 int main_cpupoolcpuremove(int argc, char **argv)
@@ -7667,7 +7667,7 @@ int main_cpupoolcpuremove(int argc, char **argv)
     libxl_bitmap_init(&cpumap);
     if (libxl_cpu_bitmap_alloc(ctx, &cpumap, 0)) {
         fprintf(stderr, "Unable to allocate cpumap");
-        return 1;
+        return EXIT_FAILURE;
     }
 
     SWITCH_FOREACH_OPT(opt, "", NULL, "cpupool-cpu-remove", 2) {
@@ -7691,7 +7691,7 @@ int main_cpupoolcpuremove(int argc, char **argv)
 
 out:
     libxl_bitmap_dispose(&cpumap);
-    return rc;
+    return rc ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
 int main_cpupoolmigrate(int argc, char **argv)
@@ -7712,19 +7712,19 @@ int main_cpupoolmigrate(int argc, char **argv)
     if (libxl_domain_qualifier_to_domid(ctx, dom, &domid) ||
         !libxl_domid_to_name(ctx, domid)) {
         fprintf(stderr, "unknown domain '%s'\n", dom);
-        return 1;
+        return EXIT_FAILURE;
     }
 
     if (libxl_cpupool_qualifier_to_cpupoolid(ctx, pool, &poolid, NULL) ||
         !libxl_cpupoolid_is_valid(ctx, poolid)) {
         fprintf(stderr, "unknown cpupool '%s'\n", pool);
-        return 1;
+        return EXIT_FAILURE;
     }
 
     if (libxl_cpupool_movedomain(ctx, poolid, domid))
-        return 1;
+        return EXIT_FAILURE;
 
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 int main_cpupoolnumasplit(int argc, char **argv)
@@ -7758,7 +7758,7 @@ int main_cpupoolnumasplit(int argc, char **argv)
     poolinfo = libxl_list_cpupool(ctx, &n_pools);
     if (!poolinfo) {
         fprintf(stderr, "error getting cpupool info\n");
-        return 1;
+        return EXIT_FAILURE;
     }
     poolid = poolinfo[0].poolid;
     sched = poolinfo[0].sched;
@@ -7766,13 +7766,13 @@ int main_cpupoolnumasplit(int argc, char **argv)
 
     if (n_pools > 1) {
         fprintf(stderr, "splitting not possible, already cpupools in use\n");
-        return 1;
+        return EXIT_FAILURE;
     }
 
     topology = libxl_get_cpu_topology(ctx, &n_cpus);
     if (topology == NULL) {
         fprintf(stderr, "libxl_get_topologyinfo failed\n");
-        return 1;
+        return EXIT_FAILURE;
     }
 
     if (libxl_cpu_bitmap_alloc(ctx, &cpumap, 0)) {
@@ -7869,7 +7869,7 @@ out:
     libxl_dominfo_dispose(&info);
     free(name);
 
-    return rc;
+    return rc ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
 int main_getenforce(int argc, char **argv)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] xl: convert scheduling related return codes to EXIT_[SUCCESS|FAILURE]
  2015-10-23  7:48 [PATCH 1/3] xl: convert scheduling related return codes to EXIT_[SUCCESS|FAILURE] Harmandeep Kaur
  2015-10-23  7:48 ` [PATCH 2/3] xl: convert vcpu " Harmandeep Kaur
  2015-10-23  7:48 ` [PATCH 3/3] xl: convert cpupool " Harmandeep Kaur
@ 2015-10-23  8:30 ` Dario Faggioli
  2015-10-23  9:56   ` Ian Campbell
  2015-10-23 10:16 ` Dario Faggioli
  3 siblings, 1 reply; 11+ messages in thread
From: Dario Faggioli @ 2015-10-23  8:30 UTC (permalink / raw)
  To: Harmandeep Kaur, xen-devel
  Cc: Lars Kurth, stefano.stebellini, wei.liu2, ian.campbell,
	ian.jackson, george.dunlap


[-- Attachment #1.1: Type: text/plain, Size: 1330 bytes --]

On Fri, 2015-10-23 at 13:18 +0530, Harmandeep Kaur wrote:
> turning scheduling related functions xl exit codes towards using the
> EXIT_[SUCCESS|FAILURE] macros, instead of instead of arbitrary
> numbers
> or libxl return codes.
> 
So, it's probably worth mentioning that this is Harman's "bite size
contribution" that is required for applying to the Outreachy program.

Harman, when you send a patch series, as you did here (thanks and good job doing it so quickly :-) ), you want to include a 'cover letter'. That is an introductory email, often labelled (usually automatically by git tools) as patch 0 of the series itself. In it, you give a brief explanation of what the series is meant at, and any kind of information you think the people reviewing the series should have, but that wouldn't fit in the various patches' changelogs, code comments, etc.

For instance, in this case, you could have mentioned (among other things) that this is your small contribution for the sake of applying to Outreachy right in there. :-)

Thanks and Regards,
Dario
-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)


[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] xl: convert scheduling related return codes to EXIT_[SUCCESS|FAILURE]
  2015-10-23  8:30 ` [PATCH 1/3] xl: convert scheduling " Dario Faggioli
@ 2015-10-23  9:56   ` Ian Campbell
  2015-10-23 10:03     ` Dario Faggioli
  0 siblings, 1 reply; 11+ messages in thread
From: Ian Campbell @ 2015-10-23  9:56 UTC (permalink / raw)
  To: Dario Faggioli, Harmandeep Kaur, xen-devel
  Cc: wei.liu2, stefano.stebellini, ian.jackson, george.dunlap, Lars Kurth

On Fri, 2015-10-23 at 10:30 +0200, Dario Faggioli wrote:
> On Fri, 2015-10-23 at 13:18 +0530, Harmandeep Kaur wrote:
> > turning scheduling related functions xl exit codes towards using the
> > EXIT_[SUCCESS|FAILURE] macros, instead of instead of arbitrary
> > numbers
> > or libxl return codes.
> > 
> So, it's probably worth mentioning that this is Harman's "bite size
> contribution" that is required for applying to the Outreachy program.
> 
> Harman, when you send a patch series, as you did here (thanks and good
> job doing it so quickly :-) ), you want to include a 'cover letter'. That
> is an introductory email, often labelled (usually automatically by git
> tools) as patch 0 of the series itself. In it, you give a brief
> explanation of what the series is meant at, and any kind of information
> you think the people reviewing the series should have, but that wouldn't
> fit in the various patches' changelogs, code comments, etc.

In particular in this case I would like to know whether all xl functions
now use EXIT_SUCCESS/FAILURE or if there is still inconsistencies/work to
be done.

I don't see any existing use of of EXIT_* in xl*.

> 
> For instance, in this case, you could have mentioned (among other things)
> that this is your small contribution for the sake of applying to
> Outreachy right in there. :-)
> 
> Thanks and Regards,
> Dario

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] xl: convert scheduling related return codes to EXIT_[SUCCESS|FAILURE]
  2015-10-23  9:56   ` Ian Campbell
@ 2015-10-23 10:03     ` Dario Faggioli
  2015-10-23 10:16       ` Ian Campbell
  0 siblings, 1 reply; 11+ messages in thread
From: Dario Faggioli @ 2015-10-23 10:03 UTC (permalink / raw)
  To: Ian Campbell, Harmandeep Kaur, xen-devel
  Cc: wei.liu2, Lars Kurth, ian.jackson, george.dunlap, stefano.stabellini


[-- Attachment #1.1: Type: text/plain, Size: 1790 bytes --]

On Fri, 2015-10-23 at 10:56 +0100, Ian Campbell wrote:
> On Fri, 2015-10-23 at 10:30 +0200, Dario Faggioli wrote:

> > Harman, when you send a patch series, as you did here (thanks and
> > good
> > job doing it so quickly :-) ), you want to include a 'cover
> > letter'. That
> > is an introductory email, often labelled (usually automatically by
> > git
> > tools) as patch 0 of the series itself. In it, you give a brief
> > explanation of what the series is meant at, and any kind of
> > information
> > you think the people reviewing the series should have, but that
> > wouldn't
> > fit in the various patches' changelogs, code comments, etc.
> 
> In particular in this case I would like to know whether all xl
> functions
> now use EXIT_SUCCESS/FAILURE or if there is still
> inconsistencies/work to
> be done.
> 
Exactly, Harman, these are the sort of things you'd include in a cover
letter for a series like this.

> I don't see any existing use of of EXIT_* in xl*.
> 
I sent a patch turning one function into doing so just yesterday. :-)

We (me, you and Wei) talked about it a while back (see the changelog of
that patch, it has the links):

 https://www.mail-archive.com/xen-devel@lists.xen.org/msg42850.html

And yes, I have it in my todo list to convert all of them. I'm fine
with committing to do that for 4.7.

This effort from Harman is just me using my todo list items as
proposals for preliminary contribution for the sake of applying to
Outreacy. :-)

Regards,
Dario
-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] xl: convert scheduling related return codes to EXIT_[SUCCESS|FAILURE]
  2015-10-23  7:48 [PATCH 1/3] xl: convert scheduling related return codes to EXIT_[SUCCESS|FAILURE] Harmandeep Kaur
                   ` (2 preceding siblings ...)
  2015-10-23  8:30 ` [PATCH 1/3] xl: convert scheduling " Dario Faggioli
@ 2015-10-23 10:16 ` Dario Faggioli
  3 siblings, 0 replies; 11+ messages in thread
From: Dario Faggioli @ 2015-10-23 10:16 UTC (permalink / raw)
  To: Harmandeep Kaur, xen-devel
  Cc: wei.liu2, ian.campbell, ian.jackson, george.dunlap, stefano.stabellini


[-- Attachment #1.1: Type: text/plain, Size: 9001 bytes --]

Now, to the technical review...

On Fri, 2015-10-23 at 13:18 +0530, Harmandeep Kaur wrote:
> turning scheduling related functions xl exit codes towards using the
> EXIT_[SUCCESS|FAILURE] macros, instead of instead of arbitrary
> numbers
> or libxl return codes.
> 
Subject of the mail: something like "xl: convert exit codes of
scheduling operations to EXIT_[SUCCESS|FAILURE]"

Note the difference between "return codes", which makes one think to
all the 'return'-s off all the functions, and "exit codes", which, IMO,
expresses better that what we care is those 'return'-s and 'exit()'-s
that causes the program to actually exit.

Or, perhaps, given the kind of changes that I'm suggesting you to do in
this review of mine, even something like "xl: improve return and exit
codes of scheduling related functions".

(Yes, I know that the one you used, I kind of suggested it myself.
Still... :-D )

> Signed-off-by: Harmandeep Kaur <write.harmandeep@gmail.com>
> ---
>  tools/libxl/xl_cmdimpl.c | 67 ++++++++++++++++++++++++--------------
> ----------
>  1 file changed, 33 insertions(+), 34 deletions(-)
> 
> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> index 365798b..c215c14 100644
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -5851,13 +5851,13 @@ static int sched_credit_domain_output(int
> domid)
>  
>      if (domid < 0) {
>          printf("%-33s %4s %6s %4s\n", "Name", "ID", "Weight",
> "Cap");
> -        return 0;
> +        return EXIT_SUCCESS;
>      }
>  
In principle, this is ok. However, see below for a more general opinion
on this and similar functions.

>      libxl_domain_sched_params_init(&scinfo);
>      rc = sched_domain_get(LIBXL_SCHEDULER_CREDIT, domid, &scinfo);
>      if (rc)
> -        return rc;
> +        return EXIT_FAILURE;
>
This is right again. However, the actual value returned by
 sched_domain_get() is only used for being returned to the caller,
without your patch. With your patch, it's basically useless.

I think you can just get rid of it, and do something like:

 if (sched_domain_get(LIBXL_SCHEDULER_CREDIT, domid, &scinfo))
     return EXIT_SUCCESS;

(Or maybe just 'return -1', and you keep the 'return 0' in case
domid<0, but again, see below for more details on this.)

Actually, as you probably noticed yourself, when dealing with
sched_rtds_domain_output(), we're missing a call to the dispose
function, both here and in the sched_credit2_domain_output().

So, I think you either get rid of rc and do it like this (and that in
sched_credit2_domain_output() as well):

 if (sched_domain_get(LIBXL_SCHEDULER_CREDIT, domid, &scinfo)) {
     libxl_domain_sched_params_dispose();
     return -1;
 }

Or you do similarly to what sched_rtds_domain_output() does already,
and, again, do it for all the credit, credit2 and rtds variants:

    rc = 0
    ...
    if (sched_domain_get(LIBXL_SCHEDULER_CREDIT, domid, &scinfo)) {
        rc = -1;
        goto out;
    }
    ...
 out:
    libxl_domain_sched_param_dispose();
    return rc;

(again, see below on why -1 and not EXIT_FAILURE.)

Which variant to go for, I'll let you decide. If this were libxl (i.e.,
the library, not the xl program) code, the latter would be the way. In
xl, there are occurrences of both paradigms, and, at least in this
specific case, I personally like the former better.
But really, pick one, and then we'll see what tools maintainers
think. :-)

> @@ -5866,7 +5866,7 @@ static int sched_credit_domain_output(int
> domid)
>          scinfo.cap);
>      free(domname);
>      libxl_domain_sched_params_dispose(&scinfo);
> -    return 0;
> +    return EXIT_SUCCESS;
>  }
>  
Ok. So, about these sched_*_domain_output() functions.

I know that, right now, their return values may actually be used as
exit code, so you've done right changing all them to
EXIT_SUCCESS/FAILURE.

However, their return value is used as exit code only once (e.g., in
this case, in main_sched_credit()), while all the other times they're
called, they are just internal functions.

So, the approach I like best would be as follows:

 - make all them be proper internal functions. That means make them 
   return either 0 (on success) or -1 (on failure). Never 
   EXIT_SUCCESS/FAILURE and never rc or ERROR_<something>

 - change the only case where they're used as "exit functions", e.g., 
   in case of credit, inside main_sched_credit():

     if (!opt_w && !opt_c) { /* output credit scheduler info */
         sched_credit_domain_output(-1);
         if (sched_credit_domain_output(domid))
             return EXIT_FAILURE;
     }

   and, of course, the same in main_sched_credit2() and
   main_sched_rtds().

What do you think?
          
>  static int sched_credit_pool_output(uint32_t poolid)
> @@ -5887,7 +5887,7 @@ static int sched_credit_pool_output(uint32_t
> poolid)
>                 scparam.ratelimit_us);
>      }
>      free(poolname);
> -    return 0;
> +    return EXIT_SUCCESS;
>  }
>  
While you're changing this function, there is another example here of
rc being defined and assigned for no useful reason, in this case, even
before your patch.

Do you mind fixing this as well? That would mean, as above, getting rid
of the rc variable, and putting the call to sched_credit_params_get()
inside the if(), as condition, directly.


Ok, now that we are done with the sched_credit_*_output() functions,
note that sched_credit2_domain_output(), sched_rtds_domain_output(),
sched_credit2_pool_output() and sched_rtds_pool_output() have almost
identical structure to these that we just discussed. So, I'd say that
everything we say, applies to all.

Can you do the suggested restructuring for the whole lot?

> @@ -5981,14 +5980,14 @@ static int
> sched_domain_output(libxl_scheduler sched, int (*output)(int),
>          if (libxl_cpupool_qualifier_to_cpupoolid(ctx, cpupool,
> &poolid, NULL) ||
>              !libxl_cpupoolid_is_valid(ctx, poolid)) {
>              fprintf(stderr, "unknown cpupool \'%s\'\n", cpupool);
> -            return -ERROR_FAIL;
> +            return EXIT_FAILURE;
>          }
>      }
>  
>      info = libxl_list_domain(ctx, &nb_domain);
>      if (!info) {
>          fprintf(stderr, "libxl_list_domain failed.\n");
> -        return 1;
> +        return EXIT_FAILURE;
>      }
>      poolinfo = libxl_list_cpupool(ctx, &n_pools);
>      if (!poolinfo) {
> @@ -6016,7 +6015,7 @@ static int sched_domain_output(libxl_scheduler
> sched, int (*output)(int),
>  
>      libxl_cpupoolinfo_list_free(poolinfo, n_pools);
>      libxl_dominfo_list_free(info, nb_domain);
> -    return 0;
> +    return EXIT_SUCCESS;
>  }
> 
This (sched_domain_output()) is ok, and it's so much better to see it
much more consistent. :-)

However, I don't think I see you changing the call site of this. Right
now it is:

        return -sched_domain_output(LIBXL_SCHEDULER_CREDIT,
                                    sched_credit_domain_output,
                                    sched_credit_pool_output,
                                    cpupool);

But since you are returning EXIT_FAILURE or EXIT_SUCCESS already, we
don't want the '-' sign in front (I know, it's probably harmless, but
it would be weird to keep it).

Likewise for the other times this is called, for RTDS and CREDIT2.

> @@ -6110,7 +6109,7 @@ int main_sched_credit(int argc, char **argv)
>          } else { /* Set scheduling parameters*/
>              rc = sched_credit_params_get(poolid, &scparam);
>              if (rc)
> -                return -rc;
> +                return EXIT_FAILURE;
>  
Here we, one more time, don't need to save the return value of
sched_credit_params_get() in rc.

>              if (opt_t)
>                  scparam.tslice_ms = tslice;
> @@ -6120,7 +6119,7 @@ int main_sched_credit(int argc, char **argv)
>  
>              rc = sched_credit_params_set(poolid, &scparam);
>              if (rc)
> -                return -rc;
> +                return EXIT_FAILURE;
>
And neither we do here.

>          }
>      } else if (!dom) { /* list all domain's credit scheduler info */
>          return -sched_domain_output(LIBXL_SCHEDULER_CREDIT,
> @@ -6144,11 +6143,11 @@ int main_sched_credit(int argc, char **argv)
>              rc = sched_domain_set(domid, &scinfo);
>              libxl_domain_sched_params_dispose(&scinfo);
>              if (rc)
> -                return -rc;
> +                return EXIT_FAILURE;
>
OTOH, here it is ok to use rc (i.e., this specific change is ok).

Thanks and Regards,
Dario
-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)


[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] xl: convert scheduling related return codes to EXIT_[SUCCESS|FAILURE]
  2015-10-23 10:03     ` Dario Faggioli
@ 2015-10-23 10:16       ` Ian Campbell
  0 siblings, 0 replies; 11+ messages in thread
From: Ian Campbell @ 2015-10-23 10:16 UTC (permalink / raw)
  To: Dario Faggioli, Harmandeep Kaur, xen-devel
  Cc: wei.liu2, Lars Kurth, ian.jackson, george.dunlap, stefano.stabellini

On Fri, 2015-10-23 at 12:03 +0200, Dario Faggioli wrote:
> On Fri, 2015-10-23 at 10:56 +0100, Ian Campbell wrote:
> > On Fri, 2015-10-23 at 10:30 +0200, Dario Faggioli wrote:
> 
> > > Harman, when you send a patch series, as you did here (thanks and
> > > good
> > > job doing it so quickly :-) ), you want to include a 'cover
> > > letter'. That
> > > is an introductory email, often labelled (usually automatically by
> > > git
> > > tools) as patch 0 of the series itself. In it, you give a brief
> > > explanation of what the series is meant at, and any kind of
> > > information
> > > you think the people reviewing the series should have, but that
> > > wouldn't
> > > fit in the various patches' changelogs, code comments, etc.
> > 
> > In particular in this case I would like to know whether all xl
> > functions
> > now use EXIT_SUCCESS/FAILURE or if there is still
> > inconsistencies/work to
> > be done.
> > 
> Exactly, Harman, these are the sort of things you'd include in a cover
> letter for a series like this.
> 
> > I don't see any existing use of of EXIT_* in xl*.
> > 
> I sent a patch turning one function into doing so just yesterday. :-)
> 
> We (me, you and Wei) talked about it a while back (see the changelog of
> that patch, it has the links):
> 
>  https://www.mail-archive.com/xen-devel@lists.xen.org/msg42850.html

Those links to previous discussions like are certainly the sort of
rationale which ought to appear in either a commit log (or a patch #0 if
one exists) as part of the rationale for a change.

Ian.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/3] xl: convert vcpu related return codes to EXIT_[SUCCESS|FAILURE]
  2015-10-23  7:48 ` [PATCH 2/3] xl: convert vcpu " Harmandeep Kaur
@ 2015-10-23 10:41   ` Dario Faggioli
  0 siblings, 0 replies; 11+ messages in thread
From: Dario Faggioli @ 2015-10-23 10:41 UTC (permalink / raw)
  To: Harmandeep Kaur, xen-devel
  Cc: wei.liu2, ian.campbell, ian.jackson, george.dunlap, stefano.stabellini


[-- Attachment #1.1: Type: text/plain, Size: 2497 bytes --]

On Fri, 2015-10-23 at 13:18 +0530, Harmandeep Kaur wrote:
> turning vcpu manipulation functions xl exit codes toward using the
> EXIT_[SUCCESS|FAILURE] macros, instead of instead of arbitrary
> numbers
> or libxl return codes.
> 
So, this patch is, technically, mostly fine. The observations on the
subject made when reviewing patch 1 applies here too, of course.

Something on the selection of functions the functions. The title says
the patch will address "vcpu related functions". However, there are a
bunch of parse_*() functions in the diff.

I appreciate that, for instance, parse_vcpu_affinity() can be
considered a vcpu related function, but that applies a lot less to
 parse_vnuma_config(), IMO. I'd therefore exclude the latter from this
patch.

Alternatively, get rid of both and do another patch specifically for
dealing with parse_*() items. There are not many of them that are
actual exit paths and/or contain calls to exit() (parse_config_data()
is big enough, and a bit more complex, that it may well deserve its own
patch, and you can leave it alone, just mention that in the changelog).

A few more comments below.

> @@ -5461,7 +5461,7 @@ static int vcpuset(uint32_t domid, const char*
> nr_vcpus, int check_host)
>  
>          rc = libxl_domain_info(ctx, &dominfo, domid);
>          if (rc)
> -            return 1;
> +            return EXIT_FAILURE;
>  
 if (libxl_domain_info(ctx, &dominfo, domid))
     return EXIT_FAILURE;

>          if (max_vcpus > dominfo.vcpu_online && max_vcpus > host_cpu)
> {
>              fprintf(stderr, "You are overcommmitting! You have %d
> physical" \
> @@ -5471,12 +5471,12 @@ static int vcpuset(uint32_t domid, const
> char* nr_vcpus, int check_host)
>          }
>          libxl_dominfo_dispose(&dominfo);
>          if (rc)
> -            return 1;
> +            return EXIT_FAILURE;
>      }
>      rc = libxl_cpu_bitmap_alloc(ctx, &cpumap, max_vcpus);
>      if (rc) {
>          fprintf(stderr, "libxl_cpu_bitmap_alloc failed, rc: %d\n",
> rc);
> -        return 1;
> +        return EXIT_FAILURE;
>
 if (libxl_cpu_bitmap_alloc(ctx, &cpumap, max_vcpus))
     return EXIT_FAILURE;

Thanks and Regards,
Dario
-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)


[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/3] xl: convert cpupool related return codes to EXIT_[SUCCESS|FAILURE]
  2015-10-23  7:48 ` [PATCH 3/3] xl: convert cpupool " Harmandeep Kaur
@ 2015-10-23 12:10   ` Dario Faggioli
  2015-10-23 12:33     ` Harmandeep Kaur
  0 siblings, 1 reply; 11+ messages in thread
From: Dario Faggioli @ 2015-10-23 12:10 UTC (permalink / raw)
  To: Harmandeep Kaur, xen-devel
  Cc: ian.jackson, stefano.stebellini, wei.liu2, ian.campbell, george.dunlap


[-- Attachment #1.1: Type: text/plain, Size: 3925 bytes --]

And here we are at the last patch of this series.

Allow me to say that this is quite good a first contribution! Thanks
for this, and I'm looking forward to seeing version 2!! :-D

About this patch, a few comments below.

On Fri, 2015-10-23 at 13:18 +0530, Harmandeep Kaur wrote:
> turning  cpupools related functions xl exit codes towards using the
> EXIT_[SUCCESS|FAILURE] macros, instead of instead of arbitrary
> numbers
> or libxl return codes.
> 
> Signed-off-by: Harmandeep Kaur <write.harmandeep@gmail.com>

> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -7497,7 +7497,7 @@ out:
>      free(name);
>      free(config_data);
>      free(extra_config);
> -    return rc;
> +    return rc ? EXIT_FAILURE : EXIT_SUCCESS;
>  }
> 
I think you can just initialize rc with EXIT_FAILURE, assign
EXIT_SUCCESS to it near the end, if everything went ok, and then keep
the 'return rc';
  
>  int main_cpupooldestroy(int argc, char **argv)
> @@ -7580,13 +7580,13 @@ int main_cpupooldestroy(int argc, char
> **argv)
>      if (libxl_cpupool_qualifier_to_cpupoolid(ctx, pool, &poolid,
> NULL) ||
>          !libxl_cpupoolid_is_valid(ctx, poolid)) {
>          fprintf(stderr, "unknown cpupool '%s'\n", pool);
> -        return 1;
> +        return EXIT_FAILURE;
>      }
>  
>      if (libxl_cpupool_destroy(ctx, poolid))
> -        return 1;
> +        return EXIT_FAILURE;
>  
> -    return 0;
> +    return EXIT_SUCCESS;
>  }
> 
For this one: I've sent a patch for another reason yesterday, and while
there I did the exit code adjustment myself. So, update your tree and,
if my patch has been committed already, just skip this function.

 https://www.mail-archive.com/xen-devel@lists.xen.org/msg42850.html

Which brings up a question: what git tree are you using for
development? You should stay either on master or staging branches (and
I recommend staging) of the official repository:

 http://wiki.xenproject.org/wiki/Xen_Project_Repositories
 
> @@ -7653,7 +7653,7 @@ int main_cpupoolcpuadd(int argc, char **argv)
>  
>  out:
>      libxl_bitmap_dispose(&cpumap);
> -    return rc;
> +    return rc ? EXIT_FAILURE : EXIT_SUCCESS;
>
Same as already said for main_cpupoolcreate, just us rc.

> @@ -7691,7 +7691,7 @@ int main_cpupoolcpuremove(int argc, char
> **argv)
>  
>  out:
>      libxl_bitmap_dispose(&cpumap);
> -    return rc;
> +    return rc ? EXIT_FAILURE : EXIT_SUCCESS;
>
And here.

>  int main_cpupoolnumasplit(int argc, char **argv)
> @@ -7758,7 +7758,7 @@ int main_cpupoolnumasplit(int argc, char
> **argv)
>      poolinfo = libxl_list_cpupool(ctx, &n_pools);
>      if (!poolinfo) {
>          fprintf(stderr, "error getting cpupool info\n");
> -        return 1;
> +        return EXIT_FAILURE;
>      }
>      poolid = poolinfo[0].poolid;
>      sched = poolinfo[0].sched;
> @@ -7766,13 +7766,13 @@ int main_cpupoolnumasplit(int argc, char
> **argv)
>  
>      if (n_pools > 1) {
>          fprintf(stderr, "splitting not possible, already cpupools in
> use\n");
> -        return 1;
> +        return EXIT_FAILURE;
>      }
>  
>      topology = libxl_get_cpu_topology(ctx, &n_cpus);
>      if (topology == NULL) {
>          fprintf(stderr, "libxl_get_topologyinfo failed\n");
> -        return 1;
> +        return EXIT_FAILURE;
>      }
>  
>      if (libxl_cpu_bitmap_alloc(ctx, &cpumap, 0)) {
> @@ -7869,7 +7869,7 @@ out:
>      libxl_dominfo_dispose(&info);
>      free(name);
>  
> -    return rc;
> +    return rc ? EXIT_FAILURE : EXIT_SUCCESS;
>  }
> 
And here too.

Thanks and regards,
Dario
-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)


[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/3] xl: convert cpupool related return codes to EXIT_[SUCCESS|FAILURE]
  2015-10-23 12:10   ` Dario Faggioli
@ 2015-10-23 12:33     ` Harmandeep Kaur
  0 siblings, 0 replies; 11+ messages in thread
From: Harmandeep Kaur @ 2015-10-23 12:33 UTC (permalink / raw)
  To: Dario Faggioli
  Cc: stefano.stebellini, wei.liu2, Ian Campbell, ian.jackson,
	George Dunlap, xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 3478 bytes --]

On Fri, Oct 23, 2015 at 5:40 PM, Dario Faggioli <dario.faggioli@citrix.com>
wrote:

> >  int main_cpupooldestroy(int argc, char **argv)
> > @@ -7580,13 +7580,13 @@ int main_cpupooldestroy(int argc, char
> > **argv)
> >      if (libxl_cpupool_qualifier_to_cpupoolid(ctx, pool, &poolid,
> > NULL) ||
> >          !libxl_cpupoolid_is_valid(ctx, poolid)) {
> >          fprintf(stderr, "unknown cpupool '%s'\n", pool);
> > -        return 1;
> > +        return EXIT_FAILURE;
> >      }
> >
> >      if (libxl_cpupool_destroy(ctx, poolid))
> > -        return 1;
> > +        return EXIT_FAILURE;
> >
> > -    return 0;
> > +    return EXIT_SUCCESS;
> >  }
> >
> For this one: I've sent a patch for another reason yesterday, and while
> there I did the exit code adjustment myself. So, update your tree and,
> if my patch has been committed already, just skip this function.
>
>  https://www.mail-archive.com/xen-devel@lists.xen.org/msg42850.html
>
> Which brings up a question: what git tree are you using for
> development? You should stay either on master or staging branches (and
> I recommend staging) of the official repository:
>
>  http://wiki.xenproject.org/wiki/Xen_Project_Repositories


I was on master branch, now switching to staging.

Thank you so much for reviewing my patch and helping on this tight
timeline. And regarding your other questions (patch 1 and 2) I will be
answering as I digest all the information you just passed :)

Again, thank you Dario. I really appreciate your help.

Warmest Regards :)
Harman


> > @@ -7653,7 +7653,7 @@ int main_cpupoolcpuadd(int argc, char **argv)
> >
> >  out:
> >      libxl_bitmap_dispose(&cpumap);
> > -    return rc;
> > +    return rc ? EXIT_FAILURE : EXIT_SUCCESS;
> >
> Same as already said for main_cpupoolcreate, just us rc.
>
> > @@ -7691,7 +7691,7 @@ int main_cpupoolcpuremove(int argc, char
> > **argv)
> >
> >  out:
> >      libxl_bitmap_dispose(&cpumap);
> > -    return rc;
> > +    return rc ? EXIT_FAILURE : EXIT_SUCCESS;
> >
> And here.
>
> >  int main_cpupoolnumasplit(int argc, char **argv)
> > @@ -7758,7 +7758,7 @@ int main_cpupoolnumasplit(int argc, char
> > **argv)
> >      poolinfo = libxl_list_cpupool(ctx, &n_pools);
> >      if (!poolinfo) {
> >          fprintf(stderr, "error getting cpupool info\n");
> > -        return 1;
> > +        return EXIT_FAILURE;
> >      }
> >      poolid = poolinfo[0].poolid;
> >      sched = poolinfo[0].sched;
> > @@ -7766,13 +7766,13 @@ int main_cpupoolnumasplit(int argc, char
> > **argv)
> >
> >      if (n_pools > 1) {
> >          fprintf(stderr, "splitting not possible, already cpupools in
> > use\n");
> > -        return 1;
> > +        return EXIT_FAILURE;
> >      }
> >
> >      topology = libxl_get_cpu_topology(ctx, &n_cpus);
> >      if (topology == NULL) {
> >          fprintf(stderr, "libxl_get_topologyinfo failed\n");
> > -        return 1;
> > +        return EXIT_FAILURE;
> >      }
> >
> >      if (libxl_cpu_bitmap_alloc(ctx, &cpumap, 0)) {
> > @@ -7869,7 +7869,7 @@ out:
> >      libxl_dominfo_dispose(&info);
> >      free(name);
> >
> > -    return rc;
> > +    return rc ? EXIT_FAILURE : EXIT_SUCCESS;
> >  }
> >
> And here too.
>
> Thanks and regards,
> Dario
> --
> <<This happens because I choose it to happen!>> (Raistlin Majere)
> -----------------------------------------------------------------
> Dario Faggioli, Ph.D, http://about.me/dario.faggioli
> Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
>
>

[-- Attachment #1.2: Type: text/html, Size: 5227 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-10-23 12:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-23  7:48 [PATCH 1/3] xl: convert scheduling related return codes to EXIT_[SUCCESS|FAILURE] Harmandeep Kaur
2015-10-23  7:48 ` [PATCH 2/3] xl: convert vcpu " Harmandeep Kaur
2015-10-23 10:41   ` Dario Faggioli
2015-10-23  7:48 ` [PATCH 3/3] xl: convert cpupool " Harmandeep Kaur
2015-10-23 12:10   ` Dario Faggioli
2015-10-23 12:33     ` Harmandeep Kaur
2015-10-23  8:30 ` [PATCH 1/3] xl: convert scheduling " Dario Faggioli
2015-10-23  9:56   ` Ian Campbell
2015-10-23 10:03     ` Dario Faggioli
2015-10-23 10:16       ` Ian Campbell
2015-10-23 10:16 ` Dario Faggioli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.