[PATCH v2 03/11] test_driver: Implement virDomainAddIOThread

Luke Yue lukedyue at gmail.com
Thu Jul 29 12:10:50 UTC 2021


Introduce testDomainChgIOThread at the same time

Signed-off-by: Luke Yue <lukedyue at gmail.com>
---
 src/test/meson.build   |  1 +
 src/test/test_driver.c | 77 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+)

diff --git a/src/test/meson.build b/src/test/meson.build
index f54585adfd..c0174ad856 100644
--- a/src/test/meson.build
+++ b/src/test/meson.build
@@ -17,6 +17,7 @@ if conf.has('WITH_TEST')
     ],
     include_directories: [
       conf_inc_dir,
+      hypervisor_inc_dir,
     ],
   )
 
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 7d9a81de54..3cabd6dc46 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -40,6 +40,7 @@
 #include "interface_conf.h"
 #include "checkpoint_conf.h"
 #include "domain_conf.h"
+#include "domain_driver.h"
 #include "domain_event.h"
 #include "network_event.h"
 #include "snapshot_conf.h"
@@ -9390,6 +9391,81 @@ testDomainCheckpointDelete(virDomainCheckpointPtr checkpoint,
     return ret;
 }
 
+typedef enum {
+    VIR_DOMAIN_IOTHREAD_ACTION_ADD,
+} virDomainIOThreadAction;
+
+static int
+testDomainChgIOThread(virDomainObj *vm,
+                      unsigned int iothread_id,
+                      virDomainIOThreadAction action,
+                      unsigned int flags)
+{
+    virDomainDef *def;
+    int ret = -1;
+
+    if (!(def = virDomainObjGetOneDef(vm, flags)))
+        return ret;
+
+    if (def) {
+        switch (action) {
+        case VIR_DOMAIN_IOTHREAD_ACTION_ADD:
+            if (virDomainDriverAddIOThreadCheck(def, iothread_id) < 0)
+                return ret;
+
+            if (!virDomainIOThreadIDAdd(def, iothread_id))
+                return ret;
+
+            break;
+        }
+    }
+
+    ret = 0;
+
+    return ret;
+}
+
+static int
+testDomainAddIOThread(virDomainPtr dom,
+                      unsigned int iothread_id,
+                      unsigned int flags)
+{
+    virDomainObj *vm = NULL;
+    testDomainObjPrivate *priv;
+    testIOThreadInfo iothread;
+    int ret = -1;
+
+    virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+                  VIR_DOMAIN_AFFECT_CONFIG, -1);
+
+    if (iothread_id == 0) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("invalid value of 0 for iothread_id"));
+        return -1;
+    }
+
+    if (!(vm = testDomObjFromDomain(dom)))
+        goto cleanup;
+
+    if (testDomainChgIOThread(vm, iothread_id,
+                              VIR_DOMAIN_IOTHREAD_ACTION_ADD, flags) < 0)
+        goto cleanup;
+
+    priv = vm->privateData;
+
+    iothread.iothread_id = iothread_id;
+    iothread.poll_max_ns = 32768;
+    iothread.poll_grow = 0;
+    iothread.poll_shrink = 0;
+
+    g_array_append_val(priv->iothreads, iothread);
+
+    ret = 0;
+
+ cleanup:
+    virDomainObjEndAPI(&vm);
+    return ret;
+}
 /*
  * Test driver
  */
@@ -9456,6 +9532,7 @@ static virHypervisorDriver testHypervisorDriver = {
     .domainGetVcpus = testDomainGetVcpus, /* 0.7.3 */
     .domainGetVcpuPinInfo = testDomainGetVcpuPinInfo, /* 1.2.18 */
     .domainGetMaxVcpus = testDomainGetMaxVcpus, /* 0.7.3 */
+    .domainAddIOThread = testDomainAddIOThread, /* 7.7.0 */
     .domainGetSecurityLabel = testDomainGetSecurityLabel, /* 7.5.0 */
     .nodeGetSecurityModel = testNodeGetSecurityModel, /* 7.5.0 */
     .domainGetXMLDesc = testDomainGetXMLDesc, /* 0.1.4 */
-- 
2.32.0




More information about the libvir-list mailing list