From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Guthro Subject: [PATCH] Propagate kernel errors in libxc Date: Mon, 12 Nov 2007 11:18:12 -0500 Message-ID: <47387CC4.7020906@virtualiron.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020108020108070109070508" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel Cc: Josh Nicholas List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------020108020108070109070508 Content-Type: multipart/alternative; boundary="------------050507000400030301090704" --------------050507000400030301090704 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 Signed-off-by: Ben Guthro --------------050507000400030301090704 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
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@virtualiron.com>
Signed-off-by: Ben Guthro <bguthro@virtualiron.com>
--------------050507000400030301090704-- --------------020108020108070109070508 Content-Type: text/x-patch; name="xen-propagate-kern-errs.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="xen-propagate-kern-errs.patch" 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) --------------020108020108070109070508 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------020108020108070109070508--