Skip to contentSkip to conversation

Guest Agent patches 2022-07-13

GIT PULL Applied Konstantin Kostiuk 3 participants 9 messages Jul 13, 2022 – Jul 14, 2022

lore
Share & tools
lore
#0 lore raw

The following changes since commit 08c8a31214e8ca29e05b9f6c3ee942b28ec58457:

Merge tag 'pull-tcg-20220712' of https://gitlab.com/rth7680/qemu into staging (2022-07-12 11:52:11 +0530)

are available in the Git repository at:

[email protected]:kostyanf14/qemu.git tags/qga-win32-pull-2022-07-13

for you to fetch changes up to 1db8a0b0ea2fb72ecab36bd3143a9715c083d5d3:

qga: add command 'guest-get-cpustats' (2022-07-13 12:19:18 +0300)

----------------------------------------------------------------
qga-win32-pull-2022-07-13

----------------------------------------------------------------
Konstantin Kostiuk (1):
MAINTAINERS: Add myself as Guest Agent reviewer

Zhenwei Pi (2):
qapi: Avoid generating C identifier 'linux'
qga: add command 'guest-get-cpustats'

 MAINTAINERS            |  1 +
 qga/commands-posix.c   | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++
 qga/commands-win32.c   |  6 ++++
 qga/qapi-schema.json   | 81 +++++++++++++++++++++++++++++++++++++++++++++
 scripts/qapi/common.py |  2 +-
 5 files changed, 178 insertions(+), 1 deletion(-)

--
2.25.1

#1 lore raw

[PULL 2/3] qapi: Avoid generating C identifier 'linux'

From: zhenwei pi <[email protected]>

'linux' is not usable as identifier, because C compilers targeting Linux predefine it as a macro expanding to 1. Add it to @polluted_words. 'unix' is already there.

Message-Id: <[email protected]>

---
 scripts/qapi/common.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/qapi/common.py +1 -1
index 489273574a..737b059e62 100644
@@ -114,7 +114,7 @@ def c_name(name: str, protect: bool = True) -> str:
                      'and', 'and_eq', 'bitand', 'bitor', 'compl', 'not',
                      'not_eq', 'or', 'or_eq', 'xor', 'xor_eq'])
     # namespace pollution:
-    polluted_words = set(['unix', 'errno', 'mips', 'sparc', 'i386'])
+    polluted_words = set(['unix', 'errno', 'mips', 'sparc', 'i386', 'linux'])
     name = re.sub(r'[^A-Za-z0-9_]', '_', name)
     if protect and (name in (c89_words | c99_words | c11_words | gcc_words
                              | cpp_words | polluted_words)
Signature · 1 line
2.25.1
#2 lore raw

[PULL 1/3] MAINTAINERS: Add myself as Guest Agent reviewer

In reply to Konstantin Kostiuk

Message-Id: <[email protected]>

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 450abd0252..b1e73d99f3 100644
@@ -2880,6 +2880,7 @@ T: git https://repo.or.cz/qemu/armbru.git qapi-next
 
 QEMU Guest Agent
 M: Michael Roth <[email protected]>
+R: Konstantin Kostiuk <[email protected]>
 S: Maintained
 F: qga/
 F: docs/interop/qemu-ga.rst
Signature · 1 line
2.25.1
#3 lore raw

Re: [PULL 1/3] MAINTAINERS: Add myself as Guest Agent reviewer

Quoted 13 lines · Konstantin Kostiuk

Message-Id: <[email protected]>

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +0 -0
index 450abd0252..b1e73d99f3 100644

MAINTAINERS T: git https://repo.or.cz/qemu/armbru.git qapi-next · line 2883

Quoted 4 lines
MAINTAINERS +1 -0
@@ -2880,6 +2880,7 @@ T: git https://repo.or.cz/qemu/armbru.git qapi-next
 
 QEMU Guest Agent
 M: Michael Roth <[email protected]>
+R: Konstantin Kostiuk <[email protected]>

This pull request contains functional changes under qga/, which suggests you're acting as a (co-)maintainer for QGA, not merely a reviewer. I wouldn't normally expect reviewers to send pull requests for a subsystem. As such should this be "M:", to indicate co-maintainership and have an explicit ACK from Michael Roth.

MAINTAINERS T: git https://repo.or.cz/qemu/armbru.git qapi-next · line 2886

Quoted 3 lines
MAINTAINERS +0 -0
 S: Maintained
 F: qga/
 F: docs/interop/qemu-ga.rst

With regards,
Daniel

Signature · 3 lines
|: 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 :|
#4 lore raw

Re: [PULL 1/3] MAINTAINERS: Add myself as Guest Agent reviewer

Quoted 20 lines · Daniel P. Berrangé

MAINTAINERS T: git https://repo.or.cz/qemu/armbru.git

Quoted 13 lines · Konstantin Kostiuk

Message-Id: <[email protected]>

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +0 -0
index 450abd0252..b1e73d99f3 100644
@@ -2880,6 +2880,7 @@ T: git https://repo.or.cz/qemu/armbru.git

qapi-next

MAINTAINERS T: git https://repo.or.cz/qemu/armbru.git qapi-next · line 2883

Quoted 4 lines
MAINTAINERS +1 -0
 QEMU Guest Agent
 M: Michael Roth <[email protected]>
+R: Konstantin Kostiuk <[email protected]>
Quoted 7 lines

This pull request contains functional changes under qga/, which suggests you're acting as a (co-)maintainer for QGA, not merely a reviewer. I wouldn't normally expect reviewers to send pull requests for a subsystem. As such should this be "M:", to indicate co-maintainership and have an explicit ACK from Michael Roth.

As the maintainer of the Windows part of the Guest Agent, I have added myself
as a reviewer so I don't miss out on general patches for the Guest Agent. Some time ago, I asked Michael Roth if I could submit PRs for all guest agent components and he allow me to do this.
If need I can add myself as a co-maintainer to Guest Agent not only Guest Agent Windows.

Quoted 17 lines

MAINTAINERS T: git https://repo.or.cz/qemu/armbru.git qapi-next · line 2886

Quoted 4 lines
MAINTAINERS +0 -0
 S: Maintained
 F: qga/
 F: docs/interop/qemu-ga.rst

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

#5 lore raw

Re: [PULL 1/3] MAINTAINERS: Add myself as Guest Agent reviewer

Quoted 31 lines · Konstantin Kostiuk
Quoted 20 lines · Daniel P. Berrangé

MAINTAINERS T: git https://repo.or.cz/qemu/armbru.git

Quoted 13 lines · Konstantin Kostiuk

Message-Id: <[email protected]>

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +0 -0
index 450abd0252..b1e73d99f3 100644
@@ -2880,6 +2880,7 @@ T: git https://repo.or.cz/qemu/armbru.git

qapi-next

MAINTAINERS T: git https://repo.or.cz/qemu/armbru.git qapi-next · line 2883

Quoted 4 lines
MAINTAINERS +1 -0
 QEMU Guest Agent
 M: Michael Roth <[email protected]>
+R: Konstantin Kostiuk <[email protected]>
Quoted 7 lines

This pull request contains functional changes under qga/, which suggests you're acting as a (co-)maintainer for QGA, not merely a reviewer. I wouldn't normally expect reviewers to send pull requests for a subsystem. As such should this be "M:", to indicate co-maintainership and have an explicit ACK from Michael Roth.

Quoted 7 lines

As the maintainer of the Windows part of the Guest Agent, I have added myself
as a reviewer so I don't miss out on general patches for the Guest Agent. Some time ago, I asked Michael Roth if I could submit PRs for all guest agent components and he allow me to do this.
If need I can add myself as a co-maintainer to Guest Agent not only Guest Agent Windows.

It sounds like you're defacto a co-maintainer already then and might as well ackowledge this in MAINTAINERS.

With regards,
Daniel

Signature · 3 lines
|: 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 :|
#6 lore raw

Re: [PULL 1/3] MAINTAINERS: Add myself as Guest Agent reviewer

Quoted 40 lines · Daniel P. Berrangé
Quoted 31 lines · Konstantin Kostiuk
Quoted 20 lines · Daniel P. Berrangé

MAINTAINERS T: git https://repo.or.cz/qemu/armbru.git

Quoted 13 lines · Konstantin Kostiuk

Message-Id: <[email protected]>

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +0 -0
index 450abd0252..b1e73d99f3 100644
@@ -2880,6 +2880,7 @@ T: git https://repo.or.cz/qemu/armbru.git

qapi-next

MAINTAINERS T: git https://repo.or.cz/qemu/armbru.git qapi-next · line 2883

Quoted 4 lines
MAINTAINERS +1 -0
 QEMU Guest Agent
 M: Michael Roth <[email protected]>
+R: Konstantin Kostiuk <[email protected]>
Quoted 7 lines

This pull request contains functional changes under qga/, which suggests you're acting as a (co-)maintainer for QGA, not merely a reviewer. I wouldn't normally expect reviewers to send pull requests for a subsystem. As such should this be "M:", to indicate co-maintainership and have an explicit ACK from Michael Roth.

Quoted 7 lines

As the maintainer of the Windows part of the Guest Agent, I have added myself
as a reviewer so I don't miss out on general patches for the Guest Agent. Some time ago, I asked Michael Roth if I could submit PRs for all guest agent components and he allow me to do this.
If need I can add myself as a co-maintainer to Guest Agent not only Guest Agent Windows.

Quoted 3 lines

It sounds like you're defacto a co-maintainer already then and might as well ackowledge this in MAINTAINERS.

Ok. Will resend patch and pull.

Quoted 12 lines

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

#7 lore raw

[PULL 3/3] qga: add command 'guest-get-cpustats'

In reply to Konstantin Kostiuk

From: zhenwei pi <[email protected]>

A vCPU thread always reaches 100% utilization when:
- guest uses idle=poll
- disable HLT vm-exit
- enable MWAIT

Add new guest agent command 'guest-get-cpustats' to get guest CPU statistics, we can know the guest workload and how busy the CPU is.

Message-Id: <[email protected]>

---
 qga/commands-posix.c | 89 ++++++++++++++++++++++++++++++++++++++++++++
 qga/commands-win32.c |  6 +++
 qga/qapi-schema.json | 81 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 176 insertions(+)
qga/commands-posix.c +89 -0
index 0469dc409d..f18530d85f 100644
@@ -2893,6 +2893,90 @@ GuestDiskStatsInfoList *qmp_guest_get_diskstats(Error **errp)
     return guest_get_diskstats(errp);
 }
 
+GuestCpuStatsList *qmp_guest_get_cpustats(Error **errp)
+{
+    GuestCpuStatsList *head = NULL, **tail = &head;
+    const char *cpustats = "/proc/stat";
+    int clk_tck = sysconf(_SC_CLK_TCK);
+    FILE *fp;
+    size_t n;
+    char *line = NULL;
+
+    fp = fopen(cpustats, "r");
+    if (fp  == NULL) {
+        error_setg_errno(errp, errno, "open(\"%s\")", cpustats);
+        return NULL;
+    }
+
+    while (getline(&line, &n, fp) != -1) {
+        GuestCpuStats *cpustat = NULL;
+        GuestLinuxCpuStats *linuxcpustat;
+        int i;
+        unsigned long user, system, idle, iowait, irq, softirq, steal, guest;
+        unsigned long nice, guest_nice;
+        char name[64];
+
+        i = sscanf(line, "%s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu",
+                   name, &user, &nice, &system, &idle, &iowait, &irq, &softirq,
+                   &steal, &guest, &guest_nice);
+
+        /* drop "cpu 1 2 3 ...", get "cpuX 1 2 3 ..." only */
+        if ((i == EOF) || strncmp(name, "cpu", 3) || (name[3] == '\0')) {
+            continue;
+        }
+
+        if (i < 5) {
+            slog("Parsing cpu stat from %s failed, see \"man proc\"", cpustats);
+            break;
+        }
+
+        cpustat = g_new0(GuestCpuStats, 1);
+        cpustat->type = GUEST_CPU_STATS_TYPE_LINUX;
+
+        linuxcpustat = &cpustat->u.q_linux;
+        linuxcpustat->cpu = atoi(&name[3]);
+        linuxcpustat->user = user * 1000 / clk_tck;
+        linuxcpustat->nice = nice * 1000 / clk_tck;
+        linuxcpustat->system = system * 1000 / clk_tck;
+        linuxcpustat->idle = idle * 1000 / clk_tck;
+
+        if (i > 5) {
+            linuxcpustat->has_iowait = true;
+            linuxcpustat->iowait = iowait * 1000 / clk_tck;
+        }
+
+        if (i > 6) {
+            linuxcpustat->has_irq = true;
+            linuxcpustat->irq = irq * 1000 / clk_tck;
+            linuxcpustat->has_softirq = true;
+            linuxcpustat->softirq = softirq * 1000 / clk_tck;
+        }
+
+        if (i > 8) {
+            linuxcpustat->has_steal = true;
+            linuxcpustat->steal = steal * 1000 / clk_tck;
+        }
+
+        if (i > 9) {
+            linuxcpustat->has_guest = true;
+            linuxcpustat->guest = guest * 1000 / clk_tck;
+        }
+
+        if (i > 10) {
+            linuxcpustat->has_guest = true;
+            linuxcpustat->guest = guest * 1000 / clk_tck;
+            linuxcpustat->has_guestnice = true;
+            linuxcpustat->guestnice = guest_nice * 1000 / clk_tck;
+        }
+
+        QAPI_LIST_APPEND(tail, cpustat);
+    }
+
+    free(line);
+    fclose(fp);
+    return head;
+}
+
 #else /* defined(__linux__) */
 
 void qmp_guest_suspend_disk(Error **errp)
@@ -3247,6 +3331,11 @@ GuestDiskStatsInfoList *qmp_guest_get_diskstats(Error **errp)
     return NULL;
 }
 
+GuestCpuStatsList *qmp_guest_get_cpustats(Error **errp)
+{
+    error_setg(errp, QERR_UNSUPPORTED);
+    return NULL;
+}
 
 #endif /* CONFIG_FSFREEZE */
 
qga/commands-win32.c +6 -0
index 36f94c0f9c..7ed7664715 100644
@@ -2543,3 +2543,9 @@ GuestDiskStatsInfoList *qmp_guest_get_diskstats(Error **errp)
     error_setg(errp, QERR_UNSUPPORTED);
     return NULL;
 }
+
+GuestCpuStatsList *qmp_guest_get_cpustats(Error **errp)
+{
+    error_setg(errp, QERR_UNSUPPORTED);
+    return NULL;
+}
qga/qapi-schema.json +81 -0

84 lines not on this page · raw message

Signature · 1 line
2.25.1
#8 lore raw
In reply to Konstantin Kostiuk
Quoted 9 lines · Konstantin Kostiuk

The following changes since commit 08c8a31214e8ca29e05b9f6c3ee942b28ec58457:

Merge tag 'pull-tcg-20220712' of https://gitlab.com/rth7680/qemu into staging (2022-07-12 11:52:11 +0530)

are available in the Git repository at:

[email protected]:kostyanf14/qemu.git tags/qga-win32-pull-2022-07-13

Quoted 8 lines

for you to fetch changes up to 1db8a0b0ea2fb72ecab36bd3143a9715c083d5d3:

qga: add command 'guest-get-cpustats' (2022-07-13 12:19:18 +0300)

----------------------------------------------------------------
qga-win32-pull-2022-07-13

----------------------------------------------------------------

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/7.1
for any user-visible changes.

-- PMM