Re: [PATCH v3 2/4] virstat: fix signature of virstat helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 18.11.2016 23:51, Mehdi Abaakouk wrote:
> From: Mehdi Abaakouk <sileht@xxxxxxxxxx>
> 
> In preparation to the code move to virnetdevtap.c, this change:
> 
> * renames virNetInterfaceStats to virNetDevTapInterfaceStats
> * changes 'path' to 'ifname', to use the same vocable as other
>   method in virnetdevtap.c.
> * Add the attributes checker
> ---
>  src/libvirt_private.syms   |  2 +-
>  src/libxl/libxl_driver.c   |  2 +-
>  src/lxc/lxc_driver.c       |  2 +-
>  src/openvz/openvz_driver.c |  2 +-
>  src/qemu/qemu_driver.c     |  4 ++--
>  src/util/virstats.c        | 22 +++++++++++-----------
>  src/util/virstats.h        |  5 +++--
>  src/xen/xen_hypervisor.c   |  2 +-
>  8 files changed, 21 insertions(+), 20 deletions(-)
> 
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index aa27f78..0036cbd 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -2367,7 +2367,7 @@ virSocketAddrSetIPv6AddrNetOrder;
>  virSocketAddrSetPort;
>  
>  # util/virstats.h
> -virNetInterfaceStats;
> +virNetDevTapInterfaceStats;
>  
>  # util/virstorageencryption.h
>  virStorageEncryptionFormat;
> diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
> index b2f3b16..67f0e58 100644
> --- a/src/libxl/libxl_driver.c
> +++ b/src/libxl/libxl_driver.c
> @@ -4982,7 +4982,7 @@ libxlDomainInterfaceStats(virDomainPtr dom,
>      }
>  
>      if (ret == 0)
> -        ret = virNetInterfaceStats(path, stats);
> +        ret = virNetDevTapInterfaceStats(path, stats);
>      else
>          virReportError(VIR_ERR_INVALID_ARG,
>                         _("'%s' is not a known interface"), path);
> diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
> index 4a0165a..526d40d 100644
> --- a/src/lxc/lxc_driver.c
> +++ b/src/lxc/lxc_driver.c
> @@ -2893,7 +2893,7 @@ lxcDomainInterfaceStats(virDomainPtr dom,
>      }
>  
>      if (ret == 0)
> -        ret = virNetInterfaceStats(path, stats);
> +        ret = virNetDevTapInterfaceStats(path, stats);
>      else
>          virReportError(VIR_ERR_INVALID_ARG,
>                         _("Invalid path, '%s' is not a known interface"), path);
> diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
> index 38a562e..7bd3acf 100644
> --- a/src/openvz/openvz_driver.c
> +++ b/src/openvz/openvz_driver.c
> @@ -2024,7 +2024,7 @@ openvzDomainInterfaceStats(virDomainPtr dom,
>      }
>  
>      if (ret == 0)
> -        ret = virNetInterfaceStats(path, stats);
> +        ret = virNetDevTapInterfaceStats(path, stats);
>      else
>          virReportError(VIR_ERR_INVALID_ARG,
>                         _("invalid path, '%s' is not a known interface"), path);
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 87ca09d..38208b1 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -11005,7 +11005,7 @@ qemuDomainInterfaceStats(virDomainPtr dom,
>          if (net->type == VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
>              ret = virNetDevOpenvswitchInterfaceStats(path, stats);
>          } else {
> -            ret = virNetInterfaceStats(path, stats);
> +            ret = virNetDevTapInterfaceStats(path, stats);
>          }
>      } else {
>          virReportError(VIR_ERR_INVALID_ARG,
> @@ -19154,7 +19154,7 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
>                  continue;
>              }
>          } else {
> -            if (virNetInterfaceStats(dom->def->nets[i]->ifname, &tmp) < 0) {
> +            if (virNetDevTapInterfaceStats(dom->def->nets[i]->ifname, &tmp) < 0) {
>                  virResetLastError();
>                  continue;
>              }
> diff --git a/src/util/virstats.c b/src/util/virstats.c
> index c4725ed..95b4c38 100644
> --- a/src/util/virstats.c
> +++ b/src/util/virstats.c
> @@ -50,10 +50,10 @@
>   */
>  #ifdef __linux__
>  int
> -virNetInterfaceStats(const char *path,
> -                     virDomainInterfaceStatsPtr stats)
> +virNetDevTapInterfaceStats(const char *ifname,
> +                           virDomainInterfaceStatsPtr stats)
>  {
> -    int path_len;
> +    int ifname_len;
>      FILE *fp;
>      char line[256], *colon;
>  
> @@ -64,7 +64,7 @@ virNetInterfaceStats(const char *path,
>          return -1;
>      }
>  
> -    path_len = strlen(path);
> +    ifname_len = strlen(ifname);
>  
>      while (fgets(line, sizeof(line), fp)) {
>          long long dummy;
> @@ -84,8 +84,8 @@ virNetInterfaceStats(const char *path,
>          colon = strchr(line, ':');
>          if (!colon) continue;
>          *colon = '\0';
> -        if (colon-path_len >= line &&
> -            STREQ(colon-path_len, path)) {
> +        if (colon-ifname_len >= line &&
> +            STREQ(colon-ifname_len, ifname)) {

While touching this you can fix the spaces around '-' sign.

>              /* IMPORTANT NOTE!
>               * /proc/net/dev vif<domid>.nn sees the network from the point
>               * of view of dom0 / hypervisor.  So bytes TRANSMITTED by dom0

ACK

Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux