Source-Changes-HG archive

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

[src/trunk]: src/sys/rump Provide an interface for reboot.



details:   https://anonhg.NetBSD.org/src/rev/8b55c5d8749b
branches:  trunk
changeset: 748014:8b55c5d8749b
user:      pooka <pooka%NetBSD.org@localhost>
date:      Fri Oct 09 14:41:36 2009 +0000

description:
Provide an interface for reboot.

diffstat:

 sys/rump/include/rump/rump.h                |   3 +-
 sys/rump/include/rump/rumpuser.h            |   6 ++--
 sys/rump/librump/rumpkern/emul.c            |  11 ++++--
 sys/rump/librump/rumpkern/rump.c            |  42 ++++++++++++++++++++++++++--
 sys/rump/librump/rumpuser/rumpuser.c        |  11 ++++--
 sys/rump/librump/rumpvfs/rump_vfs.c         |  11 ++++++-
 sys/rump/librump/rumpvfs/rump_vfs_private.h |   4 ++-
 7 files changed, 69 insertions(+), 19 deletions(-)

diffs (246 lines):

diff -r 7aaa4f8ec828 -r 8b55c5d8749b sys/rump/include/rump/rump.h
--- a/sys/rump/include/rump/rump.h      Fri Oct 09 14:32:07 2009 +0000
+++ b/sys/rump/include/rump/rump.h      Fri Oct 09 14:41:36 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump.h,v 1.27 2009/10/07 09:50:43 pooka Exp $  */
+/*     $NetBSD: rump.h,v 1.28 2009/10/09 14:41:36 pooka Exp $  */
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -76,6 +76,7 @@
 int    rump_module_fini(struct modinfo *);
 
 int            rump__init(int);
+void           rump_reboot(int);
 int            rump_getversion(void);
 
 struct componentname   *rump_makecn(u_long, u_long, const char *, size_t,
diff -r 7aaa4f8ec828 -r 8b55c5d8749b sys/rump/include/rump/rumpuser.h
--- a/sys/rump/include/rump/rumpuser.h  Fri Oct 09 14:32:07 2009 +0000
+++ b/sys/rump/include/rump/rumpuser.h  Fri Oct 09 14:41:36 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpuser.h,v 1.27 2009/09/24 21:30:42 pooka Exp $      */
+/*     $NetBSD: rumpuser.h,v 1.28 2009/10/09 14:41:36 pooka Exp $      */
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -99,8 +99,8 @@
 
 int rumpuser_putchar(int, int *);
 
-void rumpuser_panic(void);
-
+#define RUMPUSER_PANIC (-1)
+void rumpuser_exit(int);
 void rumpuser_seterrno(int);
 
 int rumpuser_writewatchfile_setup(int, int, intptr_t, int *);
diff -r 7aaa4f8ec828 -r 8b55c5d8749b sys/rump/librump/rumpkern/emul.c
--- a/sys/rump/librump/rumpkern/emul.c  Fri Oct 09 14:32:07 2009 +0000
+++ b/sys/rump/librump/rumpkern/emul.c  Fri Oct 09 14:41:36 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: emul.c,v 1.97 2009/10/03 22:55:48 christos Exp $       */
+/*     $NetBSD: emul.c,v 1.98 2009/10/09 14:41:36 pooka Exp $  */
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.97 2009/10/03 22:55:48 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.98 2009/10/09 14:41:36 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/malloc.h>
@@ -549,7 +549,7 @@
 suspendsched(void)
 {
 
-       panic("%s: not implemented", __func__);
+       /* we don't control scheduling currently, can't do anything now */
 }
 
 u_int
@@ -731,7 +731,10 @@
 cpu_reboot(int howto, char *bootstr)
 {
 
-       rumpuser_panic();
+       rump_reboot(howto);
+
+       /* this function is __dead, we must exit */
+       rumpuser_exit(0);
 }
 
 /*
diff -r 7aaa4f8ec828 -r 8b55c5d8749b sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c  Fri Oct 09 14:32:07 2009 +0000
+++ b/sys/rump/librump/rumpkern/rump.c  Fri Oct 09 14:41:36 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump.c,v 1.120 2009/10/08 00:47:47 pooka Exp $ */
+/*     $NetBSD: rump.c,v 1.121 2009/10/09 14:41:36 pooka Exp $ */
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.120 2009/10/08 00:47:47 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.121 2009/10/09 14:41:36 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -50,6 +50,7 @@
 #include <sys/once.h>
 #include <sys/percpu.h>
 #include <sys/queue.h>
+#include <sys/reboot.h>
 #include <sys/resourcevar.h>
 #include <sys/select.h>
 #include <sys/sysctl.h>
@@ -121,6 +122,8 @@
 __weak_alias(rump_vfs_init,rump__unavailable);
 __weak_alias(rump_dev_init,rump__unavailable);
 
+__weak_alias(rump_vfs_fini,rump__unavailable);
+
 __weak_alias(biodone,rump__unavailable);
 
 void rump__unavailable_vfs_panic(void);
@@ -178,10 +181,13 @@
        struct lwp *l;
        int error;
 
-       /* XXX */
+       /* not reentrant */
        if (rump_inited)
                return 0;
-       rump_inited = 1;
+       else if (rump_inited == -1)
+               panic("rump_init: host process restart required");
+       else
+               rump_inited = 1;
 
        /*
         * Seed arc4random() with a "reasonable" amount of randomness.
@@ -289,6 +295,34 @@
        return 0;
 }
 
+/* maybe support sys_reboot some day for remote shutdown */
+void
+rump_reboot(int howto)
+{
+
+       /* dump means we really take the dive here */
+       if ((howto & RB_DUMP) || panicstr) {
+               rumpuser_exit(RUMPUSER_PANIC);
+               /*NOTREACHED*/
+       }
+
+       /* try to sync */
+       if (!((howto & RB_NOSYNC) || panicstr)) {
+               rump_vfs_fini();
+       }
+
+       /* your wish is my command */
+       if (howto & RB_HALT) {
+               for (;;) {
+                       uint64_t sec = 5, nsec = 0;
+                       int error;
+
+                       rumpuser_nanosleep(&sec, &nsec, &error);
+               }
+       }
+       rump_inited = -1;
+}
+
 struct uio *
 rump_uio_setup(void *buf, size_t bufsize, off_t offset, enum rump_uiorw rw)
 {
diff -r 7aaa4f8ec828 -r 8b55c5d8749b sys/rump/librump/rumpuser/rumpuser.c
--- a/sys/rump/librump/rumpuser/rumpuser.c      Fri Oct 09 14:32:07 2009 +0000
+++ b/sys/rump/librump/rumpuser/rumpuser.c      Fri Oct 09 14:41:36 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpuser.c,v 1.42 2009/06/10 18:36:33 pooka Exp $      */
+/*     $NetBSD: rumpuser.c,v 1.43 2009/10/09 14:41:36 pooka Exp $      */
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.42 2009/06/10 18:36:33 pooka Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.43 2009/10/09 14:41:36 pooka Exp $");
 #endif /* !lint */
 
 /* thank the maker for this */
@@ -443,10 +443,13 @@
 }
 
 void
-rumpuser_panic(void)
+rumpuser_exit(int rv)
 {
 
-       abort();
+       if (rv == RUMPUSER_PANIC)
+               abort();
+       else
+               exit(rv);
 }
 
 void
diff -r 7aaa4f8ec828 -r 8b55c5d8749b sys/rump/librump/rumpvfs/rump_vfs.c
--- a/sys/rump/librump/rumpvfs/rump_vfs.c       Fri Oct 09 14:32:07 2009 +0000
+++ b/sys/rump/librump/rumpvfs/rump_vfs.c       Fri Oct 09 14:41:36 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump_vfs.c,v 1.29 2009/10/07 09:55:35 pooka Exp $      */
+/*     $NetBSD: rump_vfs.c,v 1.30 2009/10/09 14:41:36 pooka Exp $      */
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.29 2009/10/07 09:55:35 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.30 2009/10/09 14:41:36 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/buf.h>
@@ -120,6 +120,13 @@
        }
 }
 
+void
+rump_vfs_fini(void)
+{
+
+       vfs_shutdown();
+}
+
 struct componentname *
 rump_makecn(u_long nameiop, u_long flags, const char *name, size_t namelen,
        kauth_cred_t creds, struct lwp *l)
diff -r 7aaa4f8ec828 -r 8b55c5d8749b sys/rump/librump/rumpvfs/rump_vfs_private.h
--- a/sys/rump/librump/rumpvfs/rump_vfs_private.h       Fri Oct 09 14:32:07 2009 +0000
+++ b/sys/rump/librump/rumpvfs/rump_vfs_private.h       Fri Oct 09 14:41:36 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump_vfs_private.h,v 1.5 2009/10/07 09:17:54 pooka Exp $       */
+/*     $NetBSD: rump_vfs_private.h,v 1.6 2009/10/09 14:41:36 pooka Exp $       */
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -31,6 +31,8 @@
 #include <sys/types.h>
 
 void           rump_vfs_init(void);
+void           rump_vfs_fini(void);
+
 void           rumpfs_init(void);
 
 #define RUMPBLK        254



Home | Main Index | Thread Index | Old Index