]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
test_driver: Implement virDomainPinIOThread
authorLuke Yue <lukedyue@gmail.com>
Wed, 15 Sep 2021 15:30:28 +0000 (23:30 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 23 Sep 2021 11:41:24 +0000 (13:41 +0200)
Signed-off-by: Luke Yue <lukedyue@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/test/test_driver.c

index a8d102c445e0c1fd9b2fa1011607a03ea071e7cb..e83b94901c04a8c5608c13073cc5f0b4c2357a23 100644 (file)
@@ -9754,6 +9754,55 @@ testDomainDelIOThread(virDomainPtr dom,
     return ret;
 }
 
+static int
+testDomainPinIOThread(virDomainPtr dom,
+                      unsigned int iothread_id,
+                      unsigned char *cpumap,
+                      int maplen,
+                      unsigned int flags)
+{
+    int ret = -1;
+    virDomainObj *vm;
+    virDomainDef *def;
+    virDomainIOThreadIDDef *iothrid;
+    virBitmap *cpumask = NULL;
+
+    virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+                  VIR_DOMAIN_AFFECT_CONFIG, -1);
+
+    if (!(vm = testDomObjFromDomain(dom)))
+        goto cleanup;
+
+    if (!(def = virDomainObjGetOneDef(vm, flags)))
+        goto cleanup;
+
+    if (!(cpumask = virBitmapNewData(cpumap, maplen)))
+        goto cleanup;
+
+    if (virBitmapIsAllClear(cpumask)) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("Empty iothread cpumap list for pinning"));
+        goto cleanup;
+    }
+
+    if (!(iothrid = virDomainIOThreadIDFind(def, iothread_id))) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("iothreadid %d not found"), iothread_id);
+        goto cleanup;
+    }
+
+    virBitmapFree(iothrid->cpumask);
+    iothrid->cpumask = g_steal_pointer(&cpumask);
+    iothrid->autofill = false;
+
+    ret = 0;
+
+ cleanup:
+    virBitmapFree(cpumask);
+    virDomainObjEndAPI(&vm);
+    return ret;
+}
+
 /*
  * Test driver
  */
@@ -9823,6 +9872,7 @@ static virHypervisorDriver testHypervisorDriver = {
     .domainGetIOThreadInfo = testDomainGetIOThreadInfo, /* 7.8.0 */
     .domainAddIOThread = testDomainAddIOThread, /* 7.8.0 */
     .domainDelIOThread = testDomainDelIOThread, /* 7.8.0 */
+    .domainPinIOThread = testDomainPinIOThread, /* 7.8.0 */
     .domainGetSecurityLabel = testDomainGetSecurityLabel, /* 7.5.0 */
     .nodeGetSecurityModel = testNodeGetSecurityModel, /* 7.5.0 */
     .domainGetXMLDesc = testDomainGetXMLDesc, /* 0.1.4 */