From: Anthony PERARD <anthony.perard@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Anthony PERARD <anthony.perard@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Wei Liu <wei.liu2@citrix.com>
Subject: [PATCH v6 06/11] libxl_exec: Add libxl__spawn_initiate_failure
Date: Mon, 12 Nov 2018 16:49:25 +0000 [thread overview]
Message-ID: <20181112164930.25893-7-anthony.perard@citrix.com> (raw)
In-Reply-To: <20181112164930.25893-1-anthony.perard@citrix.com>
This function can be used by user of libxl__spawn_* when they setup a
notification other than xenstore. The parent can already report success
via libxl__spawn_initiate_detach(), this new function can be used for
failure instead of waiting for the timeout.
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
Notes:
v6:
long line fix
typos fixed
fix leak of internal state into external doc
if the function is call multiple times, set rc only the first time.
v5:
fix typos
tools/libxl/libxl_exec.c | 11 +++++++++++
tools/libxl/libxl_internal.h | 23 ++++++++++++++++++++++-
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/tools/libxl/libxl_exec.c b/tools/libxl/libxl_exec.c
index 02e6c917f0..bf87bc563c 100644
--- a/tools/libxl/libxl_exec.c
+++ b/tools/libxl/libxl_exec.c
@@ -373,6 +373,17 @@ void libxl__spawn_initiate_detach(libxl__gc *gc, libxl__spawn_state *ss)
spawn_detach(gc, ss);
}
+void libxl__spawn_initiate_failure(libxl__gc *gc, libxl__spawn_state *ss,
+ int rc)
+/* The spawn state must be Attached on entry and will be Attached Failed
+ * on return. */
+{
+ assert(rc);
+ if (!ss->rc)
+ ss->rc = rc;
+ spawn_detach(gc, ss);
+}
+
static void spawn_fail(libxl__egc *egc, libxl__spawn_state *ss, int rc)
/* Caller must have logged. Must be last thing in calling function,
* as it may make the callback. Precondition: Attached or Detaching. */
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index e02597a0cd..6c118ccb3b 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1552,7 +1552,8 @@ _hidden void libxl__spawn_init(libxl__spawn_state*);
*
* The inner child must soon exit or exec. It must also soon exit or
* notify the parent of its successful startup by writing to the
- * xenstore path xspath.
+ * xenstore path xspath OR via other means that the parent will have
+ * to set up.
*
* The user (in the parent) will be called back (confirm_cb) every
* time that xenstore path is modified.
@@ -1608,6 +1609,26 @@ _hidden int libxl__spawn_spawn(libxl__egc *egc, libxl__spawn_state *spawn);
*/
_hidden void libxl__spawn_initiate_detach(libxl__gc *gc, libxl__spawn_state*);
+/*
+ * libxl__spawn_initiate_failure - Propagate failure from the caller to the
+ * callee.
+ *
+ * Works by killing the intermediate process from spawn_spawn.
+ * After this function returns, a failure will be reported.
+ *
+ * This is not synchronous: there will be a further callback when
+ * the detach is complete.
+ *
+ * Logs errors.
+ *
+ * The spawn state must be Attached on entry and will remain Attached. It
+ * is possible for a spawn to fail for multiple reasons, for example
+ * call(s) to libxl__spawn_initiate_failure and also for some other reason.
+ * In that case the first rc value from any source will take precedence.
+ */
+_hidden void libxl__spawn_initiate_failure(libxl__gc *gc,
+ libxl__spawn_state *ss, int rc);
+
/*
* If successful, this should return 0.
*
--
Anthony PERARD
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-11-12 16:49 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-12 16:49 [PATCH v6 00/11] libxl: Enable save/restore/migration of a restricted QEMU + libxl__ev_qmp_* Anthony PERARD
2018-11-12 16:49 ` [PATCH v6 01/11] libxl: Enhance libxl__sendmsg_fds to deal with EINTR and EWOULDBLOCK Anthony PERARD
2018-11-12 16:58 ` Ian Jackson
2018-11-12 16:49 ` [PATCH v6 02/11] libxl_qmp: Separate QMP message generation from qmp_send_prepare Anthony PERARD
2018-11-12 17:20 ` Ian Jackson
2018-11-13 10:59 ` Anthony PERARD
2018-11-13 12:04 ` Ian Jackson
2018-11-12 16:49 ` [PATCH v6 03/11] libxl_qmp: Change qmp_qemu_check_version to compare version Anthony PERARD
2018-11-12 17:22 ` Ian Jackson
2018-11-22 12:24 ` Anthony PERARD
2018-11-22 12:27 ` Anthony PERARD
2018-11-12 16:49 ` [PATCH v6 04/11] libxl: Design of an async API to issue QMP commands to QEMU Anthony PERARD
2018-11-12 17:29 ` Ian Jackson
2018-11-12 16:49 ` [PATCH v6 05/11] libxl_qmp: Implementation of libxl__ev_qmp_* Anthony PERARD
2018-11-13 11:33 ` Ian Jackson
2018-11-22 19:04 ` Marek Marczykowski-Górecki
2018-11-23 11:09 ` Anthony PERARD
2018-11-12 16:49 ` Anthony PERARD [this message]
2018-11-12 17:34 ` [PATCH v6 06/11] libxl_exec: Add libxl__spawn_initiate_failure Ian Jackson
2018-11-12 16:49 ` [PATCH v6 07/11] libxl_dm: Pre-open QMP socket for QEMU Anthony PERARD
2018-11-16 11:52 ` Ian Jackson
2018-11-21 17:14 ` Anthony PERARD
2018-11-12 16:49 ` [PATCH v6 08/11] libxl: QEMU startup sync based on QMP Anthony PERARD
2018-11-16 12:14 ` Ian Jackson
2018-11-21 16:49 ` Anthony PERARD
2018-11-22 14:37 ` Anthony PERARD
2018-11-22 15:48 ` Ian Jackson
2018-11-12 16:49 ` [PATCH v6 09/11] libxl_qmp: Store advertised QEMU version in libxl__ev_qmp Anthony PERARD
2018-11-16 12:17 ` Ian Jackson
2018-11-12 16:49 ` [PATCH v6 10/11] libxl: Change libxl__domain_suspend_device_model() to be async Anthony PERARD
2018-11-12 16:49 ` [PATCH v6 11/11] libxl: Re-implement domain_suspend_device_model using libxl__ev_qmp Anthony PERARD
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=20181112164930.25893-7-anthony.perard@citrix.com \
--to=anthony.perard@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.