* [Qemu-devel] [PULL for-2.11 0/1] qemu-ga patch queue for 2.11
@ 2017-11-20 21:50 Michael Roth
2017-11-20 21:50 ` [Qemu-devel] [PULL for-2.11 1/1] qga: replace GetIfEntry with GetIfEntry2 for interface stats Michael Roth
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Michael Roth @ 2017-11-20 21:50 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell
The following changes since commit b2996bb405e2806725a341c72d80be9e77ed8b82:
Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.11-20171120' into staging (2017-11-20 18:00:16 +0000)
are available in the git repository at:
git://github.com/mdroth/qemu.git tags/qga-pull-2017-11-20-tag
for you to fetch changes up to df83eabd5245828cbca32060aa191d8b03bc5d50:
qga: replace GetIfEntry with GetIfEntry2 for interface stats (2017-11-20 14:45:31 -0600)
----------------------------------------------------------------
qemu-ga patch queue for 2.11
* fix potential overflow in network interface stats reporting
----------------------------------------------------------------
ZhiPeng Lu (1):
qga: replace GetIfEntry with GetIfEntry2 for interface stats
qga/commands-win32.c | 54 ++++++++++++++++++++++++++++++++++++----------------
1 file changed, 38 insertions(+), 16 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PULL for-2.11 1/1] qga: replace GetIfEntry with GetIfEntry2 for interface stats
2017-11-20 21:50 [Qemu-devel] [PULL for-2.11 0/1] qemu-ga patch queue for 2.11 Michael Roth
@ 2017-11-20 21:50 ` Michael Roth
2017-11-20 22:05 ` [Qemu-devel] [PULL for-2.11 0/1] qemu-ga patch queue for 2.11 no-reply
2017-11-21 12:08 ` Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Michael Roth @ 2017-11-20 21:50 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, ZhiPeng Lu
From: ZhiPeng Lu <lu.zhipeng@zte.com.cn>
The data obtained by GetIfEntry is 32 bits, and it may overflow. Thus
using GetIfEntry2 instead of GetIfEntry.
Signed-off-by: ZhiPeng Lu <lu.zhipeng@zte.com.cn>
*avoid CamelCase variable names
*update field names for MIB_IFROW -> MIB_IF_ROW2
*dynamically probe for GetIfIndex2 to deal with older OSs
*check return value from get_interface_index
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
qga/commands-win32.c | 54 ++++++++++++++++++++++++++++++++++++----------------
1 file changed, 38 insertions(+), 16 deletions(-)
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 0322188a73..d79974f212 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -1169,24 +1169,46 @@ static DWORD get_interface_index(const char *guid)
return index;
}
}
+
+typedef NETIOAPI_API (WINAPI *GetIfEntry2Func)(PMIB_IF_ROW2 Row);
+
static int guest_get_network_stats(const char *name,
- GuestNetworkInterfaceStat *stats)
+ GuestNetworkInterfaceStat *stats)
{
- DWORD if_index = 0;
- MIB_IFROW a_mid_ifrow;
- memset(&a_mid_ifrow, 0, sizeof(a_mid_ifrow));
- if_index = get_interface_index(name);
- a_mid_ifrow.dwIndex = if_index;
- if (NO_ERROR == GetIfEntry(&a_mid_ifrow)) {
- stats->rx_bytes = a_mid_ifrow.dwInOctets;
- stats->rx_packets = a_mid_ifrow.dwInUcastPkts;
- stats->rx_errs = a_mid_ifrow.dwInErrors;
- stats->rx_dropped = a_mid_ifrow.dwInDiscards;
- stats->tx_bytes = a_mid_ifrow.dwOutOctets;
- stats->tx_packets = a_mid_ifrow.dwOutUcastPkts;
- stats->tx_errs = a_mid_ifrow.dwOutErrors;
- stats->tx_dropped = a_mid_ifrow.dwOutDiscards;
- return 0;
+ OSVERSIONINFO os_ver;
+
+ os_ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&os_ver);
+ if (os_ver.dwMajorVersion >= 6) {
+ MIB_IF_ROW2 a_mid_ifrow;
+ GetIfEntry2Func getifentry2_ex;
+ DWORD if_index = 0;
+ HMODULE module = GetModuleHandle("iphlpapi");
+ PVOID func = GetProcAddress(module, "GetIfEntry2");
+
+ if (func == NULL) {
+ return -1;
+ }
+
+ getifentry2_ex = (GetIfEntry2Func)func;
+ if_index = get_interface_index(name);
+ if (if_index == (DWORD)~0) {
+ return -1;
+ }
+
+ memset(&a_mid_ifrow, 0, sizeof(a_mid_ifrow));
+ a_mid_ifrow.InterfaceIndex = if_index;
+ if (NO_ERROR == getifentry2_ex(&a_mid_ifrow)) {
+ stats->rx_bytes = a_mid_ifrow.InOctets;
+ stats->rx_packets = a_mid_ifrow.InUcastPkts;
+ stats->rx_errs = a_mid_ifrow.InErrors;
+ stats->rx_dropped = a_mid_ifrow.InDiscards;
+ stats->tx_bytes = a_mid_ifrow.OutOctets;
+ stats->tx_packets = a_mid_ifrow.OutUcastPkts;
+ stats->tx_errs = a_mid_ifrow.OutErrors;
+ stats->tx_dropped = a_mid_ifrow.OutDiscards;
+ return 0;
+ }
}
return -1;
}
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PULL for-2.11 0/1] qemu-ga patch queue for 2.11
2017-11-20 21:50 [Qemu-devel] [PULL for-2.11 0/1] qemu-ga patch queue for 2.11 Michael Roth
2017-11-20 21:50 ` [Qemu-devel] [PULL for-2.11 1/1] qga: replace GetIfEntry with GetIfEntry2 for interface stats Michael Roth
@ 2017-11-20 22:05 ` no-reply
2017-11-21 12:08 ` Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: no-reply @ 2017-11-20 22:05 UTC (permalink / raw)
To: mdroth; +Cc: famz, qemu-devel, peter.maydell
Hi,
This series seems to have some coding style problems. See output below for
more information:
Subject: [Qemu-devel] [PULL for-2.11 0/1] qemu-ga patch queue for 2.11
Type: series
Message-id: 20171120215034.22212-1-mdroth@linux.vnet.ibm.com
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))
done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/20171120215034.22212-1-mdroth@linux.vnet.ibm.com -> patchew/20171120215034.22212-1-mdroth@linux.vnet.ibm.com
Switched to a new branch 'test'
4dc0db9e07 qga: replace GetIfEntry with GetIfEntry2 for interface stats
=== OUTPUT BEGIN ===
Checking PATCH 1/1: qga: replace GetIfEntry with GetIfEntry2 for interface stats...
ERROR: space prohibited between function name and open parenthesis '('
#26: FILE: qga/commands-win32.c:1173:
+typedef NETIOAPI_API (WINAPI *GetIfEntry2Func)(PMIB_IF_ROW2 Row);
ERROR: spaces required around that '*' (ctx:WxV)
#26: FILE: qga/commands-win32.c:1173:
+typedef NETIOAPI_API (WINAPI *GetIfEntry2Func)(PMIB_IF_ROW2 Row);
^
total: 2 errors, 0 warnings, 62 lines checked
Your patch has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PULL for-2.11 0/1] qemu-ga patch queue for 2.11
2017-11-20 21:50 [Qemu-devel] [PULL for-2.11 0/1] qemu-ga patch queue for 2.11 Michael Roth
2017-11-20 21:50 ` [Qemu-devel] [PULL for-2.11 1/1] qga: replace GetIfEntry with GetIfEntry2 for interface stats Michael Roth
2017-11-20 22:05 ` [Qemu-devel] [PULL for-2.11 0/1] qemu-ga patch queue for 2.11 no-reply
@ 2017-11-21 12:08 ` Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2017-11-21 12:08 UTC (permalink / raw)
To: Michael Roth; +Cc: QEMU Developers
On 20 November 2017 at 21:50, Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> The following changes since commit b2996bb405e2806725a341c72d80be9e77ed8b82:
>
> Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.11-20171120' into staging (2017-11-20 18:00:16 +0000)
>
> are available in the git repository at:
>
> git://github.com/mdroth/qemu.git tags/qga-pull-2017-11-20-tag
>
> for you to fetch changes up to df83eabd5245828cbca32060aa191d8b03bc5d50:
>
> qga: replace GetIfEntry with GetIfEntry2 for interface stats (2017-11-20 14:45:31 -0600)
>
> ----------------------------------------------------------------
> qemu-ga patch queue for 2.11
>
> * fix potential overflow in network interface stats reporting
>
> ----------------------------------------------------------------
> ZhiPeng Lu (1):
> qga: replace GetIfEntry with GetIfEntry2 for interface stats
>
> qga/commands-win32.c | 54 ++++++++++++++++++++++++++++++++++++----------------
> 1 file changed, 38 insertions(+), 16 deletions(-)
>
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-11-24 13:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-20 21:50 [Qemu-devel] [PULL for-2.11 0/1] qemu-ga patch queue for 2.11 Michael Roth
2017-11-20 21:50 ` [Qemu-devel] [PULL for-2.11 1/1] qga: replace GetIfEntry with GetIfEntry2 for interface stats Michael Roth
2017-11-20 22:05 ` [Qemu-devel] [PULL for-2.11 0/1] qemu-ga patch queue for 2.11 no-reply
2017-11-21 12:08 ` Peter Maydell
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).