@SRCDIR@/src/hyperv/hyperv_driver.c
@SRCDIR@/src/hyperv/hyperv_util.c
@SRCDIR@/src/hyperv/hyperv_wmi.c
+@SRCDIR@/src/hypervisor/domain_driver.c
@SRCDIR@/src/interface/interface_backend_netcf.c
@SRCDIR@/src/interface/interface_backend_udev.c
@SRCDIR@/src/internal.h
HYPERVISOR_SOURCES = \
hypervisor/domain_cgroup.h \
hypervisor/domain_cgroup.c \
+ hypervisor/domain_driver.h \
+ hypervisor/domain_driver.c \
$(NULL)
noinst_LTLIBRARIES += libvirt_hypervisor.la
--- /dev/null
+/*
+ * domain_driver.c: general 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_driver.h"
+#include "viralloc.h"
+
+#define VIR_FROM_THIS VIR_FROM_DOMAIN
+
+
+/* Modify dest_array to reflect all blkio device changes described in
+ * src_array. */
+int
+virDomainDriverMergeBlkioDevice(virBlkioDevicePtr *dest_array,
+ size_t *dest_size,
+ virBlkioDevicePtr src_array,
+ size_t src_size,
+ const char *type)
+{
+ size_t i, j;
+ virBlkioDevicePtr dest, src;
+
+ for (i = 0; i < src_size; i++) {
+ bool found = false;
+
+ src = &src_array[i];
+ for (j = 0; j < *dest_size; j++) {
+ dest = &(*dest_array)[j];
+ if (STREQ(src->path, dest->path)) {
+ found = true;
+
+ if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) {
+ dest->weight = src->weight;
+ } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) {
+ dest->riops = src->riops;
+ } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) {
+ dest->wiops = src->wiops;
+ } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) {
+ dest->rbps = src->rbps;
+ } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) {
+ dest->wbps = src->wbps;
+ } else {
+ virReportError(VIR_ERR_INVALID_ARG, _("Unknown parameter %s"),
+ type);
+ return -1;
+ }
+ break;
+ }
+ }
+ if (!found) {
+ if (!src->weight && !src->riops && !src->wiops && !src->rbps && !src->wbps)
+ continue;
+ if (VIR_EXPAND_N(*dest_array, *dest_size, 1) < 0)
+ return -1;
+ dest = &(*dest_array)[*dest_size - 1];
+
+ if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) {
+ dest->weight = src->weight;
+ } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) {
+ dest->riops = src->riops;
+ } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) {
+ dest->wiops = src->wiops;
+ } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) {
+ dest->rbps = src->rbps;
+ } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) {
+ dest->wbps = src->wbps;
+ } else {
+ *dest_size = *dest_size - 1;
+ return -1;
+ }
+
+ dest->path = src->path;
+ src->path = NULL;
+ }
+ }
+
+ return 0;
+}
--- /dev/null
+/*
+ * domain_driver.h: general 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 "domain_conf.h"
+
+int virDomainDriverMergeBlkioDevice(virBlkioDevicePtr *dest_array,
+ size_t *dest_size,
+ virBlkioDevicePtr src_array,
+ size_t src_size,
+ const char *type);
virDomainCgroupSetupMemtune;
+# hypervisor/domain_cgroup.h
+virDomainDriverMergeBlkioDevice;
+
+
# libvirt_internal.h
virConnectSupportsFeature;
virDomainMigrateBegin3;
#include "virpidfile.h"
#include "virfdstream.h"
#include "domain_audit.h"
+#include "domain_driver.h"
#include "domain_nwfilter.h"
#include "virinitctl.h"
#include "virnetdev.h"
return -1;
}
-static int
-lxcDomainMergeBlkioDevice(virBlkioDevicePtr *dest_array,
- size_t *dest_size,
- virBlkioDevicePtr src_array,
- size_t src_size,
- const char *type)
-{
- size_t i, j;
- virBlkioDevicePtr dest, src;
-
- for (i = 0; i < src_size; i++) {
- bool found = false;
-
- src = &src_array[i];
- for (j = 0; j < *dest_size; j++) {
- dest = &(*dest_array)[j];
- if (STREQ(src->path, dest->path)) {
- found = true;
-
- if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) {
- dest->weight = src->weight;
- } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) {
- dest->riops = src->riops;
- } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) {
- dest->wiops = src->wiops;
- } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) {
- dest->rbps = src->rbps;
- } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) {
- dest->wbps = src->wbps;
- } else {
- virReportError(VIR_ERR_INVALID_ARG, _("Unknown parameter %s"),
- type);
- return -1;
- }
-
- break;
- }
- }
- if (!found) {
- if (!src->weight && !src->riops && !src->wiops && !src->rbps && !src->wbps)
- continue;
- if (VIR_EXPAND_N(*dest_array, *dest_size, 1) < 0)
- return -1;
- dest = &(*dest_array)[*dest_size - 1];
-
- if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) {
- dest->weight = src->weight;
- } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) {
- dest->riops = src->riops;
- } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) {
- dest->wiops = src->wiops;
- } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) {
- dest->rbps = src->rbps;
- } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) {
- dest->wbps = src->wbps;
- } else {
- *dest_size = *dest_size - 1;
- return -1;
- }
-
- dest->path = src->path;
- src->path = NULL;
- }
- }
-
- return 0;
-}
-
-
static int
lxcDomainBlockStats(virDomainPtr dom,
const char *path,
}
if (j != ndevices ||
- lxcDomainMergeBlkioDevice(&def->blkio.devices,
- &def->blkio.ndevices,
- devices, ndevices, param->field) < 0)
+ virDomainDriverMergeBlkioDevice(&def->blkio.devices,
+ &def->blkio.ndevices,
+ devices, ndevices,
+ param->field) < 0)
ret = -1;
virBlkioDeviceArrayClear(devices, ndevices);
VIR_FREE(devices);
ret = -1;
continue;
}
- if (lxcDomainMergeBlkioDevice(&persistentDef->blkio.devices,
- &persistentDef->blkio.ndevices,
- devices, ndevices, param->field) < 0)
+ if (virDomainDriverMergeBlkioDevice(&persistentDef->blkio.devices,
+ &persistentDef->blkio.ndevices,
+ devices, ndevices,
+ param->field) < 0)
ret = -1;
virBlkioDeviceArrayClear(devices, ndevices);
VIR_FREE(devices);
#include "viruuid.h"
#include "domain_conf.h"
#include "domain_audit.h"
+#include "domain_driver.h"
#include "node_device_conf.h"
#include "virpci.h"
#include "virusb.h"
return -1;
}
-/* Modify dest_array to reflect all blkio device changes described in
- * src_array. */
-static int
-qemuDomainMergeBlkioDevice(virBlkioDevicePtr *dest_array,
- size_t *dest_size,
- virBlkioDevicePtr src_array,
- size_t src_size,
- const char *type)
-{
- size_t i, j;
- virBlkioDevicePtr dest, src;
-
- for (i = 0; i < src_size; i++) {
- bool found = false;
-
- src = &src_array[i];
- for (j = 0; j < *dest_size; j++) {
- dest = &(*dest_array)[j];
- if (STREQ(src->path, dest->path)) {
- found = true;
-
- if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) {
- dest->weight = src->weight;
- } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) {
- dest->riops = src->riops;
- } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) {
- dest->wiops = src->wiops;
- } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) {
- dest->rbps = src->rbps;
- } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) {
- dest->wbps = src->wbps;
- } else {
- virReportError(VIR_ERR_INVALID_ARG, _("Unknown parameter %s"),
- type);
- return -1;
- }
- break;
- }
- }
- if (!found) {
- if (!src->weight && !src->riops && !src->wiops && !src->rbps && !src->wbps)
- continue;
- if (VIR_EXPAND_N(*dest_array, *dest_size, 1) < 0)
- return -1;
- dest = &(*dest_array)[*dest_size - 1];
-
- if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) {
- dest->weight = src->weight;
- } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) {
- dest->riops = src->riops;
- } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) {
- dest->wiops = src->wiops;
- } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) {
- dest->rbps = src->rbps;
- } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) {
- dest->wbps = src->wbps;
- } else {
- *dest_size = *dest_size - 1;
- return -1;
- }
-
- dest->path = src->path;
- src->path = NULL;
- }
- }
-
- return 0;
-}
static int
qemuDomainSetBlkioParameters(virDomainPtr dom,
}
if (j != ndevices ||
- qemuDomainMergeBlkioDevice(&def->blkio.devices,
- &def->blkio.ndevices,
- devices, ndevices, param->field) < 0)
+ virDomainDriverMergeBlkioDevice(&def->blkio.devices,
+ &def->blkio.ndevices,
+ devices, ndevices,
+ param->field) < 0)
ret = -1;
virBlkioDeviceArrayClear(devices, ndevices);
VIR_FREE(devices);
ret = -1;
continue;
}
- if (qemuDomainMergeBlkioDevice(&persistentDef->blkio.devices,
- &persistentDef->blkio.ndevices,
- devices, ndevices, param->field) < 0)
+ if (virDomainDriverMergeBlkioDevice(&persistentDef->blkio.devices,
+ &persistentDef->blkio.ndevices,
+ devices, ndevices,
+ param->field) < 0)
ret = -1;
virBlkioDeviceArrayClear(devices, ndevices);
VIR_FREE(devices);