xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: olaf@aepfle.de, Ian.Campbell@citrix.com, wency@cn.fujitsu.com,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	yunhong.jiang@intel.com, eddie.dong@intel.com,
	yanghy@cn.fujitsu.com, laijs@cn.fujitsu.com
Subject: [PATCH 2/3] libxl: save helper: transport errno with all callback return values
Date: Mon, 22 Sep 2014 14:58:18 +0100	[thread overview]
Message-ID: <1411394299-8584-2-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <21536.10963.947982.42738@mariner.uk.xensource.com>

Whenever we plumb the return value from a callback, plumb through
errno as well.

libxl__xc_domain_saverestore_async_callback_done now assumes that its
caller has set errno sensibly, although this is probably not true :-/.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 tools/libxl/libxl_save_callout.c   |   11 +++++++----
 tools/libxl/libxl_save_msgs_gen.pl |   10 +++++++---
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/tools/libxl/libxl_save_callout.c b/tools/libxl/libxl_save_callout.c
index 1c9f806..88b406b 100644
--- a/tools/libxl/libxl_save_callout.c
+++ b/tools/libxl/libxl_save_callout.c
@@ -138,10 +138,11 @@ void libxl__xc_domain_save(libxl__egc *egc, libxl__domain_suspend_state *dss)
 
 
 void libxl__xc_domain_saverestore_async_callback_done(libxl__egc *egc,
-                           libxl__save_helper_state *shs, int return_value)
+                           libxl__save_helper_state *shs,
+                           int return_value)
 {
     shs->egc = egc;
-    libxl__srm_callout_sendreply(return_value, shs);
+    libxl__srm_callout_sendreply(return_value, errno, shs);
     shs->egc = 0;
 }
 
@@ -356,15 +357,16 @@ libxl__srm_callout_get_callbacks_restore(void *user)
     return &shs->callbacks.restore.a;
 }
 
-void libxl__srm_callout_sendreply(int r, void *user)
+void libxl__srm_callout_sendreply(int r, int savederrno, void *user)
 {
     libxl__save_helper_state *shs = user;
     libxl__egc *egc = shs->egc;
     STATE_AO_GC(shs->ao);
     int errnoval;
+    int data[2] = { r, savederrno };
 
     errnoval = libxl_write_exactly(CTX, libxl__carefd_fd(shs->pipes[0]),
-                                   &r, sizeof(r), shs->stdin_what,
+                                   data, sizeof(data), shs->stdin_what,
                                    "callback return value");
     if (errnoval)
         helper_failed(egc, shs, ERROR_FAIL);
@@ -397,5 +399,6 @@ int libxl__srm_callout_callback_complete(int retval, int errnoval,
     shs->retval = retval;
     shs->errnoval = errnoval;
     libxl__ev_fd_deregister(gc, &shs->readable);
+    errno = 0;
     return 0;
 }
diff --git a/tools/libxl/libxl_save_msgs_gen.pl b/tools/libxl/libxl_save_msgs_gen.pl
index ddd13e5..3d89de9 100755
--- a/tools/libxl/libxl_save_msgs_gen.pl
+++ b/tools/libxl/libxl_save_msgs_gen.pl
@@ -66,6 +66,7 @@ foreach my $ah (qw(callout helper)) {
 #include <string.h>
 #include <stdint.h>
 #include <limits.h>
+#include <errno.h>
 END_BOTH
 
 #include "libxl_internal.h"
@@ -103,7 +104,7 @@ our $getcallbacks = "${libxl}_callout_get_callbacks";
 our $enumcallbacks = "${libxl}_callout_enumcallbacks";
 sub cbtype ($) { "${libxl}_".$_[0]."_autogen_callbacks"; };
 
-f_decl($sendreply, 'callout', 'void', "(int r, void *user)");
+f_decl($sendreply, 'callout', 'void', "(int r, int savederrno, void *user)");
 
 our $helper = "helper";
 our $encode = "${helper}_stub";
@@ -328,7 +329,7 @@ END_ALWAYS
 	$f_more_sr->("        $c_make_callback;\n");
     } else {
         $f_more_sr->("        r = $c_make_callback;\n".
-                     "        $sendreply(r, user);\n");
+                     "        $sendreply(r, errno, user);\n");
     }
     if ($flags =~ m/x/) {
         my $c_v = "(1u<<$msgnum)";
@@ -354,9 +355,12 @@ END_ALWAYS
 	f_more("${encode}_$name",
                (<<END_ALWAYS.($debug ? <<END_DEBUG : '').<<END_ALWAYS));
     int r = ${helper}_getreply(user);
+    int savederrno = ${helper}_getreply(user);
 END_ALWAYS
-    fprintf(stderr,"libxl-save-helper: $name got reply %d\\n",r);
+    fprintf(stderr,"libxl-save-helper: $name got reply %d (errno: %s)\\n",
+            r,strerror(savederrno));
 END_DEBUG
+    errno = savederrno;
     return r;
 END_ALWAYS
     }
-- 
1.7.10.4

  parent reply	other threads:[~2014-09-22 13:58 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-22  5:59 [RFC Patch v4 0/9] Some bugfix patches Wen Congyang
2014-09-22  5:59 ` [RFC Patch v4 1/9] copy the correct page to memory Wen Congyang
2014-09-22 14:38   ` Ian Campbell
2014-09-22  5:59 ` [RFC Patch v4 2/9] csum the correct page Wen Congyang
2014-09-22  5:59 ` [RFC Patch v4 3/9] pass correct file to qemu if we use blktap2 Wen Congyang
2014-12-11 16:45   ` George Dunlap
2014-12-13 17:06     ` Wei Liu
2014-12-15 10:18       ` Ian Campbell
2014-12-15 11:10         ` George Dunlap
2014-09-22  5:59 ` [RFC Patch v4 4/9] read nictype from xenstore Wen Congyang
2014-09-22  5:59 ` [RFC Patch v4 5/9] check if mfn is supported by IOCTL_PRIVCMD_MMAPBATCH before calling ioctl() Wen Congyang
2014-09-22 14:26   ` Ian Campbell
2014-09-23  1:40     ` Wen Congyang
2014-09-23 10:08       ` Ian Campbell
2014-09-24  1:36         ` Wen Congyang
2014-09-22  5:59 ` [RFC Patch v4 6/9] don't zero out ioreq page and handle the pended I/O after resuming Wen Congyang
2014-09-22 11:22   ` Jan Beulich
2014-09-22  5:59 ` [RFC Patch v4 7/9] correct xc_domain_save()'s return value Wen Congyang
2014-09-22  7:30   ` Olaf Hering
2014-09-22  7:34     ` Wen Congyang
2014-09-22  7:46       ` Olaf Hering
2014-09-22  8:06         ` Wen Congyang
2014-09-22  8:13           ` Olaf Hering
2014-09-22  8:24             ` Wen Congyang
2014-09-22  8:41             ` Wen Congyang
2014-09-22 12:42           ` Ian Campbell
2014-09-22 13:03             ` Ian Jackson
2014-09-22 13:13               ` Ian Campbell
2014-09-22 13:57                 ` [PATCH RFC 0/3] " Ian Jackson
2014-09-22 13:58                   ` Ian Campbell
2014-09-22 14:00                     ` Ian Campbell
2014-09-22 13:58                   ` [PATCH 1/3] libxl: save helper: remove redundant declaration Ian Jackson
2014-09-22 13:58                   ` Ian Jackson [this message]
2014-09-22 13:58                   ` [PATCH 3/3] libxl: save/restore callbacks: enforce a useful errno value Ian Jackson
2014-09-22 14:07                     ` Ian Campbell
2014-09-22 14:08                       ` Ian Jackson
2014-09-22 14:06                 ` [RFC Patch v4 7/9] correct xc_domain_save()'s return value Andrew Cooper
2014-09-23  2:14                   ` Wen Congyang
2014-09-23  9:00                     ` Andrew Cooper
2014-09-23  9:10                       ` Wen Congyang
2014-09-23  9:25                         ` Andrew Cooper
2014-09-23  9:29                           ` Wen Congyang
2014-09-23 10:09                             ` Ian Campbell
2014-09-23  9:52                           ` Wen Congyang
2014-09-22  5:59 ` [RFC Patch v4 8/9] store correct format into tapdisk-params/params Wen Congyang
2014-09-22 14:37   ` Ian Campbell
2014-09-23  2:07     ` Wen Congyang
2014-09-23 10:11       ` Ian Campbell
2014-09-23 10:32         ` Wen Congyang
2014-09-22  5:59 ` [RFC Patch v4 9/9] update libxl__device_disk_from_xs_be() to support blktap device Wen Congyang
2014-09-22 15:08   ` Ian Campbell
2014-09-23  3:07     ` Wen Congyang
2014-09-23 10:12       ` Ian Campbell
2014-09-22 12:44 ` [RFC Patch v4 0/9] Some bugfix patches Ian Campbell
2014-09-22 12:56   ` Wen Congyang

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=1411394299-8584-2-git-send-email-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=eddie.dong@intel.com \
    --cc=laijs@cn.fujitsu.com \
    --cc=olaf@aepfle.de \
    --cc=wency@cn.fujitsu.com \
    --cc=xen-devel@lists.xensource.com \
    --cc=yanghy@cn.fujitsu.com \
    --cc=yunhong.jiang@intel.com \
    /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).