[libvirt] [PATCH 3/3] qemu: Add multiqueue support for vhost-user-scsi/blk

Li Feng fengli at smartx.com
Mon Sep 30 06:54:22 UTC 2019


The format like this:

    <vhost-user-blk-pci type='unix'>
        <source type='bind' path='/tmp/vhost-blk.sock'>
            <reconnect enabled='yes' timeout='5' />
        </source>
        <queue num='4'/>
    </vhost-user-blk-pci>

Signed-off-by: Li Feng <fengli at smartx.com>
---
 src/conf/device_conf.h                                   |  5 +++++
 src/conf/domain_conf.c                                   | 14 ++++++++++++++
 src/qemu/qemu_command.c                                  |  7 +++++++
 tests/qemuxml2argvdata/vhost-user-blk.x86_64-latest.args |  2 +-
 tests/qemuxml2argvdata/vhost-user-blk.xml                |  1 +
 5 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
index d0854925e3..c3c722edd3 100644
--- a/src/conf/device_conf.h
+++ b/src/conf/device_conf.h
@@ -179,6 +179,11 @@ struct _virDomainDeviceInfo {
      * cases we might want to prevent that from happening by
      * locking the isolation group */
     bool isolationGroupLocked;
+
+    /* vhost-user-scsi/blk/nvme support multiqueue, parse the queue
+     * num from xml.
+     */
+    unsigned int num_queues;
 };
 
 void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info);
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fd53fab271..eeed88e41e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7483,10 +7483,12 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
     xmlNodePtr alias = NULL;
     xmlNodePtr boot = NULL;
     xmlNodePtr rom = NULL;
+    xmlNodePtr queue = NULL;
     int ret = -1;
     VIR_AUTOFREE(char *) romenabled = NULL;
     VIR_AUTOFREE(char *) rombar = NULL;
     VIR_AUTOFREE(char *) aliasStr = NULL;
+    VIR_AUTOFREE(char *) queueStr = NULL;
 
     virDomainDeviceInfoClear(info);
 
@@ -7510,6 +7512,9 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
                        (flags & VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) &&
                        virXMLNodeNameEqual(cur, "rom")) {
                 rom = cur;
+            } else if (queue == NULL &&
+                       virXMLNodeNameEqual(cur, "queue")) {
+                queue = cur;
             }
         }
         cur = cur->next;
@@ -7563,6 +7568,15 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
         virDomainDeviceAddressParseXML(address, info) < 0)
         goto cleanup;
 
+    if (queue) {
+        queueStr = virXMLPropString(queue, "num");
+        if (virStrToLong_uip(queueStr, NULL, 10, &info->num_queues) < 0) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("Cannot parse <queue> 'num' attribute '%s'"), queueStr);
+
+            goto cleanup;
+        }
+    }
 
     ret = 0;
  cleanup:
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 336ca3f729..7a3c695ac1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -10737,6 +10737,13 @@ qemuBuildVhostUserChrDeviceStr(char **deviceStr,
     virBufferAsprintf(&buf, "%s,chardev=char%s,id=%s",
                       device_type,
                       vhostuser->info.alias, vhostuser->info.alias);
+    if (vhostuser->info.num_queues > 0) {
+        if ((virDomainChrDeviceType)vhostuser->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_VHOST_USER_SCSI) {
+            virBufferAsprintf(&buf, ",num_queues=%d", vhostuser->info.num_queues);
+        } else if ((virDomainChrDeviceType)vhostuser->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_VHOST_USER_BLK) {
+            virBufferAsprintf(&buf, ",num-queues=%d", vhostuser->info.num_queues);
+        }
+    }
 
     if (qemuBuildDeviceAddressStr(&buf, def, &vhostuser->info, qemuCaps) < 0)
         return -1;
diff --git a/tests/qemuxml2argvdata/vhost-user-blk.x86_64-latest.args b/tests/qemuxml2argvdata/vhost-user-blk.x86_64-latest.args
index 4c67be1863..ea99f5949d 100644
--- a/tests/qemuxml2argvdata/vhost-user-blk.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/vhost-user-blk.x86_64-latest.args
@@ -31,7 +31,7 @@ file=/tmp/lib/domain--1-test/master-key.aes \
 -chardev socket,id=charvhost-user-blk-disk0,path=/tmp/vhost-blk.sock,\
 reconnect=1 \
 -device vhost-user-blk-pci,chardev=charvhost-user-blk-disk0,\
-id=vhost-user-blk-disk0 \
+id=vhost-user-blk-disk0,num-queues=4 \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
 resourcecontrol=deny \
 -msg timestamp=on
diff --git a/tests/qemuxml2argvdata/vhost-user-blk.xml b/tests/qemuxml2argvdata/vhost-user-blk.xml
index c9ff7650cb..276fea14b5 100644
--- a/tests/qemuxml2argvdata/vhost-user-blk.xml
+++ b/tests/qemuxml2argvdata/vhost-user-blk.xml
@@ -32,6 +32,7 @@
         <source type='bind' path='/tmp/vhost-blk.sock'>
             <reconnect enabled='yes' timeout='1' />
         </source>
+        <queue num='4'/>
     </vhost-user-blk-pci>
   </devices>
 </domain>
-- 
2.11.0


-- 
The SmartX email address is only for business purpose. Any sent message 
that is not related to the business is not authorized or permitted by 
SmartX.
本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.






More information about the libvir-list mailing list