WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] Propagate kernel errors in libxc

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] Propagate kernel errors in libxc
From: Ben Guthro <bguthro@xxxxxxxxxxxxxxx>
Date: Mon, 12 Nov 2007 11:18:12 -0500
Cc: Josh Nicholas <jnicholas@xxxxxxxxxxxxxxx>
Delivery-date: Mon, 12 Nov 2007 08:18:47 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.5 (X11/20070719)
When the hypervisor returns and error through the kernel
or when simply when the kernel returns an error, the ioctl()
call in userspace returns -1 with the error value in errno.

This lib_xc was dropping this useful errno value by only
returning the -1.  This change continues to propagate the
-errno value up the call chain.

The impetus for this change was xc_domain_getinfo() previously
it was not possible to distinguish the difference between an
error and the domainID (or greater) not existing in the hypervisor.
Now callers can compare the return value against -ESRCH to distinguish
the difference between errors and the domain not existing.

Signed-off-by: Josh Nicholas <jnicholas@xxxxxxxxxxxxxxx>
Signed-off-by: Ben Guthro <bguthro@xxxxxxxxxxxxxxx>
diff -r fcd625c4f896 tools/libxc/xc_linux.c
--- a/tools/libxc/xc_linux.c    Mon Nov 05 10:39:07 2007 -0500
+++ b/tools/libxc/xc_linux.c    Mon Nov 05 10:39:07 2007 -0500
@@ -153,7 +153,12 @@ int xc_map_foreign_ranges(int xc_handle,
 
 static int do_privcmd(int xc_handle, unsigned int cmd, unsigned long data)
 {
-    return ioctl(xc_handle, cmd, data);
+    int ret = ioctl(xc_handle, cmd, data);
+       if (ret >= 0)
+               return ret;
+       if (errno) // kernel errors are passed through errno with ioctl() ret 
== -1
+               return (errno > 0) ? -errno : errno;
+       return ret;
 }
 
 int do_xen_hypercall(int xc_handle, privcmd_hypercall_t *hypercall)
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] Propagate kernel errors in libxc, Ben Guthro <=