From: Rob Landley <rob@landley.net>
To: Jeff Dike <jdike@addtoit.com>
Cc: Can Sar <csar@stanford.edu>, user-mode-linux-devel@lists.sourceforge.net
Subject: Re: [uml-devel] Making UML Single Threader
Date: Wed, 9 Nov 2005 21:55:27 -0600 [thread overview]
Message-ID: <200511092155.28199.rob@landley.net> (raw)
In-Reply-To: <20051110040708.GC15002@ccure.user-mode-linux.org>
[-- Attachment #1: Type: text/plain, Size: 1691 bytes --]
On Wednesday 09 November 2005 22:07, Jeff Dike wrote:
> On Tue, Nov 08, 2005 at 06:35:47PM -0600, Rob Landley wrote:
> > Jeff was going to split out the scheduler and filesystem into shared
> > libraries or some such. He mentions it in his intermittent diary, among
> > other places.
>
> This has nothing to do with that.
Ok.
> One of my other future projects is embedding UML into other things, as in
> a library, to give those other processes access to functionality like
> clustering.
You've mentioned this before. I've never quite been able to visualize what it
is you want to do. (Embed UML to give processes access to functionality like
clustering... Nope, I still don't get it. Can you give a more concrete
example?)
> In this case, you may not want UML booting to userspace - you
> just want the kernel initialized enough that you can call into it.
My normal use case for UML involves an init that's either a command shell or a
shell script, so I'm used to there often only being one process on the
system. (I even made a dumb little "oneit.c", attached, that runs one
process and then shuts down when that process exits, and sets up everything
so ctrl-c works in that process.)
I.E.
./linux rootfstype=hostfs rw init=/path/to/oneit /bin/sh
And then once you've got your command shell in UML, you can insmod a module
that calls or prints out whatever you need, while the init process can block
indefinitely and there are no other tasks running. So I've never had too
much trouble accessing the sucker's internals when I wanted to do so, in an
otherwise quiescent system. (Usually I just stick printfs into the sucker,
though. It's just so easy...)
Rob
[-- Attachment #2: oneit.c --]
[-- Type: text/x-csrc, Size: 1117 bytes --]
/* oneit.c, tiny one-process init replacement.
*
* Copyright 2005 by Rob Landley. Released under gpl v2.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/reboot.h>
// World's most brain-dead init program. Does the minimum amount of work
// necessary to get ctrl-c and such to work.
//
// Fork a child (PID 1 is special: it can't exit and has various signals
// blocked). In the child, attach stdio to /dev/tty0 (so we have a controlling
// tty, plus do a setsid()), then exec the rest of the command line.
//
// PID 1 then reaps zombies until the child process it spawned exits, at which
// point it calls sync() and reboot().
int main(int argc, char *argv[])
{
int a;
pid_t pid;
// pid 1 just reaps zombies until it gets its child, then halts the system.
pid=fork();
if(pid) {
while(pid!=wait());
sync();
reboot(LINUX_REBOOT_CMD_HALT);
}
// Redirect stdio to /dev/tty0, with new session ID, so ctrl-c works.
setsid();
for(a=0;a<3;a++) {
close(a);
open("/dev/tty0",O_RDWR);
}
execvp(argv[1],argv+1);
}
next prev parent reply other threads:[~2005-11-10 3:55 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-06 23:23 [uml-devel] Does UML 2.6.14 work under x86-64? Rob Landley
2005-11-07 16:25 ` Jeff Dike
2005-11-07 19:32 ` Blaisorblade
2005-11-07 14:38 ` David Lang
2005-11-07 19:44 ` Blaisorblade
2005-11-08 0:53 ` Rob Landley
2005-11-07 14:47 ` David Lang
2005-11-07 15:30 ` David Lang
2005-11-08 3:39 ` Rob Landley
2005-11-08 5:13 ` [uml-devel] Making UML Single Threader Can Sar
2005-11-08 7:09 ` Rob Landley
2005-11-08 7:44 ` Can Sar
2005-11-09 0:35 ` Rob Landley
2005-11-09 0:48 ` Blaisorblade
2005-11-09 1:17 ` Rob Landley
2005-11-09 1:31 ` Blaisorblade
2005-11-09 3:18 ` Rob Landley
2005-11-10 4:18 ` Jeff Dike
2005-11-10 4:58 ` Rob Landley
2005-11-10 6:23 ` Henrik Nordstrom
2005-11-10 4:07 ` Jeff Dike
2005-11-10 3:55 ` Rob Landley [this message]
2005-11-08 15:46 ` Jeff Dike
2005-11-09 0:27 ` Rob Landley
2005-11-14 13:59 ` Nix
2005-11-14 19:37 ` Blaisorblade
2005-11-14 20:00 ` Nix
2005-11-14 20:05 ` Geert Uytterhoeven
2005-11-15 11:39 ` Henrik Nordstrom
2005-11-16 1:23 ` Rob Landley
2005-11-08 16:13 ` Blaisorblade
2005-11-09 0:51 ` Rob Landley
2005-11-08 15:43 ` Jeff Dike
2005-11-08 16:10 ` Blaisorblade
2005-11-08 19:11 ` Can Sar
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=200511092155.28199.rob@landley.net \
--to=rob@landley.net \
--cc=csar@stanford.edu \
--cc=jdike@addtoit.com \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/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.