From: reyk Date: Thu, 18 Dec 2014 19:18:22 +0000 (+0000) Subject: The VM host might send multiple messages at once but vmt(4) only X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=61285d8494d86cbb80affe96fa24db00e4b5468b;p=openbsd The VM host might send multiple messages at once but vmt(4) only processed one of time per second. Change the code to process all queued messages without delay immediately. This fixes two things: a) the vmt time sensor is available on boot when ntpd -s is loaded and b) the random seeding on resume (OS_Resume message) is executed almost immediately and not delayed by about 20 seconds. ok deraadt@ --- diff --git a/sys/dev/vmt.c b/sys/dev/vmt.c index 76346d31176..500552f70b2 100644 --- a/sys/dev/vmt.c +++ b/sys/dev/vmt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmt.c,v 1.21 2014/12/18 16:30:29 deraadt Exp $ */ +/* $OpenBSD: vmt.c,v 1.22 2014/12/18 19:18:22 reyk Exp $ */ /* * Copyright (c) 2007 David Crawshaw @@ -492,6 +492,10 @@ vmt_tclo_tick(void *xarg) struct vmt_softc *sc = xarg; u_int32_t rlen; u_int16_t ack; + int delay; + + /* By default, poll every second for new messages */ + delay = 1; /* reopen tclo channel if it's currently closed */ if (sc->sc_tclo_rpc.channel == 0 && @@ -541,6 +545,9 @@ vmt_tclo_tick(void *xarg) } sc->sc_tclo_ping = 0; + /* The VM host can queue multiple messages; continue without delay */ + delay = 0; + if (strcmp(sc->sc_rpc_buf, "reset") == 0) { if (sc->sc_rpc_error != 0) { @@ -681,8 +688,13 @@ vmt_tclo_tick(void *xarg) } } + if (sc->sc_rpc_error == 1) { + /* On error, give time to recover and wait a second */ + delay = 1; + } + out: - timeout_add_sec(&sc->sc_tclo_tick, 1); + timeout_add_sec(&sc->sc_tclo_tick, delay); } #define BACKDOOR_OP_I386(op, frame) \