- kvm-hw-virtio-virtio-iommu-Migrate-to-3-phase-reset.patch [RHEL-7188] - kvm-hw-i386-intel-iommu-Migrate-to-3-phase-reset.patch [RHEL-7188] - kvm-hw-arm-smmuv3-Move-reset-to-exit-phase.patch [RHEL-7188] - kvm-hw-vfio-common-Add-a-trace-point-in-vfio_reset_handl.patch [RHEL-7188] - kvm-docs-devel-reset-Document-reset-expectations-for-DMA.patch [RHEL-7188] - kvm-qga-implement-a-guest-get-load-command.patch [RHEL-69622] - kvm-migration-Fix-UAF-for-incoming-migration-on-Migratio.patch [RHEL-69775] - kvm-scripts-improve-error-from-qemu-trace-stap-on-missin.patch [RHEL-47340] - kvm-Recommend-systemtap-client-from-qemu-tools.patch [RHEL-47340] - Resolves: RHEL-7188 ([intel iommu][PF] DMAR: DRHD: handling fault status reg) - Resolves: RHEL-69622 ([qemu-guest-agent][RFE] Report CPU load average) - Resolves: RHEL-69775 (Guest crashed on the target host when the migration was canceled) - Resolves: RHEL-47340 ([Qemu RHEL-9] qemu-trace-stap should handle lack of stap more gracefully)
140 lines
3.9 KiB
Diff
140 lines
3.9 KiB
Diff
From 22f26a93ab94bf87c0724891a5886797a38c23b4 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
|
|
Date: Mon, 2 Dec 2024 12:19:27 +0000
|
|
Subject: [PATCH 6/9] qga: implement a 'guest-get-load' command
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
RH-Author: Konstantin Kostiuk <None>
|
|
RH-MergeRequest: 343: RHEL-69622: qga: implement a 'guest-get-load' command
|
|
RH-Jira: RHEL-69622
|
|
RH-Acked-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
RH-Acked-by: Jon Maloy <jmaloy@redhat.com>
|
|
RH-Commit: [1/1] 9284c70737ad9f700d37f8c3833f855f2354acb7 (kkostiuk/redhat-centos-stream-src-qemu-kvm)
|
|
|
|
Provide a way to report the process load average, via a new
|
|
'guest-get-load' command.
|
|
|
|
This is only implemented for POSIX platforms providing 'getloadavg'.
|
|
|
|
Example illustrated with qmp-shell:
|
|
|
|
(QEMU) guest-get-load
|
|
{
|
|
"return": {
|
|
"load15m": 1.546875,
|
|
"load1m": 1.669921875,
|
|
"load5m": 1.9306640625
|
|
}
|
|
}
|
|
|
|
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
|
|
|
|
This is left as an exercise for future contributors.
|
|
|
|
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com>
|
|
Message-ID: <20241202121927.864335-1-berrange@redhat.com>
|
|
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
|
|
---
|
|
meson.build | 1 +
|
|
qga/commands-posix.c | 20 ++++++++++++++++++++
|
|
qga/qapi-schema.json | 37 +++++++++++++++++++++++++++++++++++++
|
|
3 files changed, 58 insertions(+)
|
|
|
|
diff --git a/meson.build b/meson.build
|
|
index b3529aa0e1..1dd97c6f49 100644
|
|
--- a/meson.build
|
|
+++ b/meson.build
|
|
@@ -2497,6 +2497,7 @@ config_host_data.set('CONFIG_SETNS', cc.has_function('setns') and cc.has_functio
|
|
config_host_data.set('CONFIG_SYNCFS', cc.has_function('syncfs'))
|
|
config_host_data.set('CONFIG_SYNC_FILE_RANGE', cc.has_function('sync_file_range'))
|
|
config_host_data.set('CONFIG_TIMERFD', cc.has_function('timerfd_create'))
|
|
+config_host_data.set('CONFIG_GETLOADAVG', cc.has_function('getloadavg'))
|
|
config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range'))
|
|
config_host_data.set('HAVE_GETIFADDRS', cc.has_function('getifaddrs'))
|
|
config_host_data.set('HAVE_GLIB_WITH_SLICE_ALLOCATOR', glib_has_gslice)
|
|
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
|
|
index 49e40f9127..abfa53d6e9 100644
|
|
--- a/qga/commands-posix.c
|
|
+++ b/qga/commands-posix.c
|
|
@@ -1371,3 +1371,23 @@ char *qga_get_host_name(Error **errp)
|
|
|
|
return g_steal_pointer(&hostname);
|
|
}
|
|
+
|
|
+#ifdef CONFIG_GETLOADAVG
|
|
+GuestLoadAverage *qmp_guest_get_load(Error **errp)
|
|
+{
|
|
+ double loadavg[3];
|
|
+ GuestLoadAverage *ret = NULL;
|
|
+
|
|
+ if (getloadavg(loadavg, G_N_ELEMENTS(loadavg)) < 0) {
|
|
+ error_setg_errno(errp, errno,
|
|
+ "cannot query load average");
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
+ ret = g_new0(GuestLoadAverage, 1);
|
|
+ ret->load1m = loadavg[0];
|
|
+ ret->load5m = loadavg[1];
|
|
+ ret->load15m = loadavg[2];
|
|
+ return ret;
|
|
+}
|
|
+#endif
|
|
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
|
|
index 495706cf73..739f008ff2 100644
|
|
--- a/qga/qapi-schema.json
|
|
+++ b/qga/qapi-schema.json
|
|
@@ -1852,6 +1852,43 @@
|
|
'if': 'CONFIG_LINUX'
|
|
}
|
|
|
|
+
|
|
+##
|
|
+# @GuestLoadAverage:
|
|
+#
|
|
+# Statistics about process load information
|
|
+#
|
|
+# @load1m: 1-minute load avage
|
|
+#
|
|
+# @load5m: 5-minute load avage
|
|
+#
|
|
+# @load15m: 15-minute load avage
|
|
+#
|
|
+# Since: 10.0
|
|
+##
|
|
+{ 'struct': 'GuestLoadAverage',
|
|
+ 'data': {
|
|
+ 'load1m': 'number',
|
|
+ 'load5m': 'number',
|
|
+ 'load15m': 'number'
|
|
+ },
|
|
+ 'if': 'CONFIG_GETLOADAVG'
|
|
+}
|
|
+
|
|
+##
|
|
+# @guest-get-load:
|
|
+#
|
|
+# Retrieve CPU process load information
|
|
+#
|
|
+# Returns: load information
|
|
+#
|
|
+# Since: 10.0
|
|
+##
|
|
+{ 'command': 'guest-get-load',
|
|
+ 'returns': 'GuestLoadAverage',
|
|
+ 'if': 'CONFIG_GETLOADAVG'
|
|
+}
|
|
+
|
|
##
|
|
# @GuestNetworkRoute:
|
|
#
|
|
--
|
|
2.48.1
|
|
|