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

Re: [Xen-devel] [Patch v2 2/3] correct xc_domain_save()'s return value



Wen Congyang writes ("[Patch v2 2/3] correct xc_domain_save()'s return value"):
> If suspend_and_state() fails, the errno may be 0. But we assume
> that the errno is not 0. So remove assert().

Thanks for spotting this.

I think this is going in the wrong direction.  Perhaps we could
instead do something like the patch below ?  Please let me know what
you think.

If you think this is a better idea, please submit it as a proper patch
with a proper commit message.

(Ideally we would fix the actual suspend hook in libxl, to always set
errno, but that's too invasive a set of changes to do now, I think.)

Thanks,
Ian.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h
index 40bbac8..3ab9dd8 100644
--- a/tools/libxc/include/xenguest.h
+++ b/tools/libxc/include/xenguest.h
@@ -35,7 +35,9 @@
 /* callbacks provided by xc_domain_save */
 struct save_callbacks {
     /* Called after expiration of checkpoint interval,
-     * to suspend the guest.
+     * to suspend the guest.  Returns 1 for success, or 0 for failure.
+     * On failure it should ideally set errno.  (If it leaves errno
+     * as 0, EIO will be used instead.)
      */
     int (*suspend)(void* data);
 
diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c
index 254fdb3..444aac6 100644
--- a/tools/libxc/xc_domain_save.c
+++ b/tools/libxc/xc_domain_save.c
@@ -361,9 +361,15 @@ static int suspend_and_state(int (*suspend)(void*), void* 
data,
                              xc_interface *xch, int io_fd, int dom,
                              xc_dominfo_t *info)
 {
+    errno = 0;
     if ( !(*suspend)(data) )
     {
-        ERROR("Suspend request failed");
+        if (!errno) {
+            errno = EIO;
+            ERROR("Suspend request failed (without errno, using EINVAL)");
+        } else {
+            ERROR("Suspend request failed");
+        }
         return -1;
     }
 

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


 


Rackspace

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