qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Konstantin Kostiuk <kkostiuk@redhat.com>
Cc: qemu-devel@nongnu.org,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Michael Roth" <michael.roth@amd.com>
Subject: Re: [PATCH 1/2] qga-win: implement a 'guest-get-load' command
Date: Wed, 19 Mar 2025 15:02:31 +0000	[thread overview]
Message-ID: <Z9rchyQO5vNcrfmN@redhat.com> (raw)
In-Reply-To: <20250314113847.109460-2-kkostiuk@redhat.com>

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 <kkostiuk@redhat.com>
> ---
>  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é <berrange@redhat.com>


> +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.


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



  reply	other threads:[~2025-03-19 15:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-14 11:38 [PATCH 0/2] qga: Add 'guest-get-load' command Konstantin Kostiuk
2025-03-14 11:38 ` [PATCH 1/2] qga-win: implement a " Konstantin Kostiuk
2025-03-19 15:02   ` Daniel P. Berrangé [this message]
2025-03-19 16:52     ` Konstantin Kostiuk
2025-03-14 11:38 ` [PATCH 2/2] qga: Add tests for guest-get-load command Konstantin Kostiuk
2025-03-18 13:47 ` [PATCH 0/2] qga: Add 'guest-get-load' command Dehan Meng
2025-03-19 14:57 ` Yan Vugenfirer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z9rchyQO5vNcrfmN@redhat.com \
    --to=berrange@redhat.com \
    --cc=kkostiuk@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).