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

index 128dddbfbd85b5795e42234eb11a580f34535d89..ea2cd0eed78e8dbdbd5e2741072a467dd8bf55de 100644 (file)
@@ -20212,13 +20212,6 @@ virDomainIOThreadIDAdd(virDomainDefPtr def,
 {
     virDomainIOThreadIDDefPtr iothrid = NULL;
 
-    if (virDomainIOThreadIDFind(def, iothread_id)) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("cannot duplicate iothread_id '%u' in iothreadids"),
-                       iothread_id);
-        return NULL;
-    }
-
     if (VIR_ALLOC(iothrid) < 0)
         goto error;
 
index 013add5e9be84d024346510c9afd9fce7c83ef89..da9f10e65ef721a0666310cc0c4bb812817a80df 100644 (file)
@@ -5584,13 +5584,6 @@ qemuDomainHotplugAddIOThread(virQEMUDriverPtr driver,
     qemuMonitorIOThreadInfoPtr *new_iothreads = NULL;
     virDomainIOThreadIDDefPtr iothrid;
 
-    if (virDomainIOThreadIDFind(vm->def, iothread_id)) {
-        virReportError(VIR_ERR_INVALID_ARG,
-                       _("an IOThread is already using iothread_id '%u'"),
-                       iothread_id);
-        goto cleanup;
-    }
-
     if (virAsprintf(&alias, "iothread%u", iothread_id) < 0)
         return -1;
 
@@ -5726,6 +5719,22 @@ qemuDomainHotplugDelIOThread(virQEMUDriverPtr driver,
     goto cleanup;
 }
 
+
+static int
+qemuDomainAddIOThreadCheck(virDomainDefPtr def,
+                           unsigned int iothread_id)
+{
+    if (virDomainIOThreadIDFind(def, iothread_id)) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("an IOThread is already using iothread_id '%u'"),
+                       iothread_id);
+        return -1;
+    }
+
+    return 0;
+}
+
+
 static int
 qemuDomainDelIOThreadCheck(virDomainDefPtr def,
                            unsigned int iothread_id)
@@ -5793,6 +5802,9 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver,
         }
 
         if (add) {
+            if (qemuDomainAddIOThreadCheck(def, iothread_id) < 0)
+                goto endjob;
+
             if (qemuDomainHotplugAddIOThread(driver, vm, iothread_id) < 0)
                 goto endjob;
         } else {
@@ -5809,6 +5821,9 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver,
 
     if (persistentDef) {
         if (add) {
+            if (qemuDomainAddIOThreadCheck(persistentDef, iothread_id) < 0)
+                goto endjob;
+
             if (!virDomainIOThreadIDAdd(persistentDef, iothread_id))
                 goto endjob;