]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Correctly format controller's driver
authorLuyao Huang <lhuang@redhat.com>
Wed, 7 Jan 2015 10:39:37 +0000 (18:39 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 9 Jan 2015 15:01:55 +0000 (16:01 +0100)
https://bugzilla.redhat.com/show_bug.cgi?id=1179684

The way that we currently generate the <driver/> for <controller/> is
just madness:

    <controller type='scsi' index='0' model='virtio-scsi'>
      <driver queues='12'/>
      <driver cmd_per_lun='123'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </controller>

It's obvious that we should be aiming at the following:

    <controller type='scsi' index='0' model='virtio-scsi'>
      <driver queues='12' cmd_per_lun='123'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </controller>

Signed-off-by: Luyao Huang <lhuang@redhat.com>
src/conf/domain_conf.c

index d1a483add0aab56674c9fd197fc34e5b4879b268..57e99e6782ce1bed387e17fccb8c194e54ebc14a 100644 (file)
@@ -17120,14 +17120,19 @@ virDomainControllerDefFormat(virBufferPtr buf,
         virDomainDeviceInfoIsSet(&def->info, flags) || pcihole64) {
         virBufferAddLit(buf, ">\n");
         virBufferAdjustIndent(buf, 2);
-        if (def->queues)
-            virBufferAsprintf(buf, "<driver queues='%u'/>\n", def->queues);
 
-        if (def->cmd_per_lun)
-            virBufferAsprintf(buf, "<driver cmd_per_lun='%u'/>\n", def->cmd_per_lun);
+        if (def->queues || def->cmd_per_lun || def->max_sectors) {
+            virBufferAddLit(buf, "<driver");
+            if (def->queues)
+                virBufferAsprintf(buf, " queues='%u'", def->queues);
 
-        if (def->max_sectors)
-            virBufferAsprintf(buf, "<driver max_sectors='%u'/>\n", def->max_sectors);
+            if (def->cmd_per_lun)
+                virBufferAsprintf(buf, " cmd_per_lun='%u'", def->cmd_per_lun);
+
+            if (def->max_sectors)
+                virBufferAsprintf(buf, " max_sectors='%u'", def->max_sectors);
+            virBufferAddLit(buf, "/>\n");
+        }
 
         if (virDomainDeviceInfoIsSet(&def->info, flags) &&
             virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)