All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Guthro <bguthro@virtualiron.com>
To: xen-devel <xen-devel@lists.xensource.com>
Cc: Josh Nicholas <jnicholas@virtualiron.com>
Subject: [PATCH] Propagate kernel errors in libxc
Date: Mon, 12 Nov 2007 11:18:12 -0500	[thread overview]
Message-ID: <47387CC4.7020906@virtualiron.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 760 bytes --]

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>


[-- Attachment #1.2: Type: text/html, Size: 1105 bytes --]

[-- Attachment #2: xen-propagate-kern-errs.patch --]
[-- Type: text/x-patch, Size: 629 bytes --]

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)

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

                 reply	other threads:[~2007-11-12 16:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=47387CC4.7020906@virtualiron.com \
    --to=bguthro@virtualiron.com \
    --cc=jnicholas@virtualiron.com \
    --cc=xen-devel@lists.xensource.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 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.