qemu-ga patch queue for 2.11
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(-)
[Qemu-devel] [PULL for-2.11 1/1] qga: replace GetIfEntry with GetIfEntry2 for interface stats
From: ZhiPeng Lu <[email protected]>
The data obtained by GetIfEntry is 32 bits, and it may overflow. Thus using GetIfEntry2 instead of GetIfEntry.
*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
--- qga/commands-win32.c | 54 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 16 deletions(-)
qga/commands-win32.c +38 -16
@@ -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 ; }
Signature · 1 line
2.11.0
Peter Maydell
AppliedQuoted 15 lines · Michael Roth
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.gittags/qga-pull-2017-11-20-tagfor 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
Quoted 9 lines
* fix potential overflow in network interface stats reporting
----------------------------------------------------------------
ZhiPeng Lu (1):
qga: replace GetIfEntry with GetIfEntry2 for interface statsqga/commands-win32.c | 54 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 16 deletions(-)
Applied, thanks.
-- PMM
This series seems to have some coding style problems. See output below for more information:
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: [email protected]
=== 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/[email protected] -> patchew/[email protected]
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 [email protected]