[PATCH 07/13] qemu_process: move capabilities check for iothreads

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

 



Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 31 +++++--------------------------
 src/qemu/qemu_process.c | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 26 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c00a47a91a..7152ef9322 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2586,23 +2586,11 @@ qemuBuildUSBControllerDevStr(virDomainControllerDefPtr def,
  */
 static bool
 qemuCheckSCSIControllerIOThreads(const virDomainDef *domainDef,
-                                 virDomainControllerDefPtr def,
-                                 virQEMUCapsPtr qemuCaps)
+                                 virDomainControllerDefPtr def)
 {
     if (!def->iothread)
         return true;
 
-    /* By this time QEMU_CAPS_OBJECT_IOTHREAD was already checked.
-     * We just need to check if the QEMU_CAPS_VIRTIO_SCSI_IOTHREAD
-     * capability is set.
-     */
-    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_SCSI_IOTHREAD)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("IOThreads for virtio-scsi not supported for "
-                         "this QEMU"));
-        return false;
-    }
-
     if (def->model != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("IOThreads only supported for virtio-scsi "
@@ -2681,8 +2669,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
             if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
                 virBufferAddLit(&buf, "virtio-scsi-ccw");
                 if (def->iothread) {
-                    if (!qemuCheckSCSIControllerIOThreads(domainDef,
-                                                          def, qemuCaps))
+                    if (!qemuCheckSCSIControllerIOThreads(domainDef, def))
                         goto error;
                     virBufferAsprintf(&buf, ",iothread=iothread%u",
                                       def->iothread);
@@ -2696,8 +2683,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
             } else {
                 virBufferAddLit(&buf, "virtio-scsi-pci");
                 if (def->iothread) {
-                    if (!qemuCheckSCSIControllerIOThreads(domainDef,
-                                                          def, qemuCaps))
+                    if (!qemuCheckSCSIControllerIOThreads(domainDef, def))
                         goto error;
                     virBufferAsprintf(&buf, ",iothread=iothread%u",
                                       def->iothread);
@@ -7389,20 +7375,13 @@ qemuBuildMemCommandLine(virCommandPtr cmd,
 
 static int
 qemuBuildIOThreadCommandLine(virCommandPtr cmd,
-                             const virDomainDef *def,
-                             virQEMUCapsPtr qemuCaps)
+                             const virDomainDef *def)
 {
     size_t i;
 
     if (def->niothreadids == 0)
         return 0;
 
-    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_IOTHREAD)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("IOThreads not supported for this QEMU"));
-        return -1;
-    }
-
     /* Create iothread objects using the defined iothreadids list
      * and the defined id and name from the list. These may be used
      * by a disk definition which will associate to an iothread by
@@ -9705,7 +9684,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
     if (qemuBuildSmpCommandLine(cmd, def) < 0)
         goto error;
 
-    if (qemuBuildIOThreadCommandLine(cmd, def, qemuCaps) < 0)
+    if (qemuBuildIOThreadCommandLine(cmd, def) < 0)
         goto error;
 
     if (virDomainNumaGetNodeCount(def->numa) &&
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 2a65e9043c..4710d4ca28 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4584,6 +4584,37 @@ qemuProcessStartValidateVideo(virDomainObjPtr vm,
 
 
 static int
+qemuProcessStartValidateIOThreads(virDomainObjPtr vm,
+                                  virQEMUCapsPtr qemuCaps)
+{
+    size_t i;
+
+    if (vm->def->niothreadids > 0 &&
+        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_IOTHREAD)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("IOThreads not supported for this QEMU"));
+        return -1;
+    }
+
+    for (i = 0; i < vm->def->ncontrollers; i++) {
+        virDomainControllerDefPtr cont = vm->def->controllers[i];
+
+        if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI &&
+            cont->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI &&
+            cont->iothread > 0 &&
+            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_SCSI_IOTHREAD)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("IOThreads for virtio-scsi not supported for "
+                             "this QEMU"));
+            return -1;
+        }
+    }
+
+    return 0;
+}
+
+
+static int
 qemuProcessStartValidateXML(virQEMUDriverPtr driver,
                             virDomainObjPtr vm,
                             virQEMUCapsPtr qemuCaps,
@@ -4659,6 +4690,9 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
     if (qemuProcessStartValidateVideo(vm, qemuCaps) < 0)
         return -1;
 
+    if (qemuProcessStartValidateIOThreads(vm, qemuCaps) < 0)
+        return -1;
+
     VIR_DEBUG("Checking for any possible (non-fatal) issues");
 
     qemuProcessStartWarnShmem(vm);
-- 
2.11.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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