1
0
mirror of https://github.com/openbsd/src.git synced 2024-12-21 23:18:00 -08:00

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!
This commit is contained in:
kn 2023-08-10 07:50:45 +00:00
parent 05958c5ea9
commit 116f3cbfa9

View File

@ -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: