[PATCH] domain_conf: move iothread check for address type back to qemu_command

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

 



This partially reverts commit c96bd78e4e.

If an API virDomainAttachDevice(Flags) is used the device address
is assigned after the validation and the address type may not be set.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1430275

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/conf/domain_conf.c  | 18 ++++--------------
 src/qemu/qemu_command.c | 22 ++++++++++++++++++++++
 2 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 97d42fe993..747706e673 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4769,12 +4769,10 @@ virDomainDiskDefValidate(const virDomainDef *def,
     }
 
     if (disk->iothread > 0) {
-        if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO ||
-            (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
-             disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("IOThreads are only available for virtio pci and "
-                             "virtio ccw disk"));
+        if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("IOThreads are not available for bus '%s', disk '%s'"),
+                           virDomainDiskBusTypeToString(disk->bus), disk->dst);
             return -1;
         }
 
@@ -4850,14 +4848,6 @@ virDomainControllerDefValidate(const virDomainDef *def,
             return -1;
         }
 
-        if (cont->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
-            cont->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("IOThreads are only available for virtio pci and "
-                             "virtio ccw controllers"));
-            return -1;
-        }
-
         if (!virDomainIOThreadIDFind(def, cont->iothread)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("Invalid IOThread id '%u' for controller '%s'"),
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 6545a93259..b49242a7df 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1871,6 +1871,21 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
 }
 
 
+static int
+qemuBuildCheckIOThreadAddress(virDomainDeviceInfo info)
+{
+    if (info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
+        info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("IOThreads are only available for virtio pci and "
+                         "virtio ccw"));
+        return -1;
+    }
+
+    return 0;
+}
+
+
 char *
 qemuBuildDriveDevStr(const virDomainDef *def,
                      virDomainDiskDefPtr disk,
@@ -1889,6 +1904,9 @@ qemuBuildDriveDevStr(const virDomainDef *def,
     if (!qemuCheckCCWS390AddressSupport(def, disk->info, qemuCaps, disk->dst))
         goto error;
 
+    if (disk->iothread > 0 && qemuBuildCheckIOThreadAddress(disk->info) < 0)
+        goto error;
+
     switch (disk->bus) {
     case VIR_DOMAIN_DISK_BUS_IDE:
         if (disk->info.addr.drive.target != 0) {
@@ -2571,6 +2589,8 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
             if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
                 virBufferAddLit(&buf, "virtio-scsi-ccw");
                 if (def->iothread) {
+                    if (qemuBuildCheckIOThreadAddress(def->info) < 0)
+                        goto error;
                     virBufferAsprintf(&buf, ",iothread=iothread%u",
                                       def->iothread);
                 }
@@ -2583,6 +2603,8 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
             } else {
                 virBufferAddLit(&buf, "virtio-scsi-pci");
                 if (def->iothread) {
+                    if (qemuBuildCheckIOThreadAddress(def->info) < 0)
+                        goto error;
                     virBufferAsprintf(&buf, ",iothread=iothread%u",
                                       def->iothread);
                 }
-- 
2.12.0

--
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