]> xenbits.xensource.com Git - libvirt.git/commitdiff
Introduce a sub-element <driver> for controller
authorOsier Yang <jyang@redhat.com>
Wed, 24 Apr 2013 09:24:38 +0000 (17:24 +0800)
committerOsier Yang <jyang@redhat.com>
Thu, 25 Apr 2013 04:10:58 +0000 (12:10 +0800)
Like what we did for "disk", "filesystem" and "interface", this
introduces sub-element <driver> for "controller", and put the "queues"
into it.

docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.xml

index 4e9665fb3181210c7fa4e04733e1857b1d0ddf52..235a20683e6ec919fcbac4eea3f10f720124623b 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".  The attribute <code>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.
+      "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.
     </p>
 
     <p>
       semantics <a href="#elementsAddress">given above</a>.
     </p>
 
+    <p>
+      An optional sub-element <code>driver</code> can specify the driver
+      specific options. Currently it only supports attribute <code>queues</code>
+      (<span class="since">1.0.5</span>, QEMU and KVM only), which specifies the
+      number of queues for the controller. For best performance, it's recommended
+      to specify a value matching the number of vCPUs.
+    </p>
     <p>
       USB companion controllers have an optional
       sub-element <code>&lt;master&gt;</code> to specify the exact
index b1c4c2f8545c3ee2f6a5982e372e342043582e93..a9d05817d9b52f52a0ea2645b8f2e2b72fd73cc0 100644 (file)
                 </choice>
               </attribute>
             </optional>
-            <optional>
-              <attribute name="queues">
-                <ref name="unsignedInt"/>
-              </attribute>
-            </optional>
           </group>
           <!-- usb has an optional attribute "model", and optional subelement "master" -->
           <group>
             </optional>
           </group>
         </choice>
+        <optional>
+          <element name="driver">
+            <optional>
+              <attribute name="queues">
+                <ref name="unsignedInt"/>
+              </attribute>
+            </optional>
+          </element>
+        </optional>
       </interleave>
     </element>
   </define>
index 253c9ef70a4ddc8953243818d800a892b86838b3..0b432dd3d8dd9dc3030cd736c4ddb18187d88d75 100644 (file)
@@ -5156,6 +5156,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
                                unsigned int flags)
 {
     virDomainControllerDefPtr def;
+    xmlNodePtr cur = NULL;
     char *type = NULL;
     char *idx = NULL;
     char *model = NULL;
@@ -5195,12 +5196,19 @@ virDomainControllerDefParseXML(xmlNodePtr node,
         def->model = -1;
     }
 
-    if ((queues = virXMLPropString(node, "queues"))) {
-        if (virStrToLong_ui(queues, NULL, 10, &def->queues) < 0) {
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("Malformed 'queues' value '%s'"), queues);
-            goto error;
+    cur = node->children;
+    while (cur != NULL) {
+        if (cur->type == XML_ELEMENT_NODE) {
+            if (xmlStrEqual(cur->name, BAD_CAST "driver"))
+                queues = virXMLPropString(cur, "queues");
         }
+        cur = cur->next;
+    }
+
+    if (queues && virStrToLong_ui(queues, NULL, 10, &def->queues) < 0) {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("Malformed 'queues' value '%s'"), queues);
+        goto error;
     }
 
     if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
@@ -13524,9 +13532,6 @@ virDomainControllerDefFormat(virBufferPtr buf,
         virBufferEscapeString(buf, " model='%s'", model);
     }
 
-    if (def->queues)
-        virBufferAsprintf(buf, " queues='%u'", def->queues);
-
     switch (def->type) {
     case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
         if (def->opts.vioserial.ports != -1) {
@@ -13543,10 +13548,16 @@ virDomainControllerDefFormat(virBufferPtr buf,
         break;
     }
 
-    if (virDomainDeviceInfoIsSet(&def->info, flags)) {
+    if (def->queues || virDomainDeviceInfoIsSet(&def->info, flags)) {
         virBufferAddLit(buf, ">\n");
-        if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
+
+        if (def->queues)
+            virBufferAsprintf(buf, "      <driver queues='%u'/>\n", def->queues);
+
+        if (virDomainDeviceInfoIsSet(&def->info, flags) &&
+            virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
             return -1;
+
         virBufferAddLit(buf, "    </controller>\n");
     } else {
         virBufferAddLit(buf, "/>\n");
index b3b1289f85c208aa6baf104c603cadb20a0083d3..fda976cb958b81d3719b820f2acb72821791e147 100644 (file)
@@ -20,7 +20,9 @@
       <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' queues='8'/>
+    <controller type='scsi' index='0' model='virtio-scsi'>
+      <driver queues='8'/>
+    </controller>
     <memballoon model='virtio'/>
   </devices>
 </domain>