]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_driver: move iothread existence check into one place
authorPavel Hrdina <phrdina@redhat.com>
Sun, 12 Feb 2017 18:13:47 +0000 (19:13 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 20 Feb 2017 17:44:02 +0000 (18:44 +0100)
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_driver.c

index 6fb7836c7e061aedd808cc3bbe53765923d0e44f..98cf06bd681f9d8c002c54f9e8b4e718f56a0b6e 100644 (file)
@@ -5677,21 +5677,6 @@ qemuDomainHotplugDelIOThread(virQEMUDriverPtr driver,
     int new_niothreads = 0;
     qemuMonitorIOThreadInfoPtr *new_iothreads = NULL;
 
-    /* Normally would use virDomainIOThreadIDFind, but we need the index
-     * from whence to delete for later...
-     */
-    for (idx = 0; idx < vm->def->niothreadids; idx++) {
-        if (iothread_id == vm->def->iothreadids[idx]->iothread_id)
-            break;
-    }
-
-    if (idx == vm->def->niothreadids) {
-        virReportError(VIR_ERR_INVALID_ARG,
-                       _("cannot find IOThread '%u' in iothreadids list"),
-                       iothread_id);
-        return -1;
-    }
-
     if (virAsprintf(&alias, "iothread%u", iothread_id) < 0)
         return -1;
 
@@ -5747,6 +5732,13 @@ qemuDomainDelIOThreadCheck(virDomainDefPtr def,
 {
     size_t i;
 
+    if (!virDomainIOThreadIDFind(def, iothread_id)) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("cannot find IOThread '%u' in iothreadids list"),
+                       iothread_id);
+        return -1;
+    }
+
     for (i = 0; i < def->ndisks; i++) {
         if (def->disks[i]->iothread == iothread_id) {
             virReportError(VIR_ERR_INVALID_ARG,
@@ -5811,16 +5803,6 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver,
                 goto endjob;
 
         } else {
-            virDomainIOThreadIDDefPtr iothrid;
-            if (!(iothrid = virDomainIOThreadIDFind(persistentDef,
-                                                    iothread_id))) {
-                virReportError(VIR_ERR_INVALID_ARG,
-                               _("cannot find IOThread '%u' in persistent "
-                                 "iothreadids"),
-                               iothread_id);
-                goto endjob;
-            }
-
             if (qemuDomainDelIOThreadCheck(persistentDef, iothread_id) < 0)
                 goto endjob;