]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
domain: Introduce virDomainIOThreadsPin{Add|Del}
authorJohn Ferlan <jferlan@redhat.com>
Tue, 17 Feb 2015 17:22:48 +0000 (12:22 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 11 Mar 2015 16:23:33 +0000 (12:23 -0400)
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.

src/conf/domain_conf.c
src/conf/domain_conf.h
src/libvirt_private.syms

index 83f3ec673175ee366a402c0f41984c82bbe5671a..127fc911ef27c1fec0e0b62236cece18b101af4b 100644 (file)
@@ -16798,6 +16798,70 @@ virDomainEmulatorPinDel(virDomainDefPtr def)
     return 0;
 }
 
+int
+virDomainIOThreadsPinAdd(virDomainVcpuPinDefPtr **iothreadspin_list,
+                         size_t *niothreadspin,
+                         unsigned char *cpumap,
+                         int maplen,
+                         unsigned int iothread_id)
+{
+    /* IOThreads share the virDomainVcpuPinDefPtr */
+    virDomainVcpuPinDefPtr iothreadpin = NULL;
+
+    if (!iothreadspin_list)
+        return -1;
+
+    iothreadpin = virDomainVcpuPinFindByVcpu(*iothreadspin_list,
+                                             *niothreadspin,
+                                             iothread_id);
+    if (iothreadpin) {
+        iothreadpin->vcpuid = iothread_id;
+        virBitmapFree(iothreadpin->cpumask);
+        iothreadpin->cpumask = virBitmapNewData(cpumap, maplen);
+        if (!iothreadpin->cpumask)
+            return -1;
+
+        return 0;
+    }
+
+    /* No existing iothreadpin matches iothread_id, adding a new one */
+
+    if (VIR_ALLOC(iothreadpin) < 0)
+        goto error;
+
+    iothreadpin->vcpuid = iothread_id;
+    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,
+                         unsigned int iothread_id)
+{
+    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_id) {
+            virBitmapFree(iothreadspin_list[i]->cpumask);
+            VIR_DELETE_ELEMENT(def->cputune.iothreadspin, i,
+                               def->cputune.niothreadspin);
+            return;
+        }
+    }
+}
+
 static int
 virDomainEventActionDefFormat(virBufferPtr buf,
                               int type,
index 36bb418a1e6a5f95683857cbbf0096c9afa20ede..ea463cb8727df2f53e664ce8524aaec67bce8f98 100644 (file)
@@ -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,
+                             unsigned int iothread_id);
+
+void virDomainIOThreadsPinDel(virDomainDefPtr def,
+                              unsigned int iothread_id);
+
 void virDomainRNGDefFree(virDomainRNGDefPtr def);
 
 bool virDomainDiskDefDstDuplicates(virDomainDefPtr def);
index 64808ce9f4fcdc6526b575ca452e0247d4358668..7262c95c6c6f6f3c6eabc9dfc4d7bbb0fa75421a 100644 (file)
@@ -308,6 +308,8 @@ virDomainHubTypeToString;
 virDomainHypervTypeFromString;
 virDomainHypervTypeToString;
 virDomainInputDefFree;
+virDomainIOThreadsPinAdd;
+virDomainIOThreadsPinDel;
 virDomainLeaseDefFree;
 virDomainLeaseIndex;
 virDomainLeaseInsert;