From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: xen-devel@lists.xen.org
Cc: Wei Liu <wei.liu2@citrix.com>, Ian Jackson <ian.jackson@eu.citrix.com>
Subject: [PATCH v2 2/2] libxl: use libxl__xs_read_checked() instead or raw xs_read() in do_domain_soft_reset()
Date: Wed, 22 Mar 2017 14:59:45 +0100 [thread overview]
Message-ID: <20170322135945.24107-3-vkuznets@redhat.com> (raw)
In-Reply-To: <20170322135945.24107-1-vkuznets@redhat.com>
Replace raw xs_read() calls with libxl__xs_read_checked() and bail on error.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
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),
--
2.9.3
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-03-22 13:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-22 13:59 [PATCH v2 0/2] libxl: fix soft reset for PVHv2 guests Vitaly Kuznetsov
2017-03-22 13:59 ` [PATCH v2 1/2] libxl: preserve console tty across soft reset Vitaly Kuznetsov
2017-03-22 13:59 ` Vitaly Kuznetsov [this message]
2017-03-23 12:03 ` [PATCH v2 0/2] libxl: fix soft reset for PVHv2 guests Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170322135945.24107-3-vkuznets@redhat.com \
--to=vkuznets@redhat.com \
--cc=ian.jackson@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).