summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2015-12-03 21:45:45 +0000
committerreyk <reyk@openbsd.org>2015-12-03 21:45:45 +0000
commiteb8d1da16b60d8e99e4003563b8ace389257b016 (patch)
treed1bb34223b008a8667e692562544786dd03e9c6c
parentdeleting ip_insertoptions() prototype, which is no longer needed (diff)
downloadwireguard-openbsd-eb8d1da16b60d8e99e4003563b8ace389257b016.tar.xz
wireguard-openbsd-eb8d1da16b60d8e99e4003563b8ace389257b016.zip
Replace vmmctl with vmctl. Also remove parse.y from the "new" vmctl.
As discussed with mlarkin@ and deraadt@
-rw-r--r--usr.sbin/vmctl/Makefile (renamed from usr.sbin/vmmctl/Makefile)6
-rw-r--r--usr.sbin/vmctl/main.c (renamed from usr.sbin/vmmctl/main.c)11
-rw-r--r--usr.sbin/vmctl/vmctl.8 (renamed from usr.sbin/vmmctl/vmmctl.8)22
-rw-r--r--usr.sbin/vmctl/vmctl.c (renamed from usr.sbin/vmmctl/vmmctl.c)6
-rw-r--r--usr.sbin/vmctl/vmctl.h (renamed from usr.sbin/vmmctl/parser.h)16
-rw-r--r--usr.sbin/vmd/vm.conf.54
-rw-r--r--usr.sbin/vmd/vmd.810
-rw-r--r--usr.sbin/vmmctl/parse.y668
-rw-r--r--usr.sbin/vmmctl/vmm.conf.5140
9 files changed, 33 insertions, 850 deletions
diff --git a/usr.sbin/vmmctl/Makefile b/usr.sbin/vmctl/Makefile
index 40db2fd973a..9335dde79d1 100644
--- a/usr.sbin/vmmctl/Makefile
+++ b/usr.sbin/vmctl/Makefile
@@ -1,8 +1,8 @@
.if ${MACHINE} == "amd64"
-PROG= vmmctl
-SRCS= vmmctl.c main.c parse.y
+PROG= vmctl
+SRCS= vmctl.c main.c
CFLAGS+= -Wall
CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes
CFLAGS+= -Wmissing-declarations
@@ -18,6 +18,6 @@ NOPROG= yes
.endif
-MAN= vmmctl.8 vmm.conf.5
+MAN= vmctl.8
.include <bsd.prog.mk>
diff --git a/usr.sbin/vmmctl/main.c b/usr.sbin/vmctl/main.c
index 8979f17bfe3..baa14eee475 100644
--- a/usr.sbin/vmmctl/main.c
+++ b/usr.sbin/vmctl/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.7 2015/12/03 13:08:44 reyk Exp $ */
+/* $OpenBSD: main.c,v 1.1 2015/12/03 21:45:45 reyk Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -36,10 +36,10 @@
#include <imsg.h>
#include "vmd.h"
-#include "parser.h"
+#include "vmctl.h"
static const char *socket_name = SOCKET_NAME;
-static const char *config_file = VMM_CONF;
+static const char *config_file = VMD_CONF;
static int ctl_sock = -1;
__dead void usage(void);
@@ -427,8 +427,9 @@ ctl_load(struct parse_result *res, int argc, char *argv[])
else if (argc > 2)
ctl_usage(res->ctl);
- /* parse configuration file options */
- return (parse_config(config_file));
+ /* XXX send message to vmd(8) to load the configuration */
+ errno = ENOSYS;
+ return (-1);
}
int
diff --git a/usr.sbin/vmmctl/vmmctl.8 b/usr.sbin/vmctl/vmctl.8
index 4d3242af17b..35d85819928 100644
--- a/usr.sbin/vmmctl/vmmctl.8
+++ b/usr.sbin/vmctl/vmctl.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: vmmctl.8,v 1.7 2015/11/27 09:11:39 reyk Exp $
+.\" $OpenBSD: vmctl.8,v 1.1 2015/12/03 21:45:45 reyk Exp $
.\"
.\" Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
.\"
@@ -14,12 +14,12 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: November 27 2015 $
-.Dt VMMCTL 8
+.Dd $Mdocdate: December 3 2015 $
+.Dt VMCTL 8
.Os
.Sh NAME
-.Nm vmmctl
-.Nd control VMM subsystem
+.Nm vmctl
+.Nd control the virtual machine daemon
.Sh SYNOPSIS
.Nm
.Op Fl s Ar socket
@@ -72,7 +72,7 @@ Stops (terminates) a VM defined by the specified VM
.El
.Sh FILES
.Bl -tag -width "/etc/var/run/vmd.sockXX" -compact
-.It Pa /etc/vmm.conf
+.It Pa /etc/vm.conf
Default configuration file.
.It Pa /var/run/vmd.sock
.Ux Ns -domain
@@ -80,7 +80,7 @@ socket used for communication with
.Xr vmd 8 .
.El
.Sh EXIT STATUS
-.Ex -std vmmctl
+.Ex -std vmctl
.Nm
may fail due to one of the following reasons:
.Pp
@@ -92,19 +92,19 @@ A requested VM-based operation could not be completed.
.El
.Sh EXAMPLES
Create a 4.5 Gigabyte disk image, disk.img:
-.Dl $ vmmctl create disk.img -s 4.5G
+.Dl $ vmctl create disk.img -s 4.5G
.Pp
Create a new VM with 512MB memory, one network interface, one disk image
('disk.img') and boot from kernel '/bsd':
.Bd -literal -offset indent
-$ vmmctl start "myvm" -m 512M -i 1 -d disk.img -k /bsd
+$ vmctl start "myvm" -m 512M -i 1 -d disk.img -k /bsd
.Ed
.Pp
Terminate VM number 1:
-.Dl $ vmmctl stop 1
+.Dl $ vmctl stop 1
.Sh SEE ALSO
.Xr vmm 4 ,
-.Xr vmm.conf 5 ,
+.Xr vm.conf 5 ,
.Xr rc.conf 8 ,
.Xr vmd 8
.Sh HISTORY
diff --git a/usr.sbin/vmmctl/vmmctl.c b/usr.sbin/vmctl/vmctl.c
index c547c0da164..5401f91cb3d 100644
--- a/usr.sbin/vmmctl/vmmctl.c
+++ b/usr.sbin/vmctl/vmctl.c
@@ -14,10 +14,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/*
- * vmmctl(8) - control VMM subsystem
- */
-
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/uio.h>
@@ -38,7 +34,7 @@
#include <unistd.h>
#include "vmd.h"
-#include "parser.h"
+#include "vmctl.h"
extern char *__progname;
uint32_t info_id;
diff --git a/usr.sbin/vmmctl/parser.h b/usr.sbin/vmctl/vmctl.h
index 73091d09d1b..4fdec6ea62c 100644
--- a/usr.sbin/vmmctl/parser.h
+++ b/usr.sbin/vmctl/vmctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.h,v 1.4 2015/12/01 20:52:44 halex Exp $ */
+/* $OpenBSD: vmctl.h,v 1.1 2015/12/03 21:45:45 reyk Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -19,10 +19,8 @@
#include <sys/queue.h>
#include <imsg.h>
-#ifndef VMMCTL_PARSER_H
-#define VMMCTL_PARSER_H
-
-#define VMM_CONF "/etc/vmm.conf"
+#ifndef VMCTL_PARSER_H
+#define VMCTL_PARSER_H
enum actions {
NONE,
@@ -67,11 +65,7 @@ int parse_vmid(struct parse_result *, char *, uint32_t);
void parse_free(struct parse_result *);
int parse(int, char *[]);
-/* parse.y */
-int parse_config(const char *);
-int cmdline_symset(char *);
-
-/* vmmctl.c */
+/* vmctl.c */
int create_imagefile(const char *, long);
int start_vm(const char *, int, int, int, char **, char *);
int start_vm_complete(struct imsg *, int *);
@@ -81,4 +75,4 @@ void get_info_vm(uint32_t);
int add_info(struct imsg *, int *);
void print_vm_info(struct vm_info_result *, size_t);
-#endif /* VMMCTL_PARSER_H */
+#endif /* VMCTL_PARSER_H */
diff --git a/usr.sbin/vmd/vm.conf.5 b/usr.sbin/vmd/vm.conf.5
index 355b50ed68f..f934b00015a 100644
--- a/usr.sbin/vmd/vm.conf.5
+++ b/usr.sbin/vmd/vm.conf.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: vm.conf.5,v 1.1 2015/12/03 16:11:32 reyk Exp $
+.\" $OpenBSD: vm.conf.5,v 1.2 2015/12/03 21:45:45 reyk Exp $
.\"
.\" Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
.\" Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -127,7 +127,7 @@ vm "vm2.example.com" {
.Sh SEE ALSO
.Xr vmm 4 ,
.Xr vmd 8 ,
-.Xr vmmctl 8
+.Xr vmctl 8
.Sh HISTORY
The
.Nm
diff --git a/usr.sbin/vmd/vmd.8 b/usr.sbin/vmd/vmd.8
index 95d0a684af1..8e267111056 100644
--- a/usr.sbin/vmd/vmd.8
+++ b/usr.sbin/vmd/vmd.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: vmd.8,v 1.4 2015/12/03 16:18:13 reyk Exp $
+.\" $OpenBSD: vmd.8,v 1.5 2015/12/03 21:45:45 reyk Exp $
.\"
.\" Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
.\"
@@ -31,7 +31,7 @@ is a daemon responsible for the execution of virtual machines (VMs) on a
host.
.Nm
is typically started at boot time and is controlled via
-.Xr vmmctl 8 .
+.Xr vmctl 8 .
.Pp
.Nm
can be enabled during system boot by setting the following in
@@ -53,7 +53,7 @@ driving the VM's operations using
.Pp
.Nm
is also responsible for proxying various other commands/requests from
-.Xr vmmctl 8 ,
+.Xr vmctl 8 ,
such as stopping VMs, and retrieving information from
.Xr vmm 4
about running VMs.
@@ -93,13 +93,13 @@ This is optional.
.It Pa /var/run/vmd.sock
.Ux Ns -domain
socket used for communication with
-.Xr vmmctl 8 .
+.Xr vmctl 8 .
.El
.Sh SEE ALSO
.Xr vmm 4 ,
.Xr vm.conf 5 ,
.Xr rc.conf 8 ,
-.Xr vmmctl 8
+.Xr vmctl 8
.Sh HISTORY
The
.Nm
diff --git a/usr.sbin/vmmctl/parse.y b/usr.sbin/vmmctl/parse.y
deleted file mode 100644
index 9461963a379..00000000000
--- a/usr.sbin/vmmctl/parse.y
+++ /dev/null
@@ -1,668 +0,0 @@
-/* $OpenBSD: parse.y,v 1.7 2015/12/03 08:52:29 reyk Exp $ */
-
-/*
- * Copyright (c) 2007-2015 Reyk Floeter <reyk@openbsd.org>
- * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
- * Copyright (c) 2004 Ryan McBride <mcbride@openbsd.org>
- * Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
- * Copyright (c) 2001 Markus Friedl. All rights reserved.
- * Copyright (c) 2001 Daniel Hartmeier. All rights reserved.
- * Copyright (c) 2001 Theo de Raadt. All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-%{
-#include <sys/types.h>
-#include <sys/queue.h>
-#include <sys/uio.h>
-
-#include <machine/vmmvar.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <stdarg.h>
-#include <string.h>
-#include <ctype.h>
-#include <netdb.h>
-#include <err.h>
-
-#include "vmd.h"
-#include "parser.h"
-
-TAILQ_HEAD(files, file) files = TAILQ_HEAD_INITIALIZER(files);
-static struct file {
- TAILQ_ENTRY(file) entry;
- FILE *stream;
- char *name;
- int lineno;
- int errors;
-} *file, *topfile;
-struct file *pushfile(const char *, int);
-int popfile(void);
-int yyparse(void);
-int yylex(void);
-int yyerror(const char *, ...)
- __attribute__((__format__ (printf, 1, 2)))
- __attribute__((__nonnull__ (1)));
-int kw_cmp(const void *, const void *);
-int lookup(char *);
-int lgetc(int);
-int lungetc(int);
-int findeol(void);
-
-TAILQ_HEAD(symhead, sym) symhead = TAILQ_HEAD_INITIALIZER(symhead);
-struct sym {
- TAILQ_ENTRY(sym) entry;
- int used;
- int persist;
- char *nam;
- char *val;
-};
-int symset(const char *, const char *, int);
-char *symget(const char *);
-
-struct parse_result res;
-static int errors = 0;
-
-typedef struct {
- union {
- int64_t number;
- char *string;
- } v;
- int lineno;
-} YYSTYPE;
-
-%}
-
-
-%token INCLUDE ERROR
-%token DISK NIFS PATH SIZE VMID
-%token ENABLE DISABLE VM KERNEL MEMORY
-%token <v.string> STRING
-%token <v.number> NUMBER
-%type <v.number> disable
-
-%%
-
-grammar : /* empty */
- | grammar include '\n'
- | grammar '\n'
- | grammar varset '\n'
- | grammar main '\n'
- | grammar error '\n' { file->errors++; }
- ;
-
-include : INCLUDE STRING {
- struct file *nfile;
-
- if ((nfile = pushfile($2, 0)) == NULL) {
- yyerror("failed to include file %s", $2);
- free($2);
- YYERROR;
- }
- free($2);
-
- file = nfile;
- lungetc('\n');
- }
- ;
-
-varset : STRING '=' STRING {
- if (symset($1, $3, 0) == -1)
- errx(1, "cannot store variable");
- free($1);
- free($3);
- }
- ;
-
-main : VM STRING {
- memset(&res, 0, sizeof(res));
- res.name = $2;
- res.nifs = -1;
- } '{' optnl vm_opts_l '}' {
- if (res.disable) {
- warnx("%s:%d: vm \"%s\" disabled",
- file->name, yylval.lineno, res.name);
- } else {
- res.action = CMD_START;
- if (vmmaction(&res) != 0)
- errx(1, "vmmaction");
- }
- }
- ;
-
-vm_opts_l : vm_opts_l vm_opts nl
- | vm_opts optnl
- ;
-
-vm_opts : disable {
- res.disable = $1;
- }
- | DISK STRING {
- if (parse_disk(&res, $2) != 0) {
- yyerror("failed to parse disks: %s", $2);
- free($2);
- YYERROR;
- }
- }
- | KERNEL STRING {
- if (res.path != NULL) {
- yyerror("argument specified more than once");
- YYERROR;
- }
- res.path = $2;
- }
- | NIFS NUMBER {
- if (res.nifs != -1) {
- yyerror("argument specified more than once");
- YYERROR;
- }
- if (parse_ifs(&res, NULL, $2) != 0) {
- yyerror("failed to parse interfaces: %lld", $2);
- YYERROR;
- }
- }
- | MEMORY NUMBER {
- if (res.size != 0) {
- yyerror("argument specified more than once");
- YYERROR;
- }
- if (parse_size(&res, NULL, $2) != 0) {
- yyerror("failed to parse size: %lld", $2);
- YYERROR;
- }
- }
- | MEMORY STRING {
- if (res.size != 0) {
- yyerror("argument specified more than once");
- YYERROR;
- }
- if (parse_size(&res, $2, 0) != 0) {
- yyerror("failed to parse size: %s", $2);
- free($2);
- YYERROR;
- }
- }
- ;
-
-disable : ENABLE { $$ = 0; }
- | DISABLE { $$ = 1; }
- ;
-
-optnl : '\n' optnl
- |
- ;
-
-nl : '\n' optnl
- ;
-
-%%
-
-struct keywords {
- const char *k_name;
- int k_val;
-};
-
-int
-yyerror(const char *fmt, ...)
-{
- va_list ap;
- char *msg;
-
- file->errors++;
- va_start(ap, fmt);
- if (vasprintf(&msg, fmt, ap) == -1)
- errx(1, "yyerror vasprintf");
- va_end(ap);
- warnx("%s:%d: %s", file->name, yylval.lineno, msg);
- free(msg);
- return (0);
-}
-
-int
-kw_cmp(const void *k, const void *e)
-{
- return (strcmp(k, ((const struct keywords *)e)->k_name));
-}
-
-int
-lookup(char *s)
-{
- /* this has to be sorted always */
- static const struct keywords keywords[] = {
- { "disable", DISABLE },
- { "disk", DISK },
- { "enable", ENABLE },
- { "id", VMID },
- { "include", INCLUDE },
- { "interfaces", NIFS },
- { "kernel", KERNEL },
- { "memory", MEMORY },
- { "size", SIZE },
- { "vm", VM }
- };
- const struct keywords *p;
-
- p = bsearch(s, keywords, sizeof(keywords)/sizeof(keywords[0]),
- sizeof(keywords[0]), kw_cmp);
-
- if (p)
- return (p->k_val);
- else
- return (STRING);
-}
-
-#define MAXPUSHBACK 128
-
-u_char *parsebuf;
-int parseindex;
-u_char pushback_buffer[MAXPUSHBACK];
-int pushback_index = 0;
-
-int
-lgetc(int quotec)
-{
- int c, next;
-
- if (parsebuf) {
- /* Read character from the parsebuffer instead of input. */
- if (parseindex >= 0) {
- c = parsebuf[parseindex++];
- if (c != '\0')
- return (c);
- parsebuf = NULL;
- } else
- parseindex++;
- }
-
- if (pushback_index)
- return (pushback_buffer[--pushback_index]);
-
- if (quotec) {
- if ((c = getc(file->stream)) == EOF) {
- yyerror("reached end of file while parsing "
- "quoted string");
- if (file == topfile || popfile() == EOF)
- return (EOF);
- return (quotec);
- }
- return (c);
- }
-
- while ((c = getc(file->stream)) == '\\') {
- next = getc(file->stream);
- if (next != '\n') {
- c = next;
- break;
- }
- yylval.lineno = file->lineno;
- file->lineno++;
- }
- if (c == '\t' || c == ' ') {
- /* Compress blanks to a single space. */
- do {
- c = getc(file->stream);
- } while (c == '\t' || c == ' ');
- ungetc(c, file->stream);
- c = ' ';
- }
-
- while (c == EOF) {
- if (file == topfile || popfile() == EOF)
- return (EOF);
- c = getc(file->stream);
- }
- return (c);
-}
-
-int
-lungetc(int c)
-{
- if (c == EOF)
- return (EOF);
- if (parsebuf) {
- parseindex--;
- if (parseindex >= 0)
- return (c);
- }
- if (pushback_index < MAXPUSHBACK-1)
- return (pushback_buffer[pushback_index++] = c);
- else
- return (EOF);
-}
-
-int
-findeol(void)
-{
- int c;
-
- parsebuf = NULL;
-
- /* skip to either EOF or the first real EOL */
- while (1) {
- if (pushback_index)
- c = pushback_buffer[--pushback_index];
- else
- c = lgetc(0);
- if (c == '\n') {
- file->lineno++;
- break;
- }
- if (c == EOF)
- break;
- }
- return (ERROR);
-}
-
-int
-yylex(void)
-{
- u_char buf[8096];
- u_char *p, *val;
- int quotec, next, c;
- int token;
-
-top:
- p = buf;
- while ((c = lgetc(0)) == ' ' || c == '\t')
- ; /* nothing */
-
- yylval.lineno = file->lineno;
- if (c == '#')
- while ((c = lgetc(0)) != '\n' && c != EOF)
- ; /* nothing */
- if (c == '$' && parsebuf == NULL) {
- while (1) {
- if ((c = lgetc(0)) == EOF)
- return (0);
-
- if (p + 1 >= buf + sizeof(buf) - 1) {
- yyerror("string too long");
- return (findeol());
- }
- if (isalnum(c) || c == '_') {
- *p++ = c;
- continue;
- }
- *p = '\0';
- lungetc(c);
- break;
- }
- val = symget(buf);
- if (val == NULL) {
- yyerror("macro '%s' not defined", buf);
- return (findeol());
- }
- parsebuf = val;
- parseindex = 0;
- goto top;
- }
-
- switch (c) {
- case '\'':
- case '"':
- quotec = c;
- while (1) {
- if ((c = lgetc(quotec)) == EOF)
- return (0);
- if (c == '\n') {
- file->lineno++;
- continue;
- } else if (c == '\\') {
- if ((next = lgetc(quotec)) == EOF)
- return (0);
- if (next == quotec || c == ' ' || c == '\t')
- c = next;
- else if (next == '\n') {
- file->lineno++;
- continue;
- } else
- lungetc(next);
- } else if (c == quotec) {
- *p = '\0';
- break;
- } else if (c == '\0') {
- yyerror("syntax error");
- return (findeol());
- }
- if (p + 1 >= buf + sizeof(buf) - 1) {
- yyerror("string too long");
- return (findeol());
- }
- *p++ = c;
- }
- yylval.v.string = strdup(buf);
- if (yylval.v.string == NULL)
- err(1, "yylex: strdup");
- return (STRING);
- }
-
-#define allowed_to_end_number(x) \
- (isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' || x == '=')
-
- if (c == '-' || isdigit(c)) {
- do {
- *p++ = c;
- if ((unsigned)(p-buf) >= sizeof(buf)) {
- yyerror("string too long");
- return (findeol());
- }
- } while ((c = lgetc(0)) != EOF && isdigit(c));
- lungetc(c);
- if (p == buf + 1 && buf[0] == '-')
- goto nodigits;
- if (c == EOF || allowed_to_end_number(c)) {
- const char *errstr = NULL;
-
- *p = '\0';
- yylval.v.number = strtonum(buf, LLONG_MIN,
- LLONG_MAX, &errstr);
- if (errstr) {
- yyerror("\"%s\" invalid number: %s",
- buf, errstr);
- return (findeol());
- }
- return (NUMBER);
- } else {
-nodigits:
- while (p > buf + 1)
- lungetc(*--p);
- c = *--p;
- if (c == '-')
- return (c);
- }
- }
-
-#define allowed_in_string(x) \
- (isalnum(x) || (ispunct(x) && x != '(' && x != ')' && \
- x != '{' && x != '}' && \
- x != '!' && x != '=' && x != '#' && \
- x != ','))
-
- if (isalnum(c) || c == ':' || c == '_') {
- do {
- *p++ = c;
- if ((unsigned)(p-buf) >= sizeof(buf)) {
- yyerror("string too long");
- return (findeol());
- }
- } while ((c = lgetc(0)) != EOF && (allowed_in_string(c)));
- lungetc(c);
- *p = '\0';
- if ((token = lookup(buf)) == STRING)
- if ((yylval.v.string = strdup(buf)) == NULL)
- err(1, "yylex: strdup");
- return (token);
- }
- if (c == '\n') {
- yylval.lineno = file->lineno;
- file->lineno++;
- }
- if (c == EOF)
- return (0);
- return (c);
-}
-
-struct file *
-pushfile(const char *name, int secret)
-{
- struct file *nfile;
-
- if ((nfile = calloc(1, sizeof(struct file))) == NULL) {
- warn("malloc");
- return (NULL);
- }
- if ((nfile->name = strdup(name)) == NULL) {
- warn("malloc");
- free(nfile);
- return (NULL);
- }
- if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
- warn("%s", nfile->name);
- free(nfile->name);
- free(nfile);
- return (NULL);
- }
- nfile->lineno = 1;
- TAILQ_INSERT_TAIL(&files, nfile, entry);
- return (nfile);
-}
-
-int
-popfile(void)
-{
- struct file *prev;
-
- if ((prev = TAILQ_PREV(file, files, entry)) != NULL)
- prev->errors += file->errors;
-
- TAILQ_REMOVE(&files, file, entry);
- fclose(file->stream);
- free(file->name);
- free(file);
- file = prev;
- return (file ? 0 : EOF);
-}
-
-int
-parse_config(const char *filename)
-{
- struct sym *sym, *next;
-
- if ((file = pushfile(filename, 0)) == NULL) {
- return (-1);
- }
- topfile = file;
- setservent(1);
-
- yyparse();
- errors = file->errors;
- popfile();
-
- endservent();
-
- /* Free macros and check which have not been used. */
- for (sym = TAILQ_FIRST(&symhead); sym != NULL; sym = next) {
- next = TAILQ_NEXT(sym, entry);
- if (!sym->used)
- fprintf(stderr, "warning: macro '%s' not "
- "used\n", sym->nam);
- if (!sym->persist) {
- free(sym->nam);
- free(sym->val);
- TAILQ_REMOVE(&symhead, sym, entry);
- free(sym);
- }
- }
-
- if (errors)
- return (-1);
-
- return (0);
-}
-
-int
-symset(const char *nam, const char *val, int persist)
-{
- struct sym *sym;
-
- for (sym = TAILQ_FIRST(&symhead); sym && strcmp(nam, sym->nam);
- sym = TAILQ_NEXT(sym, entry))
- ; /* nothing */
-
- if (sym != NULL) {
- if (sym->persist == 1)
- return (0);
- else {
- free(sym->nam);
- free(sym->val);
- TAILQ_REMOVE(&symhead, sym, entry);
- free(sym);
- }
- }
- if ((sym = calloc(1, sizeof(*sym))) == NULL)
- return (-1);
-
- sym->nam = strdup(nam);
- if (sym->nam == NULL) {
- free(sym);
- return (-1);
- }
- sym->val = strdup(val);
- if (sym->val == NULL) {
- free(sym->nam);
- free(sym);
- return (-1);
- }
- sym->used = 0;
- sym->persist = persist;
- TAILQ_INSERT_TAIL(&symhead, sym, entry);
- return (0);
-}
-
-int
-cmdline_symset(char *s)
-{
- char *sym, *val;
- int ret;
- size_t len;
-
- if ((val = strrchr(s, '=')) == NULL)
- return (-1);
-
- len = (val - s) + 1;
- if ((sym = malloc(len)) == NULL)
- errx(1, "cmdline_symset: malloc");
-
- (void)strlcpy(sym, s, len);
-
- ret = symset(sym, val + 1, 1);
- free(sym);
-
- return (ret);
-}
-
-char *
-symget(const char *nam)
-{
- struct sym *sym;
-
- TAILQ_FOREACH(sym, &symhead, entry)
- if (strcmp(nam, sym->nam) == 0) {
- sym->used = 1;
- return (sym->val);
- }
- return (NULL);
-}
diff --git a/usr.sbin/vmmctl/vmm.conf.5 b/usr.sbin/vmmctl/vmm.conf.5
deleted file mode 100644
index 6223f83f5ad..00000000000
--- a/usr.sbin/vmmctl/vmm.conf.5
+++ /dev/null
@@ -1,140 +0,0 @@
-.\" $OpenBSD: vmm.conf.5,v 1.7 2015/11/27 09:11:39 reyk Exp $
-.\"
-.\" Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
-.\" Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
-.\"
-.\" Permission to use, copy, modify, and distribute this software for any
-.\" purpose with or without fee is hereby granted, provided that the above
-.\" copyright notice and this permission notice appear in all copies.
-.\"
-.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-.\"
-.Dd $Mdocdate: November 27 2015 $
-.Dt VMM.CONF 5
-.Os
-.Sh NAME
-.Nm vmm.conf
-.Nd virtual machine configuration
-.Sh DESCRIPTION
-.Nm
-is the configuration file to configure the virtual machine monitor
-(VMM) subsystem.
-A VMM manages virtual machines (VMs) on a
-.Ar host .
-The VMM subsystem is responsible for creating, destroying, and
-executing VMs.
-.Sh SECTIONS
-.Nm
-is divided into three main sections:
-.Bl -tag -width xxxx
-.It Sy Macros
-User-defined variables may be defined and used later, simplifying the
-configuration file.
-.It Sy VM Configuration
-Configuration for each individual virtual machine.
-.El
-.Pp
-Within the sections,
-the
-.Ar bytes
-argument can be specified with a human-readable scale,
-using the format described in
-.Xr scan_scaled 3 .
-.Pp
-The current line can be extended over multiple lines using a backslash
-.Pq Sq \e .
-Comments can be put anywhere in the file using a hash mark
-.Pq Sq # ,
-and extend to the end of the current line.
-Care should be taken when commenting out multi-line text:
-the comment is effective until the end of the entire block.
-.Pp
-Argument names not beginning with a letter, digit, or underscore
-must be quoted.
-.Pp
-Additional configuration files can be included with the
-.Ic include
-keyword, for example:
-.Bd -literal -offset indent
-include "/etc/vm1.example.com.conf"
-.Ed
-.Sh MACROS
-Macros can be defined that will later be expanded in context.
-Macro names must start with a letter, digit, or underscore,
-and may contain any of those characters.
-Macro names may not be reserved words (for example,
-.Ic vm ,
-.Ic memory ,
-or
-.Ic disk ) .
-Macros are not expanded inside quotes.
-.Pp
-For example:
-.Bd -literal -offset indent
-ramdisk="/bsd.rd"
-vm "vm1.example.com" {
- memory 512M
- kernel $ramdisk
-}
-.Ed
-.Sh VM CONFIGURATION
-Each
-.Ic vm
-section starts with a declaration of the virtual machine
-.Ar name :
-.Bl -tag -width Ds
-.It Ic vm Ar name Brq ...
-This name can be any string, and is typically a hostname.
-.El
-.Pp
-Followed by a block of parameters that is enclosed in curly brackets:
-.Bl -tag -width Ds
-.It Cm enable
-Automatically start the VM.
-This is the default if neither
-.Cm enable
-nor
-.Cm disable
-is specified.
-.It Cm disable
-Do not start this VM.
-.It Cm disk Ar path
-Disk image file (may be specified multiple times to add multiple disk images).
-.It Cm kernel Ar path
-Kernel to load when booting the VM.
-.It Cm memory Ar bytes
-Memory size of the VM, in bytes, rounded to megabytes.
-.It Cm interfaces Ar count
-Number of network interfaces to add to the VM.
-.El
-.Sh EXAMPLES
-Create a new VM with 512MB memory, 1 network interface, one disk image
-('disk.img') and boot from kernel '/bsd':
-.Bd -literal -offset indent
-vm "vm2.example.com" {
- memory 512M
- interfaces 1
- disk "/var/vmm/vm2-disk.img"
- kernel "/bsd"
-}
-.Ed
-.Sh SEE ALSO
-.Xr vmm 4 ,
-.Xr vmd 8 ,
-.Xr vmmctl 8
-.Sh HISTORY
-The
-.Nm
-file format first appeared in
-.Ox 5.9 .
-.Sh AUTHORS
-.An -nosplit
-.An Mike Larkin Aq Mt mlarkin@openbsd.org
-and
-.An Reyk Floeter Aq Mt reyk@openbsd.org .