diff options
author | pd <pd@cvs.openbsd.org> | 2019-12-12 03:53:39 +0000 |
---|---|---|
committer | pd <pd@cvs.openbsd.org> | 2019-12-12 03:53:39 +0000 |
commit | de2bcacdc0c2351ed03b993ac6d1367f62243ff3 (patch) | |
tree | f447721d7c43063ed5d246e26f2741ffb11ae6a4 /usr.sbin/vmd/parse.y | |
parent | 4c41d600f210db58568c1c4650913cf9e8d34c0b (diff) |
vmd: start vms defined in vm.conf in a staggered fashion
This addresses 'thundering herd' problem when a lot of
vms are configured in vm.conf. A lot of vms booting in parallel can
overload the host and also mess up tsc calibration in openbsd guests as
it uses PIT which doesn't fire reliably if the host is overloaded.
We default to starting vms with parallelism of ncpuonline and a delay 30 seconds
between batches. This is configurable in vm.conf.
ok mlarkin@ (also addressed comments from cheloha@)
Diffstat (limited to 'usr.sbin/vmd/parse.y')
-rw-r--r-- | usr.sbin/vmd/parse.y | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/usr.sbin/vmd/parse.y b/usr.sbin/vmd/parse.y index 81cfa04d466..8b323af25c4 100644 --- a/usr.sbin/vmd/parse.y +++ b/usr.sbin/vmd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.52 2019/05/14 06:05:45 anton Exp $ */ +/* $OpenBSD: parse.y,v 1.53 2019/12/12 03:53:38 pd Exp $ */ /* * Copyright (c) 2007-2016 Reyk Floeter <reyk@openbsd.org> @@ -122,7 +122,8 @@ typedef struct { %token INCLUDE ERROR %token ADD ALLOW BOOT CDROM DEVICE DISABLE DISK DOWN ENABLE FORMAT GROUP %token INET6 INSTANCE INTERFACE LLADDR LOCAL LOCKED MEMORY NET NIFS OWNER -%token PATH PREFIX RDOMAIN SIZE SOCKET SWITCH UP VM VMID +%token PATH PREFIX RDOMAIN SIZE SOCKET SWITCH UP VM VMID STAGGERED START +%token PARALLEL DELAY %token <v.number> NUMBER %token <v.string> STRING %type <v.lladdr> lladdr @@ -217,6 +218,11 @@ main : LOCAL INET6 { env->vmd_ps.ps_csock.cs_uid = $3.uid; env->vmd_ps.ps_csock.cs_gid = $3.gid == -1 ? 0 : $3.gid; } + | STAGGERED START PARALLEL NUMBER DELAY NUMBER { + env->vmd_cfg.cfg_flags |= VMD_CFG_STAGGERED_START; + env->vmd_cfg.delay.tv_sec = $6; + env->vmd_cfg.parallelism = $4; + } ; switch : SWITCH string { @@ -368,6 +374,8 @@ vm : VM string vm_instance { } else { if (vcp_disable) vm->vm_state |= VM_STATE_DISABLED; + else + vm->vm_state |= VM_STATE_WAITING; log_debug("%s:%d: vm \"%s\" " "registered (%s)", file->name, yylval.lineno, @@ -766,6 +774,7 @@ lookup(char *s) { "allow", ALLOW }, { "boot", BOOT }, { "cdrom", CDROM }, + { "delay", DELAY }, { "device", DEVICE }, { "disable", DISABLE }, { "disk", DISK }, @@ -785,10 +794,13 @@ lookup(char *s) { "memory", MEMORY }, { "net", NET }, { "owner", OWNER }, + { "parallel", PARALLEL }, { "prefix", PREFIX }, { "rdomain", RDOMAIN }, { "size", SIZE }, { "socket", SOCKET }, + { "staggered", STAGGERED }, + { "start", START }, { "switch", SWITCH }, { "up", UP }, { "vm", VM } |