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

[Xen-changelog] [xen master] libxl: use libxl__xs_read_checked() instead or raw xs_read() in do_domain_soft_reset()



commit fd9ca53f6669a7bef6ed4b22b3bcfe634a5abf74
Author:     Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>
AuthorDate: Wed Mar 22 14:59:45 2017 +0100
Commit:     Wei Liu <wei.liu2@xxxxxxxxxx>
CommitDate: Thu Mar 23 12:01:47 2017 +0000

    libxl: use libxl__xs_read_checked() instead or raw xs_read() in 
do_domain_soft_reset()
    
    Replace raw xs_read() calls with libxl__xs_read_checked() and bail on error.
    
    Signed-off-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>
    Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 tools/libxl/libxl_create.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 46b80b2..b65c971 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1696,8 +1696,8 @@ static int do_domain_soft_reset(libxl_ctx *ctx,
     libxl__domain_create_state *dcs;
     libxl__domain_build_state *state;
     libxl__domain_save_state *dss;
-    char *dom_path, *xs_store_mfn, *xs_console_mfn;
-    const char *console_tty;
+    const char *console_tty, *xs_store_mfn, *xs_console_mfn;
+    char *dom_path;
     uint32_t domid_out;
     int rc;
 
@@ -1726,17 +1726,23 @@ static int do_domain_soft_reset(libxl_ctx *ctx,
         goto out;
     }
 
-    xs_store_mfn = xs_read(ctx->xsh, XBT_NULL,
-                           GCSPRINTF("%s/store/ring-ref", dom_path),
-                           NULL);
+    rc = libxl__xs_read_checked(gc, XBT_NULL,
+                                GCSPRINTF("%s/store/ring-ref", dom_path),
+                                &xs_store_mfn);
+    if (rc) {
+        LOGD(ERROR, domid_soft_reset, "failed to read store/ring-ref.");
+        goto out;
+    }
     state->store_mfn = xs_store_mfn ? atol(xs_store_mfn): 0;
-    free(xs_store_mfn);
 
-    xs_console_mfn = xs_read(ctx->xsh, XBT_NULL,
-                             GCSPRINTF("%s/console/ring-ref", dom_path),
-                             NULL);
+    rc = libxl__xs_read_checked(gc, XBT_NULL,
+                                GCSPRINTF("%s/console/ring-ref", dom_path),
+                                &xs_console_mfn);
+    if (rc) {
+        LOGD(ERROR, domid_soft_reset, "failed to read console/ring-ref.");
+        goto out;
+    }
     state->console_mfn = xs_console_mfn ? atol(xs_console_mfn): 0;
-    free(xs_console_mfn);
 
     rc = libxl__xs_read_mandatory(gc, XBT_NULL,
                                   GCSPRINTF("%s/console/tty", dom_path),
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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