With kernel without the ref patch, if queues > vcpus, interrupts
will be centralized on one vcpu affecting guest performance. After
the ref patch merged, the queues whose number is greater than the
number of vcpus will not be used.

Considering the above, it's better to check the counts of vhost-user
queues and vcpus.

ref:
https://patchwork.kernel.org/project/linux-scsi/cover/1553682995-5682-1-git-send-email-dongli.zh...@oracle.com/

Signed-off-by: Jiang Jiacheng <jiangjiach...@huawei.com>
---
 src/conf/domain_validate.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index 95b8d9b419..6106e79999 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -308,7 +308,7 @@ virSecurityDeviceLabelDefValidate(virSecurityDeviceLabelDef 
**seclabels,
 
 
 static int
-virDomainDiskVhostUserValidate(const virDomainDiskDef *disk)
+virDomainDiskVhostUserValidate(const virDomainDef *def, const virDomainDiskDef 
*disk)
 {
     if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -465,6 +465,12 @@ virDomainDiskVhostUserValidate(const virDomainDiskDef 
*disk)
         return -1;
     }
 
+    if (disk->queues > virDomainDefGetVcpus(def)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("vhost-user disk queues must <= vcpus"));
+        return -1;
+    }
+
     return 0;
 }
 
@@ -807,7 +813,7 @@ virDomainDiskDefValidate(const virDomainDef *def,
     }
 
     if (disk->src->type == VIR_STORAGE_TYPE_VHOST_USER &&
-        virDomainDiskVhostUserValidate(disk) < 0) {
+        virDomainDiskVhostUserValidate(def, disk) < 0) {
         return -1;
     }
 
-- 
2.33.0

Reply via email to