https://bugzilla.redhat.com/show_bug.cgi?id=1135491
More or less a virtual copy of the existing virDomainVcpuPin{Add|Del} API's.
NB: The IOThreads implementation "reused" the virDomainVcpuPinDefPtr
since it provided everything necessary - an "id" and a "map" for each
thread id configured.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/conf/domain_conf.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 10 ++++++++
src/libvirt_private.syms | 2 ++
3 files changed, 76 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6da02b0..fc4e8bd 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16708,6 +16708,70 @@ virDomainEmulatorPinDel(virDomainDefPtr def)
return 0;
}
+int
+virDomainIOThreadsPinAdd(virDomainVcpuPinDefPtr **iothreadspin_list,
+ size_t *niothreadspin,
+ unsigned char *cpumap,
+ int maplen,
+ int iothread_val)
+{
+ /* IOThreads share the virDomainVcpuPinDefPtr */
+ virDomainVcpuPinDefPtr iothreadpin = NULL;
+
+ if (!iothreadspin_list)
+ return -1;
+
+ iothreadpin = virDomainVcpuPinFindByVcpu(*iothreadspin_list,
+ *niothreadspin,
+ iothread_val);
+ if (iothreadpin) {
+ iothreadpin->vcpuid = iothread_val;
+ virBitmapFree(iothreadpin->cpumask);
+ iothreadpin->cpumask = virBitmapNewData(cpumap, maplen);
+ if (!iothreadpin->cpumask)
+ return -1;
+
+ return 0;
+ }
+
+ /* No existing iothreadpin matches iothread_val, adding a new one */
+
+ if (VIR_ALLOC(iothreadpin) < 0)
+ goto error;
+
+ iothreadpin->vcpuid = iothread_val;
+ iothreadpin->cpumask = virBitmapNewData(cpumap, maplen);
+ if (!iothreadpin->cpumask)
+ goto error;
+
+ if (VIR_APPEND_ELEMENT(*iothreadspin_list, *niothreadspin, iothreadpin) < 0)
+ goto error;
+
+ return 0;
+
+ error:
+ virDomainVcpuPinDefFree(iothreadpin);
+ return -1;
+}
+
+void
+virDomainIOThreadsPinDel(virDomainDefPtr def,
+ int iothread_val)
+{
+ size_t i;
+ /* IOThreads share the virDomainVcpuPinDefPtr */
+ virDomainVcpuPinDefPtr *iothreadspin_list = def->cputune.iothreadspin;
+
+ for (i = 0; i < def->cputune.niothreadspin; i++) {
+ if (iothreadspin_list[i]->vcpuid == iothread_val) {
+ virBitmapFree(iothreadspin_list[i]->cpumask);
+ VIR_DELETE_ELEMENT(def->cputune.iothreadspin, i,
+ def->cputune.niothreadspin);
+ return;
+ }
+ }
+}
+
static int
virDomainEventActionDefFormat(virBufferPtr buf,
int type,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 36bb418..17342a4 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2563,6 +2563,16 @@ int virDomainEmulatorPinAdd(virDomainDefPtr def,
int virDomainEmulatorPinDel(virDomainDefPtr def);
+/* IOThreads share the virDomainVcpuPinDefPtr */
+int virDomainIOThreadsPinAdd(virDomainVcpuPinDefPtr **iothreadspin_list,
+ size_t *niothreads,
+ unsigned char *cpumap,
+ int maplen,
+ int iothread_val);
+
+void virDomainIOThreadsPinDel(virDomainDefPtr def,
+ int iothread_val);
+
void virDomainRNGDefFree(virDomainRNGDefPtr def);
bool virDomainDiskDefDstDuplicates(virDomainDefPtr def);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index c810cf7..baacdc2 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -308,6 +308,8 @@ virDomainHubTypeToString;
virDomainHypervTypeFromString;
virDomainHypervTypeToString;
virDomainInputDefFree;
+virDomainIOThreadsPinAdd;
+virDomainIOThreadsPinDel;
virDomainLeaseDefFree;
virDomainLeaseIndex;
virDomainLeaseInsert;
--
2.1.0