s/introducing/introduce/
On Mon, Feb 17, 2020 at 04:29:11PM -0500, Daniel Henrique Barboza wrote:
There is duplicated code between virt drivers that needs to
be moved to avoid code repetition. In the case of duplicated
code between lxc_cgroup.c and qemu_cgroup.c a common place
would be utils/vircgroup.c. The problem is that this would
introduce /conf related definitions that shouldn't be imported
to vircgroup.c, which is supposed to be a place for utilitary
cgroups functions only. And syntax-check would forbid it anyway
due to cross-directory includes being used.
An alternative would be to overload domain_conf.c, which already
contains all the definitions required. But that file is already
crowded with XML handling code and we wouldn't do any favors to
it by putting more utilitary, non-XML parsing/formatting code
there.
In [1], Colesuggested a 'domain_cgroup' file to host common code
missing space
between lxc_cgroup and qemu_cgroup, and Daniel suggested a
'src/hypervisor' dir to host these type of files. This patch
introduces src/hypervisor/domain_cgroup.c and, to get started,
introduces a new virDomainCgroupSetupBlkio() function to host shared
code between virLXCCgroupSetupBlkioTune() and qemuSetupBlkioCgroup().
[1]
https://www.redhat.com/archives/libvir-list/2019-December/msg00817.html
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/Makefile.am | 1 +
src/hypervisor/Makefile.inc.am | 14 +++++++
src/hypervisor/domain_cgroup.c | 67 ++++++++++++++++++++++++++++++++++
src/hypervisor/domain_cgroup.h | 27 ++++++++++++++
src/libvirt_private.syms | 4 ++
src/lxc/Makefile.inc.am | 2 +
src/lxc/lxc_cgroup.c | 40 +-------------------
src/qemu/Makefile.inc.am | 1 +
src/qemu/qemu_cgroup.c | 40 +-------------------
9 files changed, 120 insertions(+), 76 deletions(-)
create mode 100644 src/hypervisor/Makefile.inc.am
create mode 100644 src/hypervisor/domain_cgroup.c
create mode 100644 src/hypervisor/domain_cgroup.h
Reviewed-by: Ján Tomko <jtomko(a)redhat.com>
Jano