head 1.22; access; symbols netbsd-6-1:1.22.0.16 netbsd-6-0-2-RELEASE:1.22 netbsd-6-1-RELEASE:1.22 netbsd-6-1-RC4:1.22 netbsd-6-1-RC3:1.22 agc-symver:1.22.0.14 agc-symver-base:1.22 netbsd-6-1-RC2:1.22 tls-maxphys-nbase:1.22.0.12 netbsd-6-1-RC1:1.22 yamt-pagecache-base8:1.22 netbsd-6-0-1-RELEASE:1.22 yamt-pagecache-base7:1.22 matt-nb6-plus-nbase:1.22 yamt-pagecache-base6:1.22 netbsd-6-0:1.22.0.10 netbsd-6-0-RELEASE:1.22 netbsd-6-0-RC2:1.22 tls-maxphys:1.22.0.8 tls-maxphys-base:1.22 matt-nb6-plus:1.22.0.6 matt-nb6-plus-base:1.22 netbsd-6-0-RC1:1.22 yamt-pagecache-base5:1.22 yamt-pagecache-base4:1.22 netbsd-6:1.22.0.4 netbsd-6-base:1.22 yamt-pagecache-base3:1.22 yamt-pagecache-base2:1.22 yamt-pagecache:1.22.0.2 yamt-pagecache-base:1.22 cherry-xenmp:1.21.0.2 cherry-xenmp-base:1.21 bouyer-quota2-nbase:1.21 bouyer-quota2:1.13.0.2 bouyer-quota2-base:1.16 matt-mips64-premerge-20101231:1.11; locks; strict; comment @ * @; 1.22 date 2011.09.16.15.39.28; author joerg; state Exp; branches; next 1.21; 1.21 date 2011.02.22.15.51.59; author pooka; state Exp; branches; next 1.20; 1.20 date 2011.02.21.18.50.21; author pooka; state Exp; branches; next 1.19; 1.19 date 2011.02.18.09.54.03; author pooka; state Exp; branches; next 1.18; 1.18 date 2011.02.17.16.59.46; author pooka; state Exp; branches; next 1.17; 1.17 date 2011.02.17.16.03.05; author pooka; state Exp; branches; next 1.16; 1.16 date 2011.02.04.20.06.23; author pooka; state Exp; branches; next 1.15; 1.15 date 2011.02.03.11.25.27; author pooka; state Exp; branches; next 1.14; 1.14 date 2011.02.03.11.21.16; author pooka; state Exp; branches; next 1.13; 1.13 date 2011.01.03.12.18.25; author wiz; state Exp; branches 1.13.2.1; next 1.12; 1.12 date 2011.01.03.10.44.40; author pooka; state Exp; branches; next 1.11; 1.11 date 2010.12.15.19.07.43; author pooka; state Exp; branches; next 1.10; 1.10 date 2010.12.15.09.40.21; author wiz; state Exp; branches; next 1.9; 1.9 date 2010.12.14.16.40.05; author pooka; state Exp; branches; next 1.8; 1.8 date 2010.12.13.14.26.22; author pooka; state Exp; branches; next 1.7; 1.7 date 2010.12.13.14.13.21; author pooka; state Exp; branches; next 1.6; 1.6 date 2010.12.13.13.32.25; author pooka; state Exp; branches; next 1.5; 1.5 date 2010.12.12.18.33.44; author pooka; state Exp; branches; next 1.4; 1.4 date 2010.12.12.18.32.47; author pooka; state Exp; branches; next 1.3; 1.3 date 2010.12.12.12.49.37; author pooka; state Exp; branches; next 1.2; 1.2 date 2010.12.11.10.44.55; author pooka; state Exp; branches; next 1.1; 1.1 date 2010.12.05.17.37.33; author pooka; state Exp; branches; next ; 1.13.2.1 date 2011.02.08.16.20.12; author bouyer; state Exp; branches; next 1.13.2.2; 1.13.2.2 date 2011.03.05.15.11.00; author bouyer; state Exp; branches; next ; desc @@ 1.22 log @Use __dead @ text @/* $NetBSD: rump_allserver.c,v 1.21 2011/02/22 15:51:59 pooka Exp $ */ /*- * Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: rump_allserver.c,v 1.21 2011/02/22 15:51:59 pooka Exp $"); #endif /* !lint */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include __dead static void usage(void) { fprintf(stderr, "usage: %s [-s] [-c ncpu] [-d drivespec] [-l libs] " "[-m modules] bindurl\n", getprogname()); exit(1); } __dead static void die(int sflag, int error, const char *reason) { warnx("%s: %s", reason, strerror(error)); if (!sflag) rump_daemonize_done(error); exit(1); } static sem_t sigsem; static void sigreboot(int sig) { sem_post(&sigsem); } static const char *const disktokens[] = { #define DKEY 0 "key", #define DFILE 1 "hostpath", #define DSIZE 2 #define DSIZE_E -1 "size", #define DOFFSET 3 "offset", #define DLABEL 4 "disklabel", #define DTYPE 5 "type", NULL }; struct etfsreg { const char *key; const char *hostpath; off_t flen; off_t foffset; char partition; enum rump_etfs_type type; }; struct etfstype { const char *name; enum rump_etfs_type type; } etfstypes[] = { { "blk", RUMP_ETFS_BLK }, { "chr", RUMP_ETFS_CHR }, { "reg", RUMP_ETFS_REG }, }; int main(int argc, char *argv[]) { const char *serverurl; char **modarray = NULL; unsigned nmods = 0, curmod = 0, i; struct etfsreg *etfs = NULL; unsigned netfs = 0, curetfs = 0; int error; int ch, sflag; int ncpu; setprogname(argv[0]); sflag = 0; while ((ch = getopt(argc, argv, "c:d:l:m:r:sv")) != -1) { switch (ch) { case 'c': ncpu = atoi(optarg); /* XXX: MAXCPUS is from host, not from kernel */ if (ncpu < 1 || ncpu > MAXCPUS) err(1, "CPU count needs to be between " "1 and %d\n", MAXCPUS); setenv("RUMP_NCPU", optarg, 1); break; case 'd': { char *options, *value; char *key, *hostpath; long long flen, foffset; char partition; int ftype; flen = foffset = 0; partition = 0; key = hostpath = NULL; ftype = -1; options = optarg; while (*options) { switch (getsubopt(&options, __UNCONST(disktokens), &value)) { case DKEY: if (key != NULL) { fprintf(stderr, "key already given\n"); usage(); } key = value; break; case DFILE: if (hostpath != NULL) { fprintf(stderr, "hostpath already given\n"); usage(); } hostpath = value; break; case DSIZE: if (flen != 0) { fprintf(stderr, "size already given\n"); usage(); } if (strcmp(value, "host") == 0) { if (foffset != 0) { fprintf(stderr, "cannot specify " "offset with " "size=host\n"); usage(); } flen = DSIZE_E; } else { /* XXX: off_t max? */ flen = strsuftoll("-d size", value, 0, LLONG_MAX); } break; case DOFFSET: if (foffset != 0) { fprintf(stderr, "offset already given\n"); usage(); } if (flen == DSIZE_E) { fprintf(stderr, "cannot " "specify offset with " "size=host\n"); usage(); } /* XXX: off_t max? */ foffset = strsuftoll("-d offset", value, 0, LLONG_MAX); break; case DLABEL: if (foffset != 0 || flen != 0) { fprintf(stderr, "disklabel needs to be " "used alone\n"); usage(); } if (strlen(value) != 1 || *value < 'a' || *value > 'z') { fprintf(stderr, "invalid label part\n"); usage(); } partition = *value; break; case DTYPE: if (ftype != -1) { fprintf(stderr, "type already specified\n"); usage(); } for (i = 0; i < __arraycount(etfstypes); i++) { if (strcmp(etfstypes[i].name, value) == 0) break; } if (i == __arraycount(etfstypes)) { fprintf(stderr, "invalid type %s\n", value); usage(); } ftype = etfstypes[i].type; break; default: fprintf(stderr, "invalid dtoken\n"); usage(); break; } } if (key == NULL || hostpath == NULL || (flen == 0 && partition == 0)) { fprintf(stderr, "incomplete drivespec\n"); usage(); } if (ftype == -1) ftype = RUMP_ETFS_BLK; if (netfs - curetfs == 0) { etfs = realloc(etfs, (netfs+16)*sizeof(*etfs)); if (etfs == NULL) err(1, "realloc etfs"); netfs += 16; } etfs[curetfs].key = key; etfs[curetfs].hostpath = hostpath; etfs[curetfs].flen = flen; etfs[curetfs].foffset = foffset; etfs[curetfs].partition = partition; etfs[curetfs].type = ftype; curetfs++; break; } case 'l': if (dlopen(optarg, RTLD_LAZY|RTLD_GLOBAL) == NULL) { char pb[MAXPATHLEN]; /* try to mimic linker -l syntax */ snprintf(pb, sizeof(pb), "lib%s.so", optarg); if (dlopen(pb, RTLD_LAZY|RTLD_GLOBAL) == NULL) { errx(1, "dlopen %s failed: %s", pb, dlerror()); } } break; case 'm': if (nmods - curmod == 0) { modarray = realloc(modarray, (nmods+16) * sizeof(char *)); if (modarray == NULL) err(1, "realloc"); nmods += 16; } modarray[curmod++] = optarg; break; case 'r': setenv("RUMP_MEMLIMIT", optarg, 1); break; case 's': sflag = 1; break; case 'v': setenv("RUMP_VERBOSE", "1", 1); break; default: usage(); /*NOTREACHED*/ } } argc -= optind; argv += optind; if (argc != 1) usage(); serverurl = argv[0]; if (!sflag) { error = rump_daemonize_begin(); if (error) errx(1, "rump daemonize: %s", strerror(error)); } error = rump_init(); if (error) die(sflag, error, "rump init failed"); /* load modules */ for (i = 0; i < curmod; i++) { struct modctl_load ml; #define ETFSKEY "/module.mod" if ((error = rump_pub_etfs_register(ETFSKEY, modarray[0], RUMP_ETFS_REG)) != 0) die(sflag, error, "module etfs register failed"); memset(&ml, 0, sizeof(ml)); ml.ml_filename = ETFSKEY; if (rump_sys_modctl(MODCTL_LOAD, &ml) == -1) die(sflag, errno, "module load failed"); rump_pub_etfs_remove(ETFSKEY); #undef ETFSKEY } /* register host drives */ for (i = 0; i < curetfs; i++) { char buf[1<<16]; struct disklabel dl; struct stat sb; off_t foffset, flen, fendoff; int fd, oflags; oflags = etfs[i].flen == DSIZE_E ? 0 : O_CREAT; fd = open(etfs[i].hostpath, O_RDWR | oflags, 0644); if (fd == -1) die(sflag, errno, "etfs hostpath open"); if (etfs[i].partition) { int partition = etfs[i].partition - 'a'; pread(fd, buf, sizeof(buf), 0); if (disklabel_scan(&dl, buf, sizeof(buf))) die(sflag, ENOENT, "disklabel not found"); if (partition >= dl.d_npartitions) die(sflag, ENOENT, "partition not available"); foffset = dl.d_partitions[partition].p_offset << DEV_BSHIFT; flen = dl.d_partitions[partition].p_size << DEV_BSHIFT; } else { foffset = etfs[i].foffset; flen = etfs[i].flen; } if (fstat(fd, &sb) == -1) die(sflag, errno, "fstat etfs hostpath"); if (flen == DSIZE_E) { if (sb.st_size == 0) die(sflag, EINVAL, "size=host, but cannot " "query non-zero size"); flen = sb.st_size; } fendoff = foffset + flen; if (S_ISREG(sb.st_mode) && sb.st_size < fendoff) { if (ftruncate(fd, fendoff) == -1) die(sflag, errno, "truncate"); } close(fd); if ((error = rump_pub_etfs_register_withsize(etfs[i].key, etfs[i].hostpath, etfs[i].type, foffset, flen)) != 0) die(sflag, error, "etfs register"); } error = rump_init_server(serverurl); if (error) die(sflag, error, "rump server init failed"); if (!sflag) rump_daemonize_done(RUMP_DAEMONIZE_SUCCESS); sem_init(&sigsem, 0, 0); signal(SIGTERM, sigreboot); signal(SIGINT, sigreboot); sem_wait(&sigsem); rump_sys_reboot(0, NULL); /*NOTREACHED*/ return 0; } @ 1.21 log @* at least try to query size of non-regular size=host files too, give up if we get 0 * fix a few error messages @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.20 2011/02/21 18:50:21 pooka Exp $ */ d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.20 2011/02/21 18:50:21 pooka Exp $"); d52 1 a52 1 static void d61 1 a61 1 static void @ 1.20 log @add command line options for kernel memory allocation limit and bootverbose @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.19 2011/02/18 09:54:03 pooka Exp $ */ d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.19 2011/02/18 09:54:03 pooka Exp $"); d183 1 a183 1 "size=e\n"); d202 1 a202 1 "size=e\n"); d386 3 a388 2 if (!S_ISREG(sb.st_mode)) die(sflag, EINVAL, "size=e requires reg file"); @ 1.19 log @Use "host" instead of the slightly more cryptic "e" to indicate that the size of the mapping should be taken from the host file size. @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.18 2011/02/17 16:59:46 pooka Exp $ */ d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.18 2011/02/17 16:59:46 pooka Exp $"); d129 1 a129 1 while ((ch = getopt(argc, argv, "c:d:l:m:s")) != -1) { d302 3 d308 3 @ 1.18 log @Use "size=e" as a way say "if the underlying file is preexisting regular file, use whatever size it has". @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.17 2011/02/17 16:03:05 pooka Exp $ */ d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.17 2011/02/17 16:03:05 pooka Exp $"); d178 1 a178 1 if (strcmp(value, "e") == 0) { @ 1.17 log @Make it possible to specify the type of file (blk/chr/reg) that a mapped file (-d) is exposed as within the rump kernel. @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.16 2011/02/04 20:06:23 pooka Exp $ */ d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.16 2011/02/04 20:06:23 pooka Exp $"); d85 1 d178 14 a191 3 /* XXX: off_t max? */ flen = strsuftoll("-d size", value, 0, LLONG_MAX); d199 6 d351 1 a351 1 int fd; d353 2 a354 1 fd = open(etfs[i].hostpath, O_RDWR | O_CREAT, 0644); d356 1 a356 1 die(sflag, errno, "etfs hostpath create"); a375 1 fendoff = foffset + flen; d379 6 @ 1.16 log @Allow to specify -d hostpath offset,size with disklabel. @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.15 2011/02/03 11:25:27 pooka Exp $ */ d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.15 2011/02/03 11:25:27 pooka Exp $"); d90 2 d104 9 d143 1 d148 1 d208 22 d242 2 d257 1 a257 1 etfs[curetfs].type = RUMP_ETFS_BLK; @ 1.15 log @Create backing image with mode 0644 instead of 0755 & document this. @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.14 2011/02/03 11:21:16 pooka Exp $ */ d4 1 a4 1 * Copyright (c) 2010 Antti Kantee. All Rights Reserved. d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.14 2011/02/03 11:21:16 pooka Exp $"); d34 1 d50 1 d88 2 d98 1 d131 1 d134 1 d148 1 d157 1 d178 17 d202 2 a203 1 if (key == NULL || hostpath == NULL || flen == 0) { d219 1 d292 2 d295 1 a295 1 off_t fsize; a297 1 fsize = etfs[i].foffset + etfs[i].flen; d301 21 d324 2 a325 2 if (S_ISREG(sb.st_mode) && sb.st_size < fsize) { if (ftruncate(fd, fsize) == -1) d331 1 a331 2 etfs[i].hostpath, etfs[i].type, etfs[i].foffset, etfs[i].flen)) != 0) @ 1.14 log @* make it possible to specify an offset in -d * truncate -d hostpath only if it's a regular file and smaller than offset+size @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.13 2011/01/03 12:18:25 wiz Exp $ */ d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.13 2011/01/03 12:18:25 wiz Exp $"); d269 1 a269 1 fd = open(etfs[i].hostpath, O_RDWR | O_CREAT, 0755); @ 1.13 log @Fix usage (8th bit begone!) @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.12 2011/01/03 10:44:40 pooka Exp $ */ d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.12 2011/01/03 10:44:40 pooka Exp $"); d84 2 d93 1 d125 1 a125 1 long long flen; d127 1 a127 1 flen = 0; d159 10 d191 1 d264 2 d268 1 d271 7 a277 3 die(sflag, error, "etfs hostpath create"); if (ftruncate(fd, etfs[i].flen) == -1) die(sflag, error, "truncate"); d280 3 a282 2 if ((error = rump_pub_etfs_register(etfs[i].key, etfs[i].hostpath, etfs[i].type)) != 0) @ 1.13.2.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.16 2011/02/04 20:06:23 pooka Exp $ */ d4 1 a4 1 * Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved. d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.16 2011/02/04 20:06:23 pooka Exp $"); a33 1 #include a48 1 #include a83 4 #define DOFFSET 3 "offset", #define DLABEL 4 "disklabel", a90 2 off_t foffset; char partition; d122 1 a122 2 long long flen, foffset; char partition; d124 1 a124 2 flen = foffset = 0; partition = 0; a137 1 a145 1 a155 27 case DOFFSET: if (foffset != 0) { fprintf(stderr, "offset already given\n"); usage(); } /* XXX: off_t max? */ foffset = strsuftoll("-d offset", value, 0, LLONG_MAX); break; case DLABEL: if (foffset != 0 || flen != 0) { fprintf(stderr, "disklabel needs to be " "used alone\n"); usage(); } if (strlen(value) != 1 || *value < 'a' || *value > 'z') { fprintf(stderr, "invalid label part\n"); usage(); } partition = *value; break; d163 1 a163 2 if (key == NULL || hostpath == NULL || (flen == 0 && partition == 0)) { a177 2 etfs[curetfs].foffset = foffset; etfs[curetfs].partition = partition; a249 4 char buf[1<<16]; struct disklabel dl; struct stat sb; off_t foffset, flen, fendoff; d252 1 a252 1 fd = open(etfs[i].hostpath, O_RDWR | O_CREAT, 0644); d254 3 a256 28 die(sflag, errno, "etfs hostpath create"); if (etfs[i].partition) { int partition = etfs[i].partition - 'a'; pread(fd, buf, sizeof(buf), 0); if (disklabel_scan(&dl, buf, sizeof(buf))) die(sflag, ENOENT, "disklabel not found"); if (partition >= dl.d_npartitions) die(sflag, ENOENT, "partition not available"); foffset = dl.d_partitions[partition].p_offset << DEV_BSHIFT; flen = dl.d_partitions[partition].p_size << DEV_BSHIFT; } else { foffset = etfs[i].foffset; flen = etfs[i].flen; } fendoff = foffset + flen; if (fstat(fd, &sb) == -1) die(sflag, errno, "fstat etfs hostpath"); if (S_ISREG(sb.st_mode) && sb.st_size < fendoff) { if (ftruncate(fd, fendoff) == -1) die(sflag, errno, "truncate"); } d259 2 a260 2 if ((error = rump_pub_etfs_register_withsize(etfs[i].key, etfs[i].hostpath, etfs[i].type, foffset, flen)) != 0) @ 1.13.2.2 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD$ */ d30 1 a30 1 __RCSID("$NetBSD$"); a84 1 #define DSIZE_E -1 a89 2 #define DTYPE 5 "type", a101 9 struct etfstype { const char *name; enum rump_etfs_type type; } etfstypes[] = { { "blk", RUMP_ETFS_BLK }, { "chr", RUMP_ETFS_CHR }, { "reg", RUMP_ETFS_REG }, }; d117 1 a117 1 while ((ch = getopt(argc, argv, "c:d:l:m:r:sv")) != -1) { a131 1 int ftype; a135 1 ftype = -1; d164 3 a166 14 if (strcmp(value, "host") == 0) { if (foffset != 0) { fprintf(stderr, "cannot specify " "offset with " "size=host\n"); usage(); } flen = DSIZE_E; } else { /* XXX: off_t max? */ flen = strsuftoll("-d size", value, 0, LLONG_MAX); } a173 6 if (flen == DSIZE_E) { fprintf(stderr, "cannot " "specify offset with " "size=host\n"); usage(); } a194 22 case DTYPE: if (ftype != -1) { fprintf(stderr, "type already specified\n"); usage(); } for (i = 0; i < __arraycount(etfstypes); i++) { if (strcmp(etfstypes[i].name, value) == 0) break; } if (i == __arraycount(etfstypes)) { fprintf(stderr, "invalid type %s\n", value); usage(); } ftype = etfstypes[i].type; break; a206 2 if (ftype == -1) ftype = RUMP_ETFS_BLK; d220 1 a220 1 etfs[curetfs].type = ftype; a246 3 case 'r': setenv("RUMP_MEMLIMIT", optarg, 1); break; a249 3 case 'v': setenv("RUMP_VERBOSE", "1", 1); break; d296 1 a296 1 int fd, oflags; d298 1 a298 2 oflags = etfs[i].flen == DSIZE_E ? 0 : O_CREAT; fd = open(etfs[i].hostpath, O_RDWR | oflags, 0644); d300 1 a300 1 die(sflag, errno, "etfs hostpath open"); d320 1 a323 7 if (flen == DSIZE_E) { if (sb.st_size == 0) die(sflag, EINVAL, "size=host, but cannot " "query non-zero size"); flen = sb.st_size; } fendoff = foffset + flen; @ 1.12 log @Add -c to control the number of CPUs configured in the kernel. @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.11 2010/12/15 19:07:43 pooka Exp $ */ d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.11 2010/12/15 19:07:43 pooka Exp $"); d54 1 a54 1 fprintf(stderr, "usage: %s [-s] [-c ncpu] [-d drivespec] [-l libs] " @ 1.11 log @Guard against supplying the same parameter multiple times in one -d argument. @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.10 2010/12/15 09:40:21 wiz Exp $ */ d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.10 2010/12/15 09:40:21 wiz Exp $"); d54 2 a55 2 fprintf(stderr, "usage: %s [-s] [-d drivespec] [-l libs] [-m modules] " "bindurl\n", getprogname()); d104 1 d109 1 a109 1 while ((ch = getopt(argc, argv, "d:l:m:s")) != -1) { d111 8 @ 1.10 log @Sort options in usage same as in man page. While here, replace \xa0 with ' '. Where do you get these from? @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.9 2010/12/14 16:40:05 pooka Exp $ */ d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.9 2010/12/14 16:40:05 pooka Exp $"); d122 5 d130 5 d138 5 @ 1.9 log @Add -d which can be used to register host-backed block devices in the rump kernel. It would be cool if this, and the other options, could be specified in a config file (plist or other). @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.8 2010/12/13 14:26:22 pooka Exp $ */ d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.8 2010/12/13 14:26:22 pooka Exp $"); d54 1 a54 1 fprintf(stderr, "usage: %s [-d drivespec] [-l libs] [-m modules] [-s] " @ 1.8 log @Also support ld syntax in -l. was: -l librumpvfs.so now: -lrumpvfs @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.7 2010/12/13 14:13:21 pooka Exp $ */ d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.7 2010/12/13 14:13:21 pooka Exp $"); d43 1 d54 2 a55 1 fprintf(stderr, "usage: %s [args] bindurl\n", getprogname()); d77 17 d100 2 d108 1 a108 1 while ((ch = getopt(argc, argv, "l:m:s")) != -1) { d110 49 d208 1 d221 17 @ 1.7 log @Add -m which can be used to load modules (which is a completely different code path than using dlopen() before rump_init(), since the former uses the in-kernel linker and the latter links the object in rtld). So: golem> ./rump_server -l librumpvfs.so -m /sys/modules/tmpfs/tmpfs.kmod unix:///tmp/commsuck ==> golem> env RUMP_SERVER=unix:///tmp/commsuck rump.modstat NAME CLASS SOURCE REFS SIZE REQUIRES suser secmodel builtin 0 - - tmpfs vfs filesys 0 16713 - wapbl vfs builtin 0 - - Source is filesys instead of builtin, as expected. Notably, for -m you *must* use -l librumpvfs.so. This is because you need VFS in your kernel to be able to load modules from the file system. In a regular kernel "librumpvfs.so" is linked at kernel build time and loaded by the bootloader. Here we use dlopen() for both effects (the other choices would have been to link rump_server with -lrumpvfs, but that would limit the flexibility, or link tmpfs.kmod directly into the binary, but that would limit the flexibility even more). @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.6 2010/12/13 13:32:25 pooka Exp $ */ d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.6 2010/12/13 13:32:25 pooka Exp $"); d90 10 a99 3 if (dlopen(optarg, RTLD_LAZY|RTLD_GLOBAL) == NULL) errx(1, "dlopen %s failed: %s", optarg, dlerror()); @ 1.6 log @Handle -l which dlopens libs. This is more applicable to rump_server than rump_allserver. So if I do: golem> rump_server unix:///tmp/commsuck ==> golem> env RUMP_SERVER=unix:///tmp/commsuck rump.modstat NAME CLASS SOURCE REFS SIZE REQUIRES suser secmodel builtin 0 - - and: golem> rump_server -l librumpvfs.so unix:///tmp/commsuck ==> golem> env RUMP_SERVER=unix:///tmp/commsuck rump.modstat NAME CLASS SOURCE REFS SIZE REQUIRES suser secmodel builtin 0 - - wapbl vfs builtin 0 - - golem> rump_server -l librumpvfs.so -l librumpfs_ffs.so unix:///tmp/commsuck ==> golem> env RUMP_SERVER=unix:///tmp/commsuck rump.modstat NAME CLASS SOURCE REFS SIZE REQUIRES ffs vfs builtin 0 - - suser secmodel builtin 0 - - wapbl vfs builtin 0 - - Well, you get the picture... @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.5 2010/12/12 18:33:44 pooka Exp $ */ d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.5 2010/12/12 18:33:44 pooka Exp $"); d35 1 d79 2 d87 1 a87 1 while ((ch = getopt(argc, argv, "l:s")) != -1) { d94 10 d130 15 @ 1.5 log @lint hint to previous @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.4 2010/12/12 18:32:47 pooka Exp $ */ d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.4 2010/12/12 18:32:47 pooka Exp $"); d39 1 d84 1 a84 1 while ((ch = getopt(argc, argv, "s")) != -1) { d86 5 @ 1.4 log @Reboot when killed (does cleanup). @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.3 2010/12/12 12:49:37 pooka Exp $ */ d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.3 2010/12/12 12:49:37 pooka Exp $"); d124 2 @ 1.3 log @use appropriate macro @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.2 2010/12/11 10:44:55 pooka Exp $ */ d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.2 2010/12/11 10:44:55 pooka Exp $"); d34 1 d37 1 d41 1 d65 8 d118 7 a124 1 pause(); @ 1.2 log @Detach by default or -s to stay-on-top. @ text @d1 1 a1 1 /* $NetBSD: rump_allserver.c,v 1.1 2010/12/05 17:37:33 pooka Exp $ */ d30 1 a30 1 __RCSID("$NetBSD: rump_allserver.c,v 1.1 2010/12/05 17:37:33 pooka Exp $"); d105 1 a105 1 rump_daemonize_done(0); @ 1.1 log @Add a rump server which comes with all the drivers currently available. In terms of modules it maps to: golem> rump.modstat NAME CLASS SOURCE REFS SIZE REQUIRES bpf driver builtin 0 - - cd9660 vfs builtin 0 - - cgd driver builtin 0 - - dm driver builtin 0 - - efs vfs builtin 0 - - ext2fs vfs builtin 0 - ffs fdesc vfs builtin 0 - - ffs vfs builtin 3 - - fss driver builtin 0 - - hfs vfs builtin 0 - - kernfs vfs builtin 0 - - ksem misc builtin 0 - - layerfs misc builtin 2 - - lfs vfs builtin 0 - ffs mfs vfs builtin 0 - ffs msdos vfs builtin 0 - - nfs vfs builtin 1 - - nfsserver misc builtin 0 - nfs nilfs vfs builtin 0 - - ntfs vfs builtin 0 - - null vfs builtin 0 - layerfs pad driver builtin 0 - - ptyfs vfs builtin 0 - - puffs vfs builtin 0 - putter putter driver builtin 1 - - scsiverbose misc builtin 0 - - smbfs vfs builtin 0 - - suser secmodel builtin 0 - - swsensor driver builtin 0 - - sysvbfs vfs builtin 0 - - tmpfs vfs builtin 0 - - udf vfs builtin 0 - - umap vfs builtin 0 - layerfs union vfs builtin 0 - - usbverbose misc builtin 0 - - wapbl vfs builtin 0 - - In terms of interfaces: golem> rump.ifconfig -C shmif virt lo carp and dmesg: NetBSD 5.99.41 (RUMP-ROAST) #0: Tue Nov 30 15:35:05 CET 2010 pooka@@pain-rustique.localhost:/usr/allsrc/src/sys/rump/librump/rumpkern total memory = unlimited (host limit) timecounter: Timecounters tick every 10.000 msec timecounter: Timecounter "rumpclk" frequency 100 Hz quality 0 cpu0 at thinair0: rump virtual cpu cpu1 at thinair0: rump virtual cpu root file system type: rumpfs mainbus0 (root) ugenhc0 at mainbus0 usb0 at ugenhc0: USB revision 2.0 uhub0 at usb0: vendor 0x7275 product 0x6d70, class 9/0, rev 0.00/0.00, addr 1 uhub0: 1 port with 1 removable, self powered ugenhc1 at mainbus0 usb1 at ugenhc1: USB revision 2.0 uhub1 at usb1: vendor 0x7275 product 0x6d70, class 9/0, rev 0.00/0.00, addr 1 uhub1: 1 port with 1 removable, self powered ugenhc2 at mainbus0 usb2 at ugenhc2: USB revision 2.0 uhub2 at usb2: vendor 0x7275 product 0x6d70, class 9/0, rev 0.00/0.00, addr 1 uhub2: 1 port with 1 removable, self powered ugenhc3 at mainbus0 usb3 at ugenhc3: USB revision 2.0 uhub3 at usb3: vendor 0x7275 product 0x6d70, class 9/0, rev 0.00/0.00, addr 1 uhub3: 1 port with 1 removable, self powered scsitest0 at mainbus0 scsibus0 at scsitest0: 2 targets, 1 lun per target cd0 at scsibus0 target 1 lun 0: cdrom removable Chicony Electronics Chicony Electronics, class 0/0, rev 2.00/1.00, addr 2, uhub0 port 1 not configured AuthenTec AuthenTec, class 255/255, rev 1.10/6.21, addr 2, uhub1 port 1 not configured swwdog0: software watchdog initialized Kernelized RAIDframe activated pad0: outputs: 44100Hz, 16-bit, stereo audio0 at pad0: half duplex, playback, capture There a bunch of other stuff which doesn't show up as any of the above, plus of course the usb drivers which are probed only if I have the appropriate hardware plugged into my workstation. @ text @d1 1 a1 1 /* $NetBSD$ */ d30 1 a30 1 __RCSID("$NetBSD$"); d52 10 d65 1 d67 1 d71 16 a86 1 if (argc != 2) d89 8 d99 2 a100 2 errx(1, "rump init failed: %s", strerror(error)); error = rump_init_server(argv[1]); d102 5 a106 1 errx(1, "rump server init failed: %s", strerror(error)); @