]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virDomainDiskDefValidate: Consolidate conditions
authorPeter Krempa <pkrempa@redhat.com>
Tue, 13 Apr 2021 12:05:15 +0000 (14:05 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 19 Apr 2021 12:43:59 +0000 (14:43 +0200)
Consolidate the checks for '<reservations/>' and viritio queues under
already existing blocks which have the same condition.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_validate.c

index 570279cd927661ed69501d0ef6bc5266aad24615..4d253599af704b2c9cacc23ee317f5e860b6d2b9 100644 (file)
@@ -451,13 +451,12 @@ virDomainDiskDefValidate(const virDomainDef *def,
                              "device='lun'"), disk->dst);
             return -1;
         }
-    }
-
-    if (disk->src->pr &&
-        disk->device != VIR_DOMAIN_DISK_DEVICE_LUN) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("<reservations/> allowed only for lun devices"));
-        return -1;
+    } else {
+        if (disk->src->pr) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("<reservations/> allowed only for lun devices"));
+            return -1;
+        }
     }
 
     /* Reject disks with a bus type that is not compatible with the
@@ -474,13 +473,6 @@ virDomainDiskDefValidate(const virDomainDef *def,
         return -1;
     }
 
-    if (disk->queues && disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("queues attribute in disk driver element is only "
-                         "supported by virtio-blk"));
-        return -1;
-    }
-
     if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO) {
         if (disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO ||
             disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL ||
@@ -492,6 +484,12 @@ virDomainDiskDefValidate(const virDomainDef *def,
             return -1;
         }
 
+        if (disk->queues) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("queues attribute in disk driver element is only supported by virtio-blk"));
+            return -1;
+        }
+
         if (virDomainCheckVirtioOptionsAreAbsent(disk->virtio) < 0)
             return -1;
     }