xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-4.6] libxl: fix libxl__build_hvm error code return path
@ 2015-08-11 13:48 Wei Liu
  2015-08-11 13:55 ` Ian Campbell
  2015-08-12 15:49 ` Ian Jackson
  0 siblings, 2 replies; 8+ messages in thread
From: Wei Liu @ 2015-08-11 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: Ian Jackson, Roger Pau Monne, Wei Liu, Ian Campbell,
	Stefano Stabellini

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@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Roger Pau Monne <roger.pau@citrix.com>
---
 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

^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [PATCH for-4.6] libxl: fix libxl__build_hvm error code return path
@ 2015-08-07 16:08 Roger Pau Monne
  2015-08-11  8:57 ` Wei Liu
  0 siblings, 1 reply; 8+ messages in thread
From: Roger Pau Monne @ 2015-08-07 16:08 UTC (permalink / raw)
  To: xen-devel
  Cc: Wei Liu, Stefano Stabellini, Ian Jackson, Ian Campbell,
	Roger Pau Monne

This is a simple fix to make sure libxl__build_hvm returns an error code in
case of failure.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
---
I would rather prefer to have it fixed in a proper way like it's done in my
"libxl: fix libxl__build_hvm error handling" as part of the HVMlite series,
but I understand that given the current status of the tree and the
willingness to backport this to stable branches the other approach is going
to be much harder.
---
 tools/libxl/libxl_dom.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index e1f11a3..668ce11 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -1019,6 +1019,7 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
 
     return 0;
 out:
+    rc = ERROR_FAIL;
     return rc;
 }
 
-- 
1.9.5 (Apple Git-50.3)


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

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

end of thread, other threads:[~2015-08-12 15:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-11 13:48 [PATCH for-4.6] libxl: fix libxl__build_hvm error code return path Wei Liu
2015-08-11 13:55 ` Ian Campbell
2015-08-11 13:58   ` Wei Liu
2015-08-12 15:49 ` Ian Jackson
  -- strict thread matches above, loose matches on Subject: below --
2015-08-07 16:08 Roger Pau Monne
2015-08-11  8:57 ` Wei Liu
2015-08-11 12:44   ` Ian Campbell
2015-08-11 12:48     ` Wei Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).