With the hv_config() now in, `ldomctl init-system -n ldom.conf' to only
parse configuration is trivial.
It is usable as unprivileged user, no devices are touched.
If errors occur, errors will be generated and ldomctl exits; if all is
valid, this prints "configuration OK" just like vmd(8) does.
I have plans for additional ldom.conf(5) options and -n greatly aids
development, but I also prefer to (double) check configs before loading
them as root in general.
Feedback? OK?
? default.diff
? disk.diff
? download.diff
? msg
? n.diff
? owner.diff
? parse.y.new
Index: config.c
===================================================================
RCS file: /cvs/src/usr.sbin/ldomctl/config.c,v
retrieving revision 1.29
diff -u -p -r1.29 config.c
--- config.c 28 Nov 2019 18:40:42 -0000 1.29
+++ config.c 3 Jan 2020 20:45:33 -0000
@@ -2759,7 +2759,7 @@ primary_init(void)
}
void
-build_config(const char *filename)
+build_config(const char *filename, int noaction)
{
struct guest *primary;
struct guest *guest;
@@ -2781,6 +2781,10 @@ build_config(const char *filename)
SIMPLEQ_INIT(&conf.domain_list);
if (parse_config(filename, &conf) < 0)
exit(1);
+ if (noaction) {
+ fprintf(stderr, "configuration OK\n");
+ exit(0);
+ }
pri = md_read("pri");
if (pri == NULL)
Index: ldomctl.8
===================================================================
RCS file: /cvs/src/usr.sbin/ldomctl/ldomctl.8,v
retrieving revision 1.21
diff -u -p -r1.21 ldomctl.8
--- ldomctl.8 30 Dec 2019 20:10:48 -0000 1.21
+++ ldomctl.8 3 Jan 2020 20:45:33 -0000
@@ -63,12 +63,17 @@ The download is aborted if a configurati
.It Cm dump
Dump the current configuration from non-volatile storage into the current
working directory.
-.It Cm init-system Ar file
+.It Cm init-system Oo Fl n Oc Ar file
Generate files in the current working directory for a logical domain
configuration
.Ar file
as described in
.Xr ldom.conf 5 .
+.Bl -tag -width Fl
+.It Fl n
+Configtest mode.
+Only check the configuration file for validty.
+.El
.It Cm list
List configurations stored in non-volatile storage.
Indicate the currently running configuration,
Index: ldomctl.c
===================================================================
RCS file: /cvs/src/usr.sbin/ldomctl/ldomctl.c,v
retrieving revision 1.32
diff -u -p -r1.32 ldomctl.c
--- ldomctl.c 3 Jan 2020 19:45:51 -0000 1.32
+++ ldomctl.c 3 Jan 2020 20:45:34 -0000
@@ -129,7 +129,7 @@ usage(void)
fprintf(stderr, "usage:\t%1$s delete|select configuration\n"
"\t%1$s download directory\n"
"\t%1$s dump|list|list-io\n"
- "\t%1$s init-system file\n"
+ "\t%1$s init-system [-n] file\n"
"\t%1$s create-vdisk -s size file\n"
"\t%1$s console|panic|start|status|stop [domain]\n", getprogname());
exit(EXIT_FAILURE);
@@ -241,12 +241,27 @@ dump(int argc, char **argv)
void
init_system(int argc, char **argv)
{
- if (argc != 2)
+ int ch, noaction = 0;
+
+ while ((ch = getopt(argc, argv, "n")) != -1) {
+ switch (ch) {
+ case 'n':
+ noaction = 1;
+ break;
+ default:
+ usage();
+ }
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (argc != 1)
usage();
- hv_config();
+ if (!noaction)
+ hv_config();
- build_config(argv[1]);
+ build_config(argv[0], noaction);
}
void
Index: ldomctl.h
===================================================================
RCS file: /cvs/src/usr.sbin/ldomctl/ldomctl.h,v
retrieving revision 1.11
diff -u -p -r1.11 ldomctl.h
--- ldomctl.h 28 Nov 2019 18:03:33 -0000 1.11
+++ ldomctl.h 3 Jan 2020 20:45:34 -0000
@@ -193,5 +193,5 @@ struct ldom_config {
};
int parse_config(const char *, struct ldom_config *);
-void build_config(const char *);
+void build_config(const char *, int);
void list_components(void);