summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkn <kn@openbsd.org>2019-11-28 18:40:42 +0000
committerkn <kn@openbsd.org>2019-11-28 18:40:42 +0000
commitd73a4c4fb3962df1e72dd6910861075eabc6a1c3 (patch)
tree570d98c592ad83e8a094b47d028a1aa0f966fd0d
parentimprove on previous to only use the required CRLs. (diff)
downloadwireguard-openbsd-d73a4c4fb3962df1e72dd6910861075eabc6a1c3.tar.xz
wireguard-openbsd-d73a4c4fb3962df1e72dd6910861075eabc6a1c3.zip
Use scan_scaled(3) for memory in ldom.conf
Replace the hand-written routing with a proper library allowing even more formats. Since ldomctl's local util.h conflicts with the now used global util.h from libutil, rename it to ldom_util.h. Manual wording from amd64's vm.conf(5). OK kettenis
-rw-r--r--usr.sbin/ldomctl/Makefile4
-rw-r--r--usr.sbin/ldomctl/config.c4
-rw-r--r--usr.sbin/ldomctl/ldom.conf.512
-rw-r--r--usr.sbin/ldomctl/ldom_util.h (renamed from usr.sbin/ldomctl/util.h)2
-rw-r--r--usr.sbin/ldomctl/ldomctl.c4
-rw-r--r--usr.sbin/ldomctl/mdesc.c4
-rw-r--r--usr.sbin/ldomctl/mdstore.c4
-rw-r--r--usr.sbin/ldomctl/parse.y24
-rw-r--r--usr.sbin/ldomctl/pri.c4
-rw-r--r--usr.sbin/ldomctl/util.c4
-rw-r--r--usr.sbin/ldomd/ds.c4
-rw-r--r--usr.sbin/ldomd/ldomd.c4
-rw-r--r--usr.sbin/ldomd/var-config.c4
13 files changed, 35 insertions, 43 deletions
diff --git a/usr.sbin/ldomctl/Makefile b/usr.sbin/ldomctl/Makefile
index 931eddcbcca..bf4686a9abd 100644
--- a/usr.sbin/ldomctl/Makefile
+++ b/usr.sbin/ldomctl/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.10 2019/11/20 18:11:28 kn Exp $
+# $OpenBSD: Makefile,v 1.11 2019/11/28 18:40:42 kn Exp $
.if ${MACHINE} == "sparc64"
@@ -8,6 +8,8 @@ PROG= ldomctl
SRCS= ldomctl.c ds.c mdesc.c util.c mdstore.c pri.c config.c parse.y
CFLAGS+=-Wall
CFLAGS+=-I${.CURDIR}/../ldomd -I${.CURDIR}
+LDADD+= -lutil
+DPADD+= ${LIBUTIL}
.else
diff --git a/usr.sbin/ldomctl/config.c b/usr.sbin/ldomctl/config.c
index d8d930264bb..952d34b8791 100644
--- a/usr.sbin/ldomctl/config.c
+++ b/usr.sbin/ldomctl/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.28 2019/11/27 19:54:10 kn Exp $ */
+/* $OpenBSD: config.c,v 1.29 2019/11/28 18:40:42 kn Exp $ */
/*
* Copyright (c) 2012, 2018 Mark Kettenis
@@ -28,7 +28,7 @@
#include "mdesc.h"
#include "ldomctl.h"
-#include "util.h"
+#include "ldom_util.h"
#define LDC_GUEST 0
#define LDC_HV 1
diff --git a/usr.sbin/ldomctl/ldom.conf.5 b/usr.sbin/ldomctl/ldom.conf.5
index ec8ac13ad3d..0c478b74fed 100644
--- a/usr.sbin/ldomctl/ldom.conf.5
+++ b/usr.sbin/ldomctl/ldom.conf.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ldom.conf.5,v 1.6 2019/08/05 19:27:47 kettenis Exp $
+.\" $OpenBSD: ldom.conf.5,v 1.7 2019/11/28 18:40:42 kn Exp $
.\"
.\" Copyright (c) 2012 Mark Kettenis <kettenis@openbsd.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: August 5 2019 $
+.Dd $Mdocdate: November 28 2019 $
.Dt LDOM.CONF 5 sparc64
.Os
.Sh NAME
@@ -41,10 +41,12 @@ Declare the number of virtual CPUs assigned to a domain.
Optionally a stride can be specified to allocate additional virtual CPUs
but not assign them to a domain.
This can be used to distribute virtual CPUs over the available CPU cores.
-.It Ic memory Ar number Ns Op Ar unit
+.It Ic memory Ar bytes
Declare the amount of memory assigned to a domain, in bytes.
-Optionally, the units 'K', 'M', or 'G', for kilo-, mega-, and gigabytes
-can be used.
+.Ar bytes
+can be specified with a human-readable scale, using the format described in
+.Xr scan_scaled 3 ,
+e.g. 512M.
.It Ic iodevice Ar path
Assign the specified PCIe device to the guest domain.
This keyword can be used multiple times.
diff --git a/usr.sbin/ldomctl/util.h b/usr.sbin/ldomctl/ldom_util.h
index 873de0a1011..8374a734594 100644
--- a/usr.sbin/ldomctl/util.h
+++ b/usr.sbin/ldomctl/ldom_util.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.h,v 1.4 2014/10/15 21:37:27 deraadt Exp $ */
+/* $OpenBSD: ldom_util.h,v 1.1 2019/11/28 18:40:42 kn Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
diff --git a/usr.sbin/ldomctl/ldomctl.c b/usr.sbin/ldomctl/ldomctl.c
index d501257865f..359f8b8c571 100644
--- a/usr.sbin/ldomctl/ldomctl.c
+++ b/usr.sbin/ldomctl/ldomctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldomctl.c,v 1.26 2019/11/28 18:03:33 kn Exp $ */
+/* $OpenBSD: ldomctl.c,v 1.27 2019/11/28 18:40:42 kn Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
@@ -29,7 +29,7 @@
#include "hvctl.h"
#include "mdstore.h"
#include "mdesc.h"
-#include "util.h"
+#include "ldom_util.h"
#include "ldomctl.h"
extern struct ds_service pri_service;
diff --git a/usr.sbin/ldomctl/mdesc.c b/usr.sbin/ldomctl/mdesc.c
index ddad9483b3d..3cae1f7d9b0 100644
--- a/usr.sbin/ldomctl/mdesc.c
+++ b/usr.sbin/ldomctl/mdesc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdesc.c,v 1.12 2019/07/14 14:40:55 kettenis Exp $ */
+/* $OpenBSD: mdesc.c,v 1.13 2019/11/28 18:40:42 kn Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
@@ -25,7 +25,7 @@
#include <string.h>
#include "mdesc.h"
-#include "util.h"
+#include "ldom_util.h"
struct md_name *
md_find_name(struct md *md, const char *str)
diff --git a/usr.sbin/ldomctl/mdstore.c b/usr.sbin/ldomctl/mdstore.c
index 946679b920c..ff6f3c910e5 100644
--- a/usr.sbin/ldomctl/mdstore.c
+++ b/usr.sbin/ldomctl/mdstore.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdstore.c,v 1.11 2019/07/07 14:45:15 kettenis Exp $ */
+/* $OpenBSD: mdstore.c,v 1.12 2019/11/28 18:40:42 kn Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
@@ -26,7 +26,7 @@
#include "ds.h"
#include "mdesc.h"
#include "mdstore.h"
-#include "util.h"
+#include "ldom_util.h"
#include "ldomctl.h"
void mdstore_start(struct ldc_conn *, uint64_t);
diff --git a/usr.sbin/ldomctl/parse.y b/usr.sbin/ldomctl/parse.y
index 7cd42f15566..6306d6cb9d4 100644
--- a/usr.sbin/ldomctl/parse.y
+++ b/usr.sbin/ldomctl/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.12 2019/08/05 19:27:47 kettenis Exp $ */
+/* $OpenBSD: parse.y,v 1.13 2019/11/28 18:40:42 kn Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis <kettenis@openbsd.org>
@@ -37,9 +37,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <util.h>
#include "ldomctl.h"
-#include "util.h"
+#include "ldom_util.h"
TAILQ_HEAD(files, file) files = TAILQ_HEAD_INITIALIZER(files);
static struct file {
@@ -236,23 +237,10 @@ memory : NUMBER {
$$ = $1;
}
| STRING {
- uint64_t size;
- char *cp;
-
- size = strtoll($1, &cp, 10);
- if (cp != NULL) {
- if (strcmp(cp, "K") == 0)
- size *= 1024;
- else if (strcmp(cp, "M") == 0)
- size *= 1024 * 1024;
- else if (strcmp(cp, "G") == 0)
- size *= 1024 * 1024 * 1024;
- else {
- yyerror("unknown unit %s", cp);
- YYERROR;
- }
+ if (scan_scaled($1, &$$) == -1) {
+ yyerror("invalid size: %s", $1);
+ YYERROR;
}
- $$ = size;
}
;
diff --git a/usr.sbin/ldomctl/pri.c b/usr.sbin/ldomctl/pri.c
index 66fdf48b242..94d8bb11775 100644
--- a/usr.sbin/ldomctl/pri.c
+++ b/usr.sbin/ldomctl/pri.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pri.c,v 1.1 2012/11/04 19:04:11 kettenis Exp $ */
+/* $OpenBSD: pri.c,v 1.2 2019/11/28 18:40:42 kn Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
@@ -21,7 +21,7 @@
#include "ds.h"
#include "mdesc.h"
-#include "util.h"
+#include "ldom_util.h"
void pri_start(struct ldc_conn *, uint64_t);
void pri_rx_data(struct ldc_conn *, uint64_t, void *, size_t);
diff --git a/usr.sbin/ldomctl/util.c b/usr.sbin/ldomctl/util.c
index eb160b32bd0..516369a0e75 100644
--- a/usr.sbin/ldomctl/util.c
+++ b/usr.sbin/ldomctl/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.4 2014/10/15 21:37:27 deraadt Exp $ */
+/* $OpenBSD: util.c,v 1.5 2019/11/28 18:40:42 kn Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
@@ -22,7 +22,7 @@
#include <stdlib.h>
#include <string.h>
-#include "util.h"
+#include "ldom_util.h"
int debug;
diff --git a/usr.sbin/ldomd/ds.c b/usr.sbin/ldomd/ds.c
index 0be1c72c15b..9aa19a480d1 100644
--- a/usr.sbin/ldomd/ds.c
+++ b/usr.sbin/ldomd/ds.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ds.c,v 1.9 2019/10/20 16:18:36 kettenis Exp $ */
+/* $OpenBSD: ds.c,v 1.10 2019/11/28 18:40:42 kn Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
@@ -27,7 +27,7 @@
#include <unistd.h>
#include "ds.h"
-#include "util.h"
+#include "ldom_util.h"
void ldc_rx_ctrl_vers(struct ldc_conn *, struct ldc_pkt *);
void ldc_rx_ctrl_rtr(struct ldc_conn *, struct ldc_pkt *);
diff --git a/usr.sbin/ldomd/ldomd.c b/usr.sbin/ldomd/ldomd.c
index db5e6bf5fbd..50f41c1631b 100644
--- a/usr.sbin/ldomd/ldomd.c
+++ b/usr.sbin/ldomd/ldomd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldomd.c,v 1.9 2019/09/29 17:10:00 deraadt Exp $ */
+/* $OpenBSD: ldomd.c,v 1.10 2019/11/28 18:40:42 kn Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
@@ -34,7 +34,7 @@
#include "ds.h"
#include "hvctl.h"
#include "mdesc.h"
-#include "util.h"
+#include "ldom_util.h"
#include "ldomd.h"
TAILQ_HEAD(guest_head, guest) guests;
diff --git a/usr.sbin/ldomd/var-config.c b/usr.sbin/ldomd/var-config.c
index b0c0687af6a..b3cabb079c9 100644
--- a/usr.sbin/ldomd/var-config.c
+++ b/usr.sbin/ldomd/var-config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: var-config.c,v 1.2 2012/10/27 20:51:42 kettenis Exp $ */
+/* $OpenBSD: var-config.c,v 1.3 2019/11/28 18:40:42 kn Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
@@ -29,7 +29,7 @@
#include "ds.h"
#include "mdesc.h"
-#include "util.h"
+#include "ldom_util.h"
#include "ldomd.h"
void var_config_start(struct ldc_conn *, uint64_t);