All of lore.kernel.org
 help / color / mirror / Atom feed
From: <lu.zhipeng@zte.com.cn>
To: mdroth@linux.vnet.ibm.com
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] 答复: Re: 答复: Re: 答复: Re: [PATCH v2] qga: replace GetIfEntry
Date: Wed, 15 Nov 2017 09:41:58 +0800 (CST)	[thread overview]
Message-ID: <201711150941584900906@zte.com.cn> (raw)
In-Reply-To: <151070890548.31225.9825410878164929754@sif>

[-- Attachment #1: Type: text/plain, Size: 13238 bytes --]

i used  xp  version:


xp professional 2002 service pack 3


build environment: 




root@localhost qemu-2.5.0]# cat /etc/redhat-release 

CentOS Linux release 7.0.1406 (Core) 
























为了让您的VPlat虚拟机故障和docker故障得到高效的处理,请上报故障到: $VPlat技术支持。


芦志朋 luzhipeng






IT开发工程师 IT Development
Engineer
操作系统产品部/中心研究院/系统产品 OS Product Dept./Central R&D Institute/System Product









四川省成都市天府大道中段800号
E: lu.zhipeng@zte.com.cn 
www.zte.com.cn










原始邮件



发件人: <mdroth@linux.vnet.ibm.com>;
收件人:芦志朋10108272;
抄送人: <qemu-devel@nongnu.org>;
日 期 :2017年11月15日 09:22
主 题 :Re: 答复: Re: 答复: Re: [PATCH v2] qga: replace GetIfEntry


Quoting lu.zhipeng@zte.com.cn (2017-11-14 05:09:35)
>  i test the latest qga in xp , it run ok .
> 
> 
> my qga config :
> 
> Configured with: './configure' '--enable-guest-agent' '--cross-prefix=
> x86_64-w64-mingw32-' '--with-vss-sdk=/home/VSSSDK72' '--disable-fdt'        
> '--target-list=x86_64-softmmu'

Hmm, so you're testing with Windows XP x64? I was using XP 32-bit (SP3),
but I retried with XP x64 (SP2) and I still have the same issue.

I can only get qemu-ga working if I build on top of something prior to
commit 12f8def0e.

What build environment are you using? I've tried Fedora Core 18 and 20
and have the same issue with both.

> 
> used qga version info
> 
> [root@ceshi qemu]# git log
> 
> commit 533ab83ea074d5fc457769f6ac698524a12f1156
> 
> Author: ZhiPeng Lu <lu.zhipeng@zte.com.cn>
> 
> Date:   Fri Nov 10 10:17:14 2017 +0800
> 
> 
>     qga: fix some errors for guest_get_network_stats
> 
>     
> 
>     fix some erros:
> 
>     1.if building qga on Windows Vista/2008 and newer,
> 
>     it cann't find the link to GetIfEntry2 in windows xp.
> 
>     2. check valid of if_index.
> 
>     
> 
>     Signed-off-by: ZhiPeng Lu <lu.zhipeng@zte.com.cn>
> 
> 
> commit de597a8b27722ce4f9cc660f930f7dccc712712d
> 
> Author: ZhiPeng Lu <lu.zhipeng@zte.com.cn>
> 
> Date:   Fri Nov 3 22:54:20 2017 +0800
> 
> 
>     qga: replace GetIfEntry
> 
>     
> 
>     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
> 
>     Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> 
> 
> commit 5ca7a3cba468736cfe555887af1f6ba754f6eac9
> 
> Merge: a4f0537 10a7b7e
> 
> Author: Peter Maydell <peter.maydell@linaro.org>
> 
> Date:   Tue Nov 7 14:43:35 2017 +0000
> 
> 
>     Merge remote-tracking branch 'remotes/berrange/tags/pull-2017-11-06-2' into
> staging
> 
>     
> 
>     Pull IO 2017/11/06 v2
> 
> 
> 
> 
> 为了让您的VPlat虚拟机故障和docker故障得到高效的处理,请上报故障到: $VPlat技术支
> 持。
> 
> 芦志朋 luzhipeng
> 
> 
> IT开发工程师 IT Development Engineer
> 操作系统产品部/中心研究院/系统产品 OS Product Dept./Central R&D Institute/
> System Product
> 
> 
> [cid]          [cid]
>                四川省成都市天府大道中段800号
>                E: lu.zhipeng@zte.com.cn
>                www.zte.com.cn
> 
> 原始邮件
> 发件人: <mdroth@linux.vnet.ibm.com>;
> 收件人:芦志朋10108272;
> 抄送人: <qemu-devel@nongnu.org>;
> 日期:2017年11月14日 07:57
> 主题:Re: 答复: Re: [PATCH v2] qga: replace GetIfEntry
> Quoting lu.zhipeng@zte.com.cn (2017-11-09 05:26:15)
> >  i think the code is better
> > 
> >  if (OSver.dwMajorVersion >= 6) {
> >       MIB_IF_ROW2 aMib_ifrow;
> >       typedef NETIOAPI_API (WINAPI *getifentry2_t)(PMIB_IF_ROW2 Row);
> >       memset(&aMib_ifrow, 0, sizeof(aMib_ifrow));
> >       aMib_ifrow.InterfaceIndex = nicId;
> >       HMODULE module = GetModuleHandle("iphlpapi");
> >       PVOID fun = GetProcAddress(module, "GetIfEntry2");
> >       if (fun == NULL) {
> >           error_setg(errp, QERR_QGA_COMMAND_FAILED,
> >                      "Failed to get address of GetIfEntry2");
> >           return NULL;
> >       }
> >     getifentry2_t getifentry2_ex = (getifentry2_t)fun;
> >     if (NO_ERROR == getifentry2_ex(&aMib_ifrow)){
> >     }
> 
> I've updated the patch with this change:
>   https://github.com/mdroth/qemu/commits/qga-if-stats
> 
> But I'm a bit confused now: when I tried to test this on XP I realized that
> that qemu-ga no longer works on XP, and generates the following error
> when I try to start it (even without your stats patch):
> 
>   "The procedure entry point AcquireSRWLockExclusive could not be located
>    in the dynamic link library KERNEL32.dll"
> 
> I think this may be due to the following commit, which notes that Vista+
> are now required as a result:
> 
> commit 12f8def0e02232d7c6416ad9b66640f973c531d1
> Author: Andrey Shedel <ashedel@microsoft.com>
> Date:   Fri Mar 24 15:01:41 2017 -0700
> 
>     win32: replace custom mutex and condition variable with native
>     primitives
> 
> So, are you actually able to run on XP currently? If so, how? And if
> not, I think we have other issues that need to be addressed if we
> want to support XP still; I'm not even sure that's realistic at this
> point.
> 
> Unless there's actually a way to test QGA on XP right now I think I
> we should just get in the updated patch minus the dynamic DLL stuff,
> i.e.:
>   https://github.com/mdroth/qemu/commit/
> de597a8b27722ce4f9cc660f930f7dccc712712d
> 
> Make sense?
> 
> > 
> > 
> > 
> > 
> > 
> > 为了让您的VPlat虚拟机故障和docker故障得到高效的处理,请上报故障到: $VPlat技术
> 支
> > 持。
> > 
> > 芦志朋 luzhipeng
> > 
> > 
> > IT开发工程师 IT Development Engineer
> > 操作系统产品部/中心研究院/系统产品 OS Product Dept./Central R&D Institute/
> > System Product
> > 
> > 
> > [cid]          [cid]
> >                四川省成都市天府大道中段800号
> >                E: lu.zhipeng@zte.com.cn
> >                www.zte.com.cn
> > 
> > 原始邮件
> > 发件人:芦志朋10108272
> > 收件人: <mdroth@linux.vnet.ibm.com>;
> > 抄送人: <qemu-devel@nongnu.org>;
> > 日期:2017年11月08日 10:54
> > 主题:答复: Re: [PATCH v2] qga: replace GetIfEntry
> > 
> > 
> > >I have the modified patch staged here:
> > 
> > >  https://github.com/mdroth/qemu/commit/
> > de597a8b27722ce4f9cc660f930f7dccc712712d
> > >Let me know if it looks okay and I'll send a pull request for rc1
> > 
> >  
> > 
> >
>  the code right, but running QGA on the Windows XP, error: can not find the link
> > to  GetIfEntry2 in iphlpapi.DLL.
> > 
> > 
> > 
> > 
> > 为了让您的VPlat虚拟机故障和docker故障得到高效的处理,请上报故障到: $VPlat技术
> 支
> > 持。
> > 
> > 芦志朋 luzhipeng
> > 
> > 
> > IT开发工程师 IT Development Engineer
> > 操作系统产品部/中心研究院/系统产品 OS Product Dept./Central R&D Institute/
> > System Product
> > 
> > 
> > [cid]          [cid]
> >                四川省成都市天府大道中段800号
> >                E: lu.zhipeng@zte.com.cn
> >                www.zte.com.cn
> > 
> > 
> > 发件人: <mdroth@linux.vnet.ibm.com>;
> > 收件人:芦志朋10108272;
> > 抄送人: <qemu-devel@nongnu.org>;芦志朋10108272;
> > 日期:2017年11月08日 01:07
> > 主题:Re: [PATCH v2] qga: replace GetIfEntry
> > 
> > 
> > Quoting ZhiPeng Lu (2017-11-03 09:54:20)
> > >
> >
>   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>
> > > ---
> > >  qga/commands-win32.c | 31 ++++++++++++++++++-------------
> > >  1 file changed, 18 insertions(+), 13 deletions(-)
> > > 
> > > diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> > > index 0322188..d096dc2 100644
> > > --- a/qga/commands-win32.c
> > > +++ b/qga/commands-win32.c
> > > @@ -1173,20 +1173,25 @@ static int guest_get_network_stats
> (const char *name,
> > >                         GuestNetworkInterfaceStat *stats)
> > >  {
> > >      DWORD if_index = 0;
> > > -    MIB_IFROW a_mid_ifrow;
> > > -    memset(&a_mid_ifrow, 0, sizeof(a_mid_ifrow));
> > > +    OSVERSIONINFO OSver;
> > >      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;
> > > +    OSver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
> > > +    GetVersionEx(&OSver);
> > > +    if (OSver.dwMajorVersion >= 6) {
> > > +        MIB_IF_ROW2 a_mid_ifrow;
> > > +        memset(&a_mid_ifrow, 0, sizeof(a_mid_ifrow));
> > > +        a_mid_ifrow.dwIndex = if_index;
> > > +        if (NO_ERROR == GetIfEntry2(&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;
> > 
> > This fails to build in my fc20 mingw64 environment:
> > 
> > /home/mdroth/w/qemu4.git/qga/
> > commands-win32.c:1184:20: error: 'MIB_IF_ROW2' has no member named 'dwIndex'
> >          a_mid_ifrow.dwIndex = if_index;
> >                     ^
> > /home/mdroth/w/qemu4.git/qga/
> >
>  commands-win32.c:1186:42: error: 'MIB_IF_ROW2' has no member named 'dwInOctets'
> >              stats->rx_bytes = a_mid_ifrow.dwInOctets;
> >                                           ^
> > /home/mdroth/w/qemu4.git/qga/
> >
>  commands-win32.c:1187:44: error: 'MIB_IF_ROW2' has no member named 'dwInUcastPkts'
> >              stats->rx_packets = a_mid_ifrow.dwInUcastPkts;
> > 
> > etc ...
> > 
> > The patch seems to assume MIB_IFROW and MIB_IF_ROW2 have the same field names
> > for the stats, but according to this they're slightly different:
> > 
> >   https://msdn.microsoft.com/en-us/library/windows/desktop/aa814491(v=
> > vs.85).aspx
> > 
> > This change on top of your patch seems to work:
> > 
> > diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> > index e17fc3c284..58e470877f 100644
> > --- a/qga/commands-win32.c
> > +++ b/qga/commands-win32.c
> > @@ -1181,16 +1181,16 @@ static int guest_get_network_stats(const char *name,
> >      if (os_ver.dwMajorVersion >= 6) {
> >          MIB_IF_ROW2 a_mid_ifrow;
> >          memset(&a_mid_ifrow, 0, sizeof(a_mid_ifrow));
> > -        a_mid_ifrow.dwIndex = if_index;
> > +        a_mid_ifrow.InterfaceIndex = if_index;
> >          if (NO_ERROR == GetIfEntry2(&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;
> > +            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;
> >          }
> >      }
> > 
> > I have the modified patch staged here:
> > 
> >   https://github.com/mdroth/qemu/commit/
> > de597a8b27722ce4f9cc660f930f7dccc712712d
> > 
> > Let me know if it looks okay and I'll send a pull request for rc1
> > 
> > > +        }
> > >      }
> > >      return -1;
> > >  }
> > > -- 
> > > 1.8.3.1
> > > 
> > 
> > 
> 
>

[-- Attachment #2: 24242e5637af428891c4db731e7765ad.jpg --]
[-- Type: image/jpeg, Size: 2064 bytes --]

[-- Attachment #3: 9ae3e214c17d49ed935d87c674ba3ee2.jpg --]
[-- Type: image/jpeg, Size: 6015 bytes --]

  reply	other threads:[~2017-11-15  1:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-03 14:54 [Qemu-devel] [PATCH v2] qga: replace GetIfEntry ZhiPeng Lu
2017-11-03 17:54 ` no-reply
2017-11-07 17:06 ` Michael Roth
2017-11-08  2:54   ` [Qemu-devel] 答复: " lu.zhipeng
2017-11-09 11:26     ` lu.zhipeng
2017-11-13 23:57       ` Michael Roth
2017-11-14  2:32         ` [Qemu-devel] 答复:Re: " lu.zhipeng
2017-11-14 11:09         ` [Qemu-devel] 答复: " lu.zhipeng
2017-11-15  1:21           ` Michael Roth
2017-11-15  1:41             ` lu.zhipeng [this message]
2017-11-15  2:22               ` [Qemu-devel] 答复: " Michael Roth
2017-11-15  2:48                 ` [Qemu-devel] 答复: " lu.zhipeng
2017-11-20 21:57               ` [Qemu-devel] " Michael Roth

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=201711150941584900906@zte.com.cn \
    --to=lu.zhipeng@zte.com.cn \
    --cc=mdroth@linux.vnet.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.