From 8eb2436863ca6d5d4fc68d9d8d13c320d56dc973 Mon Sep 17 00:00:00 2001 From: kn Date: Fri, 22 May 2020 21:40:17 +0000 Subject: Make "init-system -n" check vcpu and memory constraints kmos noted that "-n" wouldn't bark at overallocation, only running without it would do so. Hoit setup code and delay the noaction bailout just after constraint checks such that they're always done. OK kmos --- usr.sbin/ldomctl/config.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'usr.sbin/ldomctl') diff --git a/usr.sbin/ldomctl/config.c b/usr.sbin/ldomctl/config.c index 8c5486da04f..33506c36bf3 100644 --- a/usr.sbin/ldomctl/config.c +++ b/usr.sbin/ldomctl/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.36 2020/03/17 21:24:22 kn Exp $ */ +/* $OpenBSD: config.c,v 1.37 2020/05/22 21:40:16 kn Exp $ */ /* * Copyright (c) 2012, 2018 Mark Kettenis @@ -2792,18 +2792,6 @@ build_config(const char *filename, int noaction) SIMPLEQ_INIT(&conf.domain_list); if (parse_config(filename, &conf) < 0) exit(1); - if (noaction) - exit(0); - - pri = md_read("pri"); - if (pri == NULL) - err(1, "unable to get PRI"); - hvmd = md_read("hv.md"); - if (hvmd == NULL) - err(1, "unable to get Hypervisor MD"); - - pri_init(pri); - pri_alloc_memory(hv_membase, hv_memsize); SIMPLEQ_FOREACH(domain, &conf.domain_list, entry) { if (strcmp(domain->name, "primary") == 0) { @@ -2823,6 +2811,19 @@ build_config(const char *filename, int noaction) if (memory > total_memory || primary_memory == 0) errx(1, "not enough memory available"); + if (noaction) + exit(0); + + pri = md_read("pri"); + if (pri == NULL) + err(1, "unable to get PRI"); + hvmd = md_read("hv.md"); + if (hvmd == NULL) + err(1, "unable to get Hypervisor MD"); + + pri_init(pri); + pri_alloc_memory(hv_membase, hv_memsize); + hvmd_init(hvmd); primary = primary_init(); -- cgit v1.2.3