On Wed, Oct 30, 2019 at 11:42:12AM +0800, Mao Zhongyi wrote:
Both qemu and lxc drivers have some duplicate code when
dealing with cgroups, such as virLXCCgroupSetupBlkioTune()
and qemuSetupBlkioCgroup(), duplicate code over 80, so
consolidate the same chunk into a separate routine.
Signed-off-by: Mao Zhongyi <maozhongyi(a)cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju(a)cmss.chinamobile.com>
---
src/libvirt_private.syms | 1 +
src/lxc/lxc_cgroup.c | 56 +-----------------------------------
src/qemu/qemu_cgroup.c | 47 +------------------------------
src/util/vircgroup.c | 61 ++++++++++++++++++++++++++++++++++++++++
src/util/vircgroup.h | 3 ++
5 files changed, 67 insertions(+), 101 deletions(-)
diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
index 3eefe78787..9815c51fda 100644
--- a/src/util/vircgroup.h
+++ b/src/util/vircgroup.h
@@ -24,6 +24,7 @@
#include "virutil.h"
#include "virbitmap.h"
#include "virenum.h"
+#include "conf/domain_conf.h"
Code in src/util should not be including code from src/conf.
src/util is for the lowest level of utilities
src/conf can use code from src/util, but not the other way around
and various hypervisor drivers use code from those
I don't remember whether it was this particular function or something other
shared between LXC and QEMU, but my attempt to introduce a layer between
src/conf and the drivers was unsuccessful - probably due to too generic
naming (I proposed src/common).
So either the BlkioDevice data type needs to be defined in a lower layer
than src/conf, or we can just give up and put these functions somewehere
in src/conf/virblkio
Introducing a dependency on domain_conf.h here could lead to the same
recursive problems we have in src/util/virhostdev.h
Jano
struct _virCgroup;
typedef struct _virCgroup virCgroup;
@@ -123,6 +124,8 @@ int virCgroupAddThread(virCgroupPtr group, pid_t pid);
int virCgroupSetBlkioWeight(virCgroupPtr group, unsigned int weight);
int virCgroupGetBlkioWeight(virCgroupPtr group, unsigned int *weight);
+int virCgroupSetupBlkio(virCgroupPtr group, virDomainDefPtr def);
+
int virCgroupGetBlkioIoServiced(virCgroupPtr group,
long long *bytes_read,
long long *bytes_write,
--
2.17.1
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list