Source-Changes-HG archive

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

[src/trunk]: src Translate error codes between the hypervisor and rump kernel.



details:   https://anonhg.NetBSD.org/src/rev/44efea71fd49
branches:  trunk
changeset: 786516:44efea71fd49
user:      pooka <pooka%NetBSD.org@localhost>
date:      Tue Apr 30 12:39:20 2013 +0000

description:
Translate error codes between the hypervisor and rump kernel.

diffstat:

 lib/librumpuser/Makefile                   |    4 +-
 lib/librumpuser/rumpuser.c                 |   36 +-
 lib/librumpuser/rumpuser_component.c       |   11 +-
 lib/librumpuser/rumpuser_component.h       |    3 +-
 lib/librumpuser/rumpuser_daemonize.c       |   50 ++-
 lib/librumpuser/rumpuser_errtrans.c        |  321 +++++++++++++++++++++++++++++
 lib/librumpuser/rumpuser_int.h             |    9 +-
 lib/librumpuser/rumpuser_pth.c             |   14 +-
 lib/librumpuser/rumpuser_sp.c              |   28 +-
 sys/rump/dev/lib/libugenhc/rumpcomp_user.c |    4 +-
 sys/rump/include/rump/rumpdefs.h           |    8 +-
 sys/rump/net/lib/libshmif/rumpcomp_user.c  |   12 +-
 sys/rump/net/lib/libsockin/rumpcomp_user.c |   22 +-
 sys/rump/net/lib/libvirtif/rumpcomp_user.c |    6 +-
 14 files changed, 443 insertions(+), 85 deletions(-)

diffs (truncated from 1056 to 300 lines):

diff -r d8439b343f9f -r 44efea71fd49 lib/librumpuser/Makefile
--- a/lib/librumpuser/Makefile  Tue Apr 30 12:24:31 2013 +0000
+++ b/lib/librumpuser/Makefile  Tue Apr 30 12:39:20 2013 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.10 2013/04/29 12:56:04 pooka Exp $
+#      $NetBSD: Makefile,v 1.11 2013/04/30 12:39:20 pooka Exp $
 #
 
 WARNS?=                5
@@ -14,7 +14,7 @@
 SRCS=          rumpuser.c
 SRCS+=         rumpuser_pth.c
 SRCS+=         rumpuser_dl.c rumpuser_sp.c rumpuser_daemonize.c rumpuser_bio.c
-SRCS+=         rumpuser_component.c
+SRCS+=         rumpuser_component.c rumpuser_errtrans.c
 
 INCSDIR=       /usr/include/rump
 INCS=          rumpuser.h rumpuser_component.h
diff -r d8439b343f9f -r 44efea71fd49 lib/librumpuser/rumpuser.c
--- a/lib/librumpuser/rumpuser.c        Tue Apr 30 12:24:31 2013 +0000
+++ b/lib/librumpuser/rumpuser.c        Tue Apr 30 12:39:20 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpuser.c,v 1.46 2013/04/30 11:26:26 pooka Exp $      */
+/*     $NetBSD: rumpuser.c,v 1.47 2013/04/30 12:39:20 pooka Exp $      */
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.46 2013/04/30 11:26:26 pooka Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.47 2013/04/30 12:39:20 pooka Exp $");
 #endif /* !lint */
 
 #include <sys/ioctl.h>
@@ -206,7 +206,7 @@
        if (fd != -1)
                close(fd);
 
-       return rv;
+       ET(rv);
 }
 
 int
@@ -228,7 +228,7 @@
        }
 
        *memp = mem;
-       return rv;
+       ET(rv);
 }
 
 /*ARGSUSED1*/
@@ -265,16 +265,14 @@
                rv = 0;
        }
 
-       return rv;
+       ET(rv);
 }
 
 void
 rumpuser_unmap(void *addr, size_t len)
 {
-       int rv;
 
-       rv = munmap(addr, len);
-       assert(rv == 0);
+       munmap(addr, len);
 }
 
 int
@@ -311,7 +309,7 @@
        }
 
  out:
-       return rv;
+       ET(rv);
 }
 
 int
@@ -324,7 +322,7 @@
        close(fd);
        rumpkern_sched(nlocks, NULL);
 
-       return 0;
+       ET(0);
 }
 
 /*
@@ -361,7 +359,7 @@
                rv = 0;
        }
 
-       return rv;
+       ET(rv);
 }
 
 int
@@ -393,7 +391,7 @@
                rv = 0;
        }
 
-       return rv;
+       ET(rv);
 }
 
 int
@@ -418,8 +416,7 @@
                abort();
        }
 
-       rv = clock_gettime(clk, &ts);
-       if (rv == -1) {
+       if (clock_gettime(clk, &ts) == -1) {
                rv = errno;
        } else {
                *sec = ts.tv_sec;
@@ -427,7 +424,7 @@
                rv = 0;
        }
 
-       return rv;
+       ET(rv);
 }
 
 int
@@ -486,7 +483,8 @@
        }
 
        rumpkern_sched(nlocks, NULL);
-       return rv;
+
+       ET(rv);
 }
 
 static int
@@ -556,7 +554,7 @@
                        rv = 0;
        }
 
-       return rv;
+       ET(rv);
 }
 
 void
@@ -616,7 +614,7 @@
        rv = EOPNOTSUPP;
 #endif
 
-       return rv;
+       ET(rv);
 }
 
 int
@@ -636,5 +634,5 @@
        } while (chunk);
 
        *retp = origlen;
-       return 0;
+       ET(0);
 }
diff -r d8439b343f9f -r 44efea71fd49 lib/librumpuser/rumpuser_component.c
--- a/lib/librumpuser/rumpuser_component.c      Tue Apr 30 12:24:31 2013 +0000
+++ b/lib/librumpuser/rumpuser_component.c      Tue Apr 30 12:39:20 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpuser_component.c,v 1.4 2013/04/29 15:20:05 pooka Exp $     */
+/*     $NetBSD: rumpuser_component.c,v 1.5 2013/04/30 12:39:20 pooka Exp $     */
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_component.c,v 1.4 2013/04/29 15:20:05 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_component.c,v 1.5 2013/04/30 12:39:20 pooka Exp $");
 #endif /* !lint */
 
 /*
@@ -97,3 +97,10 @@
        rumpuser__hyp.hyp_lwproc_release();
        rumpuser__hyp.hyp_unschedule();
 }
+
+int
+rumpuser_component_errtrans(int hosterr)
+{
+
+       return rumpuser__errtrans(hosterr);
+}
diff -r d8439b343f9f -r 44efea71fd49 lib/librumpuser/rumpuser_component.h
--- a/lib/librumpuser/rumpuser_component.h      Tue Apr 30 12:24:31 2013 +0000
+++ b/lib/librumpuser/rumpuser_component.h      Tue Apr 30 12:39:20 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpuser_component.h,v 1.2 2013/04/29 15:20:05 pooka Exp $     */
+/*     $NetBSD: rumpuser_component.h,v 1.3 2013/04/30 12:39:20 pooka Exp $     */
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -30,6 +30,7 @@
 
 void * rumpuser_component_unschedule(void);
 void   rumpuser_component_schedule(void *);
+int    rumpuser_component_errtrans(int);
 
 void   rumpuser_component_kthread(void);
 struct lwp *rumpuser_component_curlwp(void);
diff -r d8439b343f9f -r 44efea71fd49 lib/librumpuser/rumpuser_daemonize.c
--- a/lib/librumpuser/rumpuser_daemonize.c      Tue Apr 30 12:24:31 2013 +0000
+++ b/lib/librumpuser/rumpuser_daemonize.c      Tue Apr 30 12:39:20 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpuser_daemonize.c,v 1.4 2012/11/18 19:29:40 pooka Exp $     */
+/*     $NetBSD: rumpuser_daemonize.c,v 1.5 2013/04/30 12:39:20 pooka Exp $     */
 
 /*
  * Copyright (c) 2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_daemonize.c,v 1.4 2012/11/18 19:29:40 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_daemonize.c,v 1.5 2013/04/30 12:39:20 pooka Exp $");
 #endif /* !lint */
 
 #include <sys/types.h>
@@ -39,6 +39,8 @@
 #include <stdio.h>
 #include <unistd.h>
 
+#include "rumpuser_int.h"
+
 #ifdef __sun__
 #define _PATH_DEVNULL "/dev/null"
 #else
@@ -55,9 +57,12 @@
 {
        ssize_t n;
        int error;
+       int rv;
 
-       if (isdaemonizing)
-               return EINPROGRESS;
+       if (isdaemonizing) {
+               rv = EINPROGRESS;
+               goto out;
+       }
        isdaemonizing = 1;
 
        /*
@@ -72,7 +77,8 @@
         * take care of that or not.
         */
        if (socketpair(PF_LOCAL, SOCK_STREAM, 0, daemonpipe) == -1) {
-               return errno;
+               rv = errno;
+               goto out;
        }
 
        switch (fork()) {
@@ -80,9 +86,11 @@
                if (setsid() == -1) {
                        rumpuser_daemonize_done(errno);
                }
-               return 0;
+               rv = 0;
+               break;
        case -1:
-               return errno;
+               rv = errno;
+               break;
        default:
                close(daemonpipe[1]);
                n = recv(daemonpipe[0], &error, sizeof(error), MSG_NOSIGNAL);
@@ -93,16 +101,21 @@
                _exit(error);
                /*NOTREACHED*/
        }
+
+ out:
+       ET(rv);
 }
 
 int
 rumpuser_daemonize_done(int error)
 {
        ssize_t n;
-       int fd;
+       int fd, rv = 0;
 
-       if (!isdaemonizing)
-               return ENOENT;
+       if (!isdaemonizing) {
+               rv = ENOENT;
+               goto outout;
+       }
 
        if (error == 0) {
                fd = open(_PATH_DEVNULL, O_RDWR);



Home | Main Index | Thread Index | Old Index