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

Pavel Hrdina posted 1 patch 7 years, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/5791c3facab047835d3a9de5dca60e1fed10fbf3.1488991793.git.phrdina@redhat.com
src/conf/domain_conf.c  | 18 ++++--------------
src/qemu/qemu_command.c | 22 ++++++++++++++++++++++
2 files changed, 26 insertions(+), 14 deletions(-)
[libvirt] [PATCH] domain_conf: move iothread check for address type back to qemu_command
Posted by Pavel Hrdina 7 years, 1 month ago
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@redhat.com>
---
 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@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] domain_conf: move iothread check for address type back to qemu_command
Posted by Ján Tomko 7 years, 1 month ago
On Wed, Mar 08, 2017 at 05:50:11PM +0100, Pavel Hrdina wrote:
>This partially reverts commit c96bd78e4e.
>

That commit also moved the check that ensures the controller type
is virtio-scsi. However, it seems qemuDomainSetSCSIControllerModel
which can also possibly set the default model to virtio-scsi
(if QEMU does not support LSI) now gets called after
virDomainControllerDefValidate.

Jan

>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@redhat.com>
>---
> src/conf/domain_conf.c  | 18 ++++--------------
> src/qemu/qemu_command.c | 22 ++++++++++++++++++++++
> 2 files changed, 26 insertions(+), 14 deletions(-)
>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list