include admin/Makefile.inc.am
include rpc/Makefile.inc.am
include test/Makefile.inc.am
+include hypervisor/Makefile.inc.am
include esx/Makefile.inc.am
include hyperv/Makefile.inc.am
include vmx/Makefile.inc.am
--- /dev/null
+# vim: filetype=automake
+
+HYPERVISOR_SOURCES = \
+ hypervisor/domain_cgroup.h \
+ hypervisor/domain_cgroup.c \
+ $(NULL)
+
+noinst_LTLIBRARIES += libvirt_hypervisor.la
+libvirt_la_BUILT_LIBADD += libvirt_hypervisor.la
+libvirt_hypervisor_la_CFLAGS = \
+ -I$(srcdir)/conf \
+ $(AM_CFLAGS) \
+ $(NULL)
+libvirt_hypervisor_la_SOURCES = $(HYPERVISOR_SOURCES)
--- /dev/null
+/*
+ * domain_cgroup.c: cgroup functions shared between hypervisor drivers
+ *
+ * Copyright IBM Corp. 2020
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include "domain_cgroup.h"
+
+
+int
+virDomainCgroupSetupBlkio(virCgroupPtr cgroup, virDomainBlkiotune blkio)
+{
+ size_t i;
+
+ if (blkio.weight != 0 &&
+ virCgroupSetBlkioWeight(cgroup, blkio.weight) < 0)
+ return -1;
+
+ if (blkio.ndevices) {
+ for (i = 0; i < blkio.ndevices; i++) {
+ virBlkioDevicePtr dev = &blkio.devices[i];
+
+ if (dev->weight &&
+ virCgroupSetupBlkioDeviceWeight(cgroup, dev->path,
+ &dev->weight) < 0)
+ return -1;
+
+ if (dev->riops &&
+ virCgroupSetupBlkioDeviceReadIops(cgroup, dev->path,
+ &dev->riops) < 0)
+ return -1;
+
+ if (dev->wiops &&
+ virCgroupSetupBlkioDeviceWriteIops(cgroup, dev->path,
+ &dev->wiops) < 0)
+ return -1;
+
+ if (dev->rbps &&
+ virCgroupSetupBlkioDeviceReadBps(cgroup, dev->path,
+ &dev->rbps) < 0)
+ return -1;
+
+ if (dev->wbps &&
+ virCgroupSetupBlkioDeviceWriteBps(cgroup, dev->path,
+ &dev->wbps) < 0)
+ return -1;
+ }
+ }
+
+ return 0;
+}
--- /dev/null
+/*
+ * domain_cgroup.h: cgroup functions shared between hypervisor drivers
+ *
+ * Copyright IBM Corp. 2020
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "vircgroup.h"
+#include "domain_conf.h"
+
+
+int virDomainCgroupSetupBlkio(virCgroupPtr cgroup, virDomainBlkiotune blkio);
virSetConnectStorage;
+# hypervisor/domain_cgroup.h
+virDomainCgroupSetupBlkio;
+
+
# libvirt_internal.h
virConnectSupportsFeature;
virDomainMigrateBegin3;
-I$(srcdir)/conf \
-I$(builddir)/lxc \
-I$(builddir)/rpc \
+ -I$(srcdir)/hypervisor \
$(AM_CFLAGS) \
$(NULL)
libvirt_driver_lxc_impl_la_LIBADD = \
-I$(srcdir)/conf \
-I$(builddir)/lxc \
-I$(builddir)/rpc \
+ -I$(srcdir)/hypervisor \
$(AM_CFLAGS) \
$(PIE_CFLAGS) \
$(CAPNG_CFLAGS) \
#include "lxc_cgroup.h"
#include "lxc_container.h"
+#include "domain_cgroup.h"
#include "virfile.h"
#include "virerror.h"
#include "virlog.h"
static int virLXCCgroupSetupBlkioTune(virDomainDefPtr def,
virCgroupPtr cgroup)
{
- size_t i;
-
- if (def->blkio.weight &&
- virCgroupSetBlkioWeight(cgroup, def->blkio.weight) < 0)
- return -1;
-
- if (def->blkio.ndevices) {
- for (i = 0; i < def->blkio.ndevices; i++) {
- virBlkioDevicePtr dev = &def->blkio.devices[i];
-
- if (dev->weight &&
- virCgroupSetupBlkioDeviceWeight(cgroup, dev->path,
- &dev->weight) < 0)
- return -1;
-
- if (dev->riops &&
- virCgroupSetupBlkioDeviceReadIops(cgroup, dev->path,
- &dev->riops) < 0)
- return -1;
-
- if (dev->wiops &&
- virCgroupSetupBlkioDeviceWriteIops(cgroup, dev->path,
- &dev->wiops) < 0)
- return -1;
-
- if (dev->rbps &&
- virCgroupSetupBlkioDeviceReadBps(cgroup, dev->path,
- &dev->rbps) < 0)
- return -1;
-
- if (dev->wbps &&
- virCgroupSetupBlkioDeviceWriteBps(cgroup, dev->path,
- &dev->wbps) < 0)
- return -1;
- }
- }
-
- return 0;
+ return virDomainCgroupSetupBlkio(cgroup, def->blkio);
}
-I$(builddir)/access \
-I$(srcdir)/conf \
-I$(srcdir)/secret \
+ -I$(srcdir)/hypervisor \
$(AM_CFLAGS) \
$(NULL)
libvirt_driver_qemu_impl_la_LDFLAGS = $(AM_LDFLAGS)
#include "viralloc.h"
#include "virerror.h"
#include "domain_audit.h"
+#include "domain_cgroup.h"
#include "virscsi.h"
#include "virstring.h"
#include "virfile.h"
qemuSetupBlkioCgroup(virDomainObjPtr vm)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
- size_t i;
if (!virCgroupHasController(priv->cgroup,
VIR_CGROUP_CONTROLLER_BLKIO)) {
}
}
- if (vm->def->blkio.weight != 0 &&
- virCgroupSetBlkioWeight(priv->cgroup, vm->def->blkio.weight) < 0)
- return -1;
-
- if (vm->def->blkio.ndevices) {
- for (i = 0; i < vm->def->blkio.ndevices; i++) {
- virBlkioDevicePtr dev = &vm->def->blkio.devices[i];
- virCgroupPtr cgroup = priv->cgroup;
-
- if (dev->weight &&
- virCgroupSetupBlkioDeviceWeight(cgroup, dev->path,
- &dev->weight) < 0)
- return -1;
-
- if (dev->riops &&
- virCgroupSetupBlkioDeviceReadIops(cgroup, dev->path,
- &dev->riops) < 0)
- return -1;
-
- if (dev->wiops &&
- virCgroupSetupBlkioDeviceWriteIops(cgroup, dev->path,
- &dev->wiops) < 0)
- return -1;
-
- if (dev->rbps &&
- virCgroupSetupBlkioDeviceReadBps(cgroup, dev->path,
- &dev->rbps) < 0)
- return -1;
-
- if (dev->wbps &&
- virCgroupSetupBlkioDeviceWriteBps(cgroup, dev->path,
- &dev->wbps) < 0)
- return -1;
- }
- }
-
- return 0;
+ return virDomainCgroupSetupBlkio(priv->cgroup, vm->def->blkio);
}