From: kn Date: Thu, 10 Aug 2023 07:50:45 +0000 (+0000) Subject: Make stopped ldom utilization appear as zero X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=116f3cbfa99016305486ec0c1fc58090ee6bb7d6;p=openbsd Make stopped ldom utilization appear as zero ldomctl(8) 'status' updated the value only on running guests, i.e. stopped ones repeated the last ones instead of showing zero. Always reset per guest before updating it, From Koakuma, thanks! --- diff --git a/usr.sbin/ldomctl/ldomctl.c b/usr.sbin/ldomctl/ldomctl.c index e48a560f7db..78dfdb320f0 100644 --- a/usr.sbin/ldomctl/ldomctl.c +++ b/usr.sbin/ldomctl/ldomctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldomctl.c,v 1.40 2021/10/24 21:24:18 deraadt Exp $ */ +/* $OpenBSD: ldomctl.c,v 1.41 2023/08/10 07:50:45 kn Exp $ */ /* * Copyright (c) 2012 Mark Kettenis @@ -592,6 +592,8 @@ guest_status(int argc, char **argv) if (nbytes != sizeof(msg)) err(1, "read"); + utilisation = 0.0; + memcpy(&state, msg.msg.resstat.data, sizeof(state)); switch (state.state) { case GUEST_STATE_STOPPED: @@ -644,8 +646,6 @@ guest_status(int argc, char **argv) if (yielded_cycles <= total_cycles) utilisation = (100.0 * (total_cycles - yielded_cycles)) / total_cycles; - else - utilisation = 0.0; break; case GUEST_STATE_SUSPENDED: