]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: Support multiple queue virtio-scsi
authorOsier Yang <jyang@redhat.com>
Fri, 5 Apr 2013 16:21:23 +0000 (00:21 +0800)
committerOsier Yang <jyang@redhat.com>
Sat, 6 Apr 2013 02:08:47 +0000 (10:08 +0800)
This introduce a new attribute "num_queues" (same with the good name
QEMU uses) for virtio-scsi controller. An example of the XML:

<controller type='scsi' index='0' model='virtio-scsi' num_queues='8'/>

The corresponding QEMU command line:

-device virtio-scsi-pci,id=scsi0,num_queues=8,bus=pci.0,addr=0x3 \

docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
src/qemu/qemu_command.c
tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c
tests/qemuxml2xmltest.c

index cf382e82873e5e998d69dba160f14804c057e3fb..2bd924133d120b64d8f273154d1de27cd4a7589e 100644 (file)
       controller.  A "scsi" controller has an optional
       attribute <code>model</code>, which is one of "auto", "buslogic",
       "ibmvscsi", "lsilogic", "lsisas1068", "lsisas1078", "virtio-scsi" or
-      "vmpvscsi".  A "usb" controller has an optional attribute
-      <code>model</code>, which is one of "piix3-uhci", "piix4-uhci", "ehci",
-      "ich9-ehci1", "ich9-uhci1", "ich9-uhci2", "ich9-uhci3",
-      "vt82c686b-uhci", "pci-ohci" or "nec-xhci". Additionally,
-      <span class="since">since 0.10.0</span>, if the USB bus needs to be
-      explicitly disabled for the guest, <code>model='none'</code> may be used.
-      The PowerPC64 "spapr-vio" addresses do not have an associated controller.
+      "vmpvscsi".  The attribute <code>num_queues</code>
+      (<span class="since">1.0.5 (QEMU and KVM only)</span>) specifies
+      the number of queues for the controller. For best performance, it's
+      recommended to specify a value matching the number of vCPUs.  A "usb"
+      controller has an optional attribute <code>model</code>, which is one
+      of "piix3-uhci", "piix4-uhci", "ehci", "ich9-ehci1", "ich9-uhci1",
+      "ich9-uhci2", "ich9-uhci3", "vt82c686b-uhci", "pci-ohci" or "nec-xhci".
+      Additionally, <span class="since">since 0.10.0</span>, if the USB bus
+      needs to be explicitly disabled for the guest, <code>model='none'</code>
+      may be used.  The PowerPC64 "spapr-vio" addresses do not have an
+      associated controller.
     </p>
 
     <p>
index 63ba7d100731261f1b25f0bcb0ffd9839475efa5..d486ae8b34aeaa6e4ef17002847bfd9cf59fb26e 100644 (file)
           </choice>
         </attribute>
       </optional>
+      <optional>
+        <attribute name="num_queues">
+          <ref name="unsignedInt"/>
+        </attribute>
+      </optional>
       <optional>
         <ref name="usbmaster"/>
       </optional>
index 5ad30803a5a6c6d056a3a0afdd0d1133a78b7860..f50a964e110682408f0af4fcbe23698ac7bad6fe 100644 (file)
@@ -5034,6 +5034,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
     char *type = NULL;
     char *idx = NULL;
     char *model = NULL;
+    char *num_queues = NULL;
 
     if (VIR_ALLOC(def) < 0) {
         virReportOOMError();
@@ -5069,6 +5070,14 @@ virDomainControllerDefParseXML(xmlNodePtr node,
         def->model = -1;
     }
 
+    if ((num_queues = virXMLPropString(node, "num_queues"))) {
+        if (virStrToLong_ui(num_queues, NULL, 10, &def->num_queues) < 0) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("Malformed 'num_queues' value '%s'"), num_queues);
+            goto error;
+        }
+    }
+
     if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
         goto error;
 
@@ -5146,6 +5155,7 @@ cleanup:
     VIR_FREE(type);
     VIR_FREE(idx);
     VIR_FREE(model);
+    VIR_FREE(num_queues);
 
     return def;
 
@@ -13195,6 +13205,9 @@ virDomainControllerDefFormat(virBufferPtr buf,
         virBufferEscapeString(buf, " model='%s'", model);
     }
 
+    if (def->num_queues)
+        virBufferAsprintf(buf, " num_queues='%u'", def->num_queues);
+
     switch (def->type) {
     case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
         if (def->opts.vioserial.ports != -1) {
index 700f03f3e54c400a7c188982a2884e003f309e49..75e3f1500f72fd35b11048a223495fa7d7f69c4c 100644 (file)
@@ -728,6 +728,7 @@ struct _virDomainControllerDef {
     int type;
     int idx;
     int model; /* -1 == undef */
+    unsigned int num_queues;
     union {
         virDomainVirtioSerialOpts vioserial;
     } opts;
index 493e5f8a3fec589d92c0670332b4c50fc1c0fdb0..53caba5e2034259e217547398b4854f23bd687af 100644 (file)
@@ -3533,6 +3533,14 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     int model;
 
+    if (def->num_queues &&
+        !(def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI &&
+          def->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("'num_queues' is only supported by virtio-scsi controller"));
+        return NULL;
+    }
+
     switch (def->type) {
     case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
         model = def->model;
@@ -3616,6 +3624,9 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
         goto error;
     }
 
+    if (def->num_queues)
+        virBufferAsprintf(&buf, ",num_queues=%u", def->num_queues);
+
     if (qemuBuildDeviceAddressStr(&buf, &def->info, qemuCaps) < 0)
         goto error;
 
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.args
new file mode 100644 (file)
index 0000000..8d46799
--- /dev/null
@@ -0,0 +1,8 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
+/usr/bin/qemu -S -M pc -m 214 -smp 8 -nographic -nodefconfig -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
+-device virtio-scsi-pci,id=scsi0,num_queues=8,bus=pci.0,addr=0x3 \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-scsi0-0-0-0 \
+-device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.xml
new file mode 100644 (file)
index 0000000..dfa9cf1
--- /dev/null
@@ -0,0 +1,26 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>8</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='sdb' bus='scsi'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='usb' index='0'/>
+    <controller type='scsi' index='0' model='virtio-scsi' num_queues='8'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
index 099fb3630aa320867f7272205281919092d916f4..d6575e7c2186ac7b3fb214d6866dad4951893412 100644 (file)
@@ -553,6 +553,9 @@ mymain(void)
     DO_TEST("disk-scsi-virtio-scsi",
             QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_VIRTIO_SCSI);
+    DO_TEST("disk-virtio-scsi-num_queues",
+            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
+            QEMU_CAPS_VIRTIO_SCSI);
     DO_TEST("disk-scsi-megasas",
             QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_SCSI_MEGASAS);
index aa058bd86baabdbf5869a5d0d919178b75b27ea4..10a6ea2963f97c073bc368ddc37180876bbe8ad5 100644 (file)
@@ -179,6 +179,7 @@ mymain(void)
     DO_TEST("disk-scsi-device");
     DO_TEST("disk-scsi-vscsi");
     DO_TEST("disk-scsi-virtio-scsi");
+    DO_TEST("disk-virtio-scsi-num_queues");
     DO_TEST("disk-scsi-megasas");
     DO_TEST_FULL("disk-mirror", false, WHEN_ACTIVE);
     DO_TEST_FULL("disk-mirror", true, WHEN_INACTIVE);