[PATCH 03/13] hypervisor: domain: Extract code for checking iothread usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The code will be also needed for 'virtio-scsi' controller definitions.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/hypervisor/domain_driver.c | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c
index 9fbfec9f04..b7499a376f 100644
--- a/src/hypervisor/domain_driver.c
+++ b/src/hypervisor/domain_driver.c
@@ -537,6 +537,23 @@ virDomainDriverAddIOThreadCheck(virDomainDef *def,
     return 0;
 }

+
+static bool
+virDomainIothreadMappingDefHasIothread(GSList *iothreads,
+                                       unsigned int iothread_id)
+{
+    GSList *n;
+
+    for (n = iothreads; n; n = n->next) {
+        virDomainIothreadMappingDef *iothread = n->data;
+
+        if (iothread->id == iothread_id)
+            return true;
+    }
+
+    return false;
+}
+
 /**
  * virDomainDriverDelIOThreadCheck:
  * @def: domain definition
@@ -558,19 +575,7 @@ virDomainDriverDelIOThreadCheck(virDomainDef *def,
     }

     for (i = 0; i < def->ndisks; i++) {
-        GSList *n;
-        bool inuse = false;
-
-        for (n = def->disks[i]->iothreads; n; n = n->next) {
-            virDomainIothreadMappingDef *iothread = n->data;
-
-            if (iothread->id == iothread_id) {
-                inuse = true;
-                break;
-            }
-        }
-
-        if (inuse ||
+        if (virDomainIothreadMappingDefHasIothread(def->disks[i]->iothreads, iothread_id) ||
             def->disks[i]->iothread == iothread_id) {
             virReportError(VIR_ERR_INVALID_ARG,
                            _("cannot remove IOThread %1$u since it is being used by disk '%2$s'"),
-- 
2.48.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux