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

[Xen-devel] [PATCH for-4.6] 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.

Explicitly set rc to ERROR_FAIL in all error paths to fix this.

Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Cc: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>
---
 tools/libxl/libxl_dom.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index e1f11a3..17ae4bd 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -966,12 +966,19 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
         ret = libxl__vnuma_build_vmemrange_hvm(gc, domid, info, state, &args);
         if (ret) {
             LOGEV(ERROR, ret, "hvm build vmemranges failed");
+            rc = ERROR_FAIL;
             goto out;
         }
         ret = libxl__vnuma_config_check(gc, info, state);
-        if (ret) goto out;
+        if (ret) {
+            rc = ERROR_FAIL;
+            goto out;
+        }
         ret = set_vnuma_info(gc, domid, info, state);
-        if (ret) goto out;
+        if (ret) {
+            rc = ERROR_FAIL;
+            goto out;
+        }
 
         args.nr_vmemranges = state->num_vmemranges;
         args.vmemranges = libxl__malloc(gc, sizeof(*args.vmemranges) *
@@ -994,6 +1001,7 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
     ret = xc_hvm_build(ctx->xch, domid, &args);
     if (ret) {
         LOGEV(ERROR, ret, "hvm building failed");
+        rc = ERROR_FAIL;
         goto out;
     }
 
@@ -1008,12 +1016,14 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
                                state->console_domid);
     if (ret) {
         LOGEV(ERROR, ret, "hvm build set params failed");
+        rc = ERROR_FAIL;
         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 = ERROR_FAIL;
         goto out;
     }
 
-- 
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®.