On Wed, Mar 19, 2025 at 5:02 PM Daniel P. Berrangé <[email protected]> wrote:
> On Fri, Mar 14, 2025 at 01:38:46PM +0200, Konstantin Kostiuk wrote: > > Windows has no native equivalent API, but it would be possible to > > simulate it as illustrated here (BSD-3-Clause): > > > > https://github.com/giampaolo/psutil/pull/1485 > > > > Signed-off-by: Konstantin Kostiuk <[email protected]> > > --- > > qga/commands-win32.c | 140 +++++++++++++++++++++++++++++++++++++++++ > > qga/guest-agent-core.h | 10 +++ > > qga/main.c | 39 ++++++++++++ > > qga/meson.build | 2 +- > > qga/qapi-schema.json | 4 +- > > 5 files changed, 192 insertions(+), 3 deletions(-) > > Reviewed-by: Daniel P. Berrangé <[email protected]> > > > > +GuestLoadAverage *qmp_guest_get_load(Error **errp) > > +{ > > + if (ga_get_load_avg_pdh_query(ga_state) == NULL) { > > + /* set initial values */ > > + load_avg_1m = 0; > > + load_avg_5m = 0; > > + load_avg_15m = 0; > > + > > + if (init_load_avg_counter(errp) == false) { > > + return NULL; > > + } > > + } > > Nice idea. So we avoid running the load average logic > until such time as a mgmt app actually asks for it. > > The load avg won't be very accurate initially, but > assuming any interested mgmt app will ask for this > repeatedly over the entire life of the VM, this looks > like a good mitigation. > > Perhaps worth a commenting explaining why we're doing > this. > > Will add comments Also, this allows the mgmt app to capture errors in the initialization process. Otherwise, it should somehow parse logs. > > > + > > + GuestLoadAverage *ret = NULL; > > + > > + ret = g_new0(GuestLoadAverage, 1); > > + ret->load1m = load_avg_1m; > > + ret->load5m = load_avg_5m; > > + ret->load15m = load_avg_15m; > > + return ret; > > +} > > With regards, > Daniel > -- > |: https://berrange.com -o- > https://www.flickr.com/photos/dberrange :| > |: https://libvirt.org -o- > https://fstop138.berrange.com :| > |: https://entangle-photo.org -o- > https://www.instagram.com/dberrange :| > >
