[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH for-4.6 v3] libxl: fix libxl__build_hvm error code return path



In 25652f23 ("tools/libxl: detect and avoid conflicts with RDM"), new
code was added to use rc to store libxl function call return value,
which complied to libxl coding style. That patch, however, didn't change
other locations where return value was stored in ret. In the end
libxl__build_hvm could return 0 when it failed.

Change all assignments to ret to assignment to rc and abolish ret.

Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
v3: store return value for libxl__domain_firmware in rc, too.
---
 tools/libxl/libxl_dom.c | 47 +++++++++++++++++++++++++----------------------
 1 file changed, 25 insertions(+), 22 deletions(-)

diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index e1f11a3..1e5bb0b 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -912,7 +912,7 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     struct xc_hvm_build_args args = {};
-    int ret, rc = ERROR_FAIL;
+    int rc;
     uint64_t mmio_start, lowmem_end, highmem_end;
     libxl_domain_build_info *const info = &d_config->b_info;
 
@@ -932,10 +932,13 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
         if (max_ram_below_4g < HVM_BELOW_4G_MMIO_START)
             args.mmio_size = info->u.hvm.mmio_hole_memkb << 10;
     }
-    if (libxl__domain_firmware(gc, info, &args)) {
+
+    rc = libxl__domain_firmware(gc, info, &args);
+    if (rc) {
         LOG(ERROR, "initializing domain firmware failed");
         goto out;
     }
+
     if (args.mem_target == 0)
         args.mem_target = args.mem_size;
     if (args.mmio_size == 0)
@@ -963,15 +966,15 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
     if (info->num_vnuma_nodes != 0) {
         int i;
 
-        ret = libxl__vnuma_build_vmemrange_hvm(gc, domid, info, state, &args);
-        if (ret) {
-            LOGEV(ERROR, ret, "hvm build vmemranges failed");
+        rc = libxl__vnuma_build_vmemrange_hvm(gc, domid, info, state, &args);
+        if (rc) {
+            LOGEV(ERROR, rc, "hvm build vmemranges failed");
             goto out;
         }
-        ret = libxl__vnuma_config_check(gc, info, state);
-        if (ret) goto out;
-        ret = set_vnuma_info(gc, domid, info, state);
-        if (ret) goto out;
+        rc = libxl__vnuma_config_check(gc, info, state);
+        if (rc) goto out;
+        rc = set_vnuma_info(gc, domid, info, state);
+        if (rc) goto out;
 
         args.nr_vmemranges = state->num_vmemranges;
         args.vmemranges = libxl__malloc(gc, sizeof(*args.vmemranges) *
@@ -991,9 +994,9 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
             args.vnode_to_pnode[i] = info->vnuma_nodes[i].pnode;
     }
 
-    ret = xc_hvm_build(ctx->xch, domid, &args);
-    if (ret) {
-        LOGEV(ERROR, ret, "hvm building failed");
+    rc = xc_hvm_build(ctx->xch, domid, &args);
+    if (rc) {
+        LOGEV(ERROR, rc, "hvm building failed");
         goto out;
     }
 
@@ -1002,22 +1005,22 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
         goto out;
     }
 
-    ret = hvm_build_set_params(ctx->xch, domid, info, state->store_port,
-                               &state->store_mfn, state->console_port,
-                               &state->console_mfn, state->store_domid,
-                               state->console_domid);
-    if (ret) {
-        LOGEV(ERROR, ret, "hvm build set params failed");
+    rc = hvm_build_set_params(ctx->xch, domid, info, state->store_port,
+                              &state->store_mfn, state->console_port,
+                              &state->console_mfn, state->store_domid,
+                              state->console_domid);
+    if (rc) {
+        LOGEV(ERROR, rc, "hvm build set params failed");
         goto out;
     }
 
-    ret = hvm_build_set_xs_values(gc, domid, &args);
-    if (ret) {
-        LOG(ERROR, "hvm build set xenstore values failed (ret=%d)", ret);
+    rc = hvm_build_set_xs_values(gc, domid, &args);
+    if (rc) {
+        LOG(ERROR, "hvm build set xenstore values failed (rc=%d)", rc);
         goto out;
     }
 
-    return 0;
+    rc = 0;
 out:
     return rc;
 }
-- 
2.1.4


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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.