mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-04 21:47:16 +03:00
util: virstatslinux: make more generic
Rename linuxDomainInterfaceStats to virNetInterfaceStats in order to allow adding platform specific implementations without making consumer worrying about specific implementation to be used. Also, rename util/virstatslinux.c to util/virstats.c so placing other platform specific implementations into this file don't look unexpected from the file name.
This commit is contained in:
parent
2f97ea328f
commit
5559a8b838
@ -198,7 +198,7 @@ src/util/virrandom.c
|
|||||||
src/util/virsexpr.c
|
src/util/virsexpr.c
|
||||||
src/util/virscsi.c
|
src/util/virscsi.c
|
||||||
src/util/virsocketaddr.c
|
src/util/virsocketaddr.c
|
||||||
src/util/virstatslinux.c
|
src/util/virstats.c
|
||||||
src/util/virstorageencryption.c
|
src/util/virstorageencryption.c
|
||||||
src/util/virstoragefile.c
|
src/util/virstoragefile.c
|
||||||
src/util/virstring.c
|
src/util/virstring.c
|
||||||
|
@ -149,7 +149,7 @@ UTIL_SOURCES = \
|
|||||||
util/virseclabel.c util/virseclabel.h \
|
util/virseclabel.c util/virseclabel.h \
|
||||||
util/virsexpr.c util/virsexpr.h \
|
util/virsexpr.c util/virsexpr.h \
|
||||||
util/virsocketaddr.h util/virsocketaddr.c \
|
util/virsocketaddr.h util/virsocketaddr.c \
|
||||||
util/virstatslinux.c util/virstatslinux.h \
|
util/virstats.c util/virstats.h \
|
||||||
util/virstorageencryption.c util/virstorageencryption.h \
|
util/virstorageencryption.c util/virstorageencryption.h \
|
||||||
util/virstoragefile.c util/virstoragefile.h \
|
util/virstoragefile.c util/virstoragefile.h \
|
||||||
util/virstring.h util/virstring.c \
|
util/virstring.h util/virstring.c \
|
||||||
|
@ -6,9 +6,6 @@
|
|||||||
linuxNodeGetCPUStats;
|
linuxNodeGetCPUStats;
|
||||||
linuxNodeInfoCPUPopulate;
|
linuxNodeInfoCPUPopulate;
|
||||||
|
|
||||||
# util/virstatslinux.h
|
|
||||||
linuxDomainInterfaceStats;
|
|
||||||
|
|
||||||
# Let emacs know we want case-insensitive sorting
|
# Let emacs know we want case-insensitive sorting
|
||||||
# Local Variables:
|
# Local Variables:
|
||||||
# sort-fold-case: t
|
# sort-fold-case: t
|
||||||
|
@ -1886,6 +1886,8 @@ virSocketAddrPrefixToNetmask;
|
|||||||
virSocketAddrSetIPv4Addr;
|
virSocketAddrSetIPv4Addr;
|
||||||
virSocketAddrSetPort;
|
virSocketAddrSetPort;
|
||||||
|
|
||||||
|
# util/virstats.h
|
||||||
|
virNetInterfaceStats;
|
||||||
|
|
||||||
# util/virstorageencryption.h
|
# util/virstorageencryption.h
|
||||||
virStorageEncryptionFormat;
|
virStorageEncryptionFormat;
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
#include "virnetdevveth.h"
|
#include "virnetdevveth.h"
|
||||||
#include "nodeinfo.h"
|
#include "nodeinfo.h"
|
||||||
#include "viruuid.h"
|
#include "viruuid.h"
|
||||||
#include "virstatslinux.h"
|
#include "virstats.h"
|
||||||
#include "virhook.h"
|
#include "virhook.h"
|
||||||
#include "virfile.h"
|
#include "virfile.h"
|
||||||
#include "virpidfile.h"
|
#include "virpidfile.h"
|
||||||
@ -3132,7 +3132,7 @@ lxcDomainInterfaceStats(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
ret = linuxDomainInterfaceStats(path, stats);
|
ret = virNetInterfaceStats(path, stats);
|
||||||
else
|
else
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("Invalid path, '%s' is not a known interface"), path);
|
_("Invalid path, '%s' is not a known interface"), path);
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
#include "virlog.h"
|
#include "virlog.h"
|
||||||
#include "vircommand.h"
|
#include "vircommand.h"
|
||||||
#include "viruri.h"
|
#include "viruri.h"
|
||||||
#include "virstatslinux.h"
|
#include "virstats.h"
|
||||||
#include "virstring.h"
|
#include "virstring.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_OPENVZ
|
#define VIR_FROM_THIS VIR_FROM_OPENVZ
|
||||||
@ -2010,7 +2010,7 @@ openvzDomainInterfaceStats(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
ret = linuxDomainInterfaceStats(path, stats);
|
ret = virNetInterfaceStats(path, stats);
|
||||||
else
|
else
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("invalid path, '%s' is not a known interface"), path);
|
_("invalid path, '%s' is not a known interface"), path);
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
#include "virbuffer.h"
|
#include "virbuffer.h"
|
||||||
#include "nodeinfo.h"
|
#include "nodeinfo.h"
|
||||||
#include "virstatslinux.h"
|
#include "virstats.h"
|
||||||
#include "capabilities.h"
|
#include "capabilities.h"
|
||||||
#include "viralloc.h"
|
#include "viralloc.h"
|
||||||
#include "viruuid.h"
|
#include "viruuid.h"
|
||||||
@ -9765,7 +9765,6 @@ qemuDomainBlockStatsFlags(virDomainPtr dom,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
static int
|
static int
|
||||||
qemuDomainInterfaceStats(virDomainPtr dom,
|
qemuDomainInterfaceStats(virDomainPtr dom,
|
||||||
const char *path,
|
const char *path,
|
||||||
@ -9797,7 +9796,7 @@ qemuDomainInterfaceStats(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
ret = linuxDomainInterfaceStats(path, stats);
|
ret = virNetInterfaceStats(path, stats);
|
||||||
else
|
else
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("invalid path, '%s' is not a known interface"), path);
|
_("invalid path, '%s' is not a known interface"), path);
|
||||||
@ -9807,17 +9806,6 @@ qemuDomainInterfaceStats(virDomainPtr dom,
|
|||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
static int
|
|
||||||
qemuDomainInterfaceStats(virDomainPtr dom ATTRIBUTE_UNUSED,
|
|
||||||
const char *path ATTRIBUTE_UNUSED,
|
|
||||||
struct _virDomainInterfaceStats *stats ATTRIBUTE_UNUSED)
|
|
||||||
{
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
||||||
_("interface stats not implemented on this platform"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainSetInterfaceParameters(virDomainPtr dom,
|
qemuDomainSetInterfaceParameters(virDomainPtr dom,
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
#include "uml_conf.h"
|
#include "uml_conf.h"
|
||||||
#include "virbuffer.h"
|
#include "virbuffer.h"
|
||||||
#include "nodeinfo.h"
|
#include "nodeinfo.h"
|
||||||
#include "virstatslinux.h"
|
#include "virstats.h"
|
||||||
#include "capabilities.h"
|
#include "capabilities.h"
|
||||||
#include "viralloc.h"
|
#include "viralloc.h"
|
||||||
#include "viruuid.h"
|
#include "viruuid.h"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* virstatslinux.c: Linux block and network stats.
|
* virstats.c: Block and network stats.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2010 Red Hat, Inc.
|
* Copyright (C) 2007-2010 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
@ -22,23 +22,20 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
/* This file only applies on Linux. */
|
#include <stdio.h>
|
||||||
#ifdef __linux__
|
#include <stdlib.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <regex.h>
|
||||||
|
|
||||||
# include <stdio.h>
|
#include "virerror.h"
|
||||||
# include <stdlib.h>
|
#include "datatypes.h"
|
||||||
# include <fcntl.h>
|
#include "virstats.h"
|
||||||
# include <string.h>
|
#include "viralloc.h"
|
||||||
# include <unistd.h>
|
#include "virfile.h"
|
||||||
# include <regex.h>
|
|
||||||
|
|
||||||
# include "virerror.h"
|
#define VIR_FROM_THIS VIR_FROM_STATS_LINUX
|
||||||
# include "datatypes.h"
|
|
||||||
# include "virstatslinux.h"
|
|
||||||
# include "viralloc.h"
|
|
||||||
# include "virfile.h"
|
|
||||||
|
|
||||||
# define VIR_FROM_THIS VIR_FROM_STATS_LINUX
|
|
||||||
|
|
||||||
|
|
||||||
/*-------------------- interface stats --------------------*/
|
/*-------------------- interface stats --------------------*/
|
||||||
@ -46,10 +43,10 @@
|
|||||||
* NB. Caller must check that libvirt user is trying to query
|
* NB. Caller must check that libvirt user is trying to query
|
||||||
* the interface of a domain they own. We do no such checking.
|
* the interface of a domain they own. We do no such checking.
|
||||||
*/
|
*/
|
||||||
|
#ifdef __linux__
|
||||||
int
|
int
|
||||||
linuxDomainInterfaceStats(const char *path,
|
virNetInterfaceStats(const char *path,
|
||||||
struct _virDomainInterfaceStats *stats)
|
struct _virDomainInterfaceStats *stats)
|
||||||
{
|
{
|
||||||
int path_len;
|
int path_len;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
@ -117,5 +114,14 @@ linuxDomainInterfaceStats(const char *path,
|
|||||||
_("/proc/net/dev: Interface not found"));
|
_("/proc/net/dev: Interface not found"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
int
|
||||||
|
virNetInterfaceStats(const char *path ATTRIBUTE_UNUSED,
|
||||||
|
struct _virDomainInterfaceStats *stats ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
|
_("interface stats not implemented on this platform"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* __linux__ */
|
#endif /* __linux__ */
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* virstatslinux.h: Linux block and network stats.
|
* virstats.h: Block and network stats.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 Red Hat, Inc.
|
* Copyright (C) 2007 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
@ -23,13 +23,9 @@
|
|||||||
#ifndef __STATS_LINUX_H__
|
#ifndef __STATS_LINUX_H__
|
||||||
# define __STATS_LINUX_H__
|
# define __STATS_LINUX_H__
|
||||||
|
|
||||||
# ifdef __linux__
|
# include "internal.h"
|
||||||
|
|
||||||
# include "internal.h"
|
extern int virNetInterfaceStats(const char *path,
|
||||||
|
struct _virDomainInterfaceStats *stats);
|
||||||
extern int linuxDomainInterfaceStats(const char *path,
|
|
||||||
struct _virDomainInterfaceStats *stats);
|
|
||||||
|
|
||||||
# endif /* __linux__ */
|
|
||||||
|
|
||||||
#endif /* __STATS_LINUX_H__ */
|
#endif /* __STATS_LINUX_H__ */
|
@ -68,7 +68,7 @@
|
|||||||
#include "xen_driver.h"
|
#include "xen_driver.h"
|
||||||
#include "xen_hypervisor.h"
|
#include "xen_hypervisor.h"
|
||||||
#include "xs_internal.h"
|
#include "xs_internal.h"
|
||||||
#include "virstatslinux.h"
|
#include "virstats.h"
|
||||||
#include "block_stats.h"
|
#include "block_stats.h"
|
||||||
#include "xend_internal.h"
|
#include "xend_internal.h"
|
||||||
#include "virbuffer.h"
|
#include "virbuffer.h"
|
||||||
@ -1470,7 +1470,7 @@ xenHypervisorDomainInterfaceStats(virDomainDefPtr def,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return linuxDomainInterfaceStats(path, stats);
|
return virNetInterfaceStats(path, stats);
|
||||||
#else
|
#else
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("/proc/net/dev: Interface not found"));
|
_("/proc/net/dev: Interface not found"));
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
#include "virstatslinux.h"
|
#include "virstats.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "xen/block_stats.h"
|
#include "xen/block_stats.h"
|
||||||
#include "testutils.h"
|
#include "testutils.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user