]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Format scheduler priority when it is zero
authorLuyao Huang <lhuang@redhat.com>
Wed, 24 Jun 2015 04:00:36 +0000 (12:00 +0800)
committerMartin Kletzander <mkletzan@redhat.com>
Thu, 25 Jun 2015 21:25:30 +0000 (23:25 +0200)
https://bugzilla.redhat.com/show_bug.cgi?id=1235116

According to our XML definition, zero is as valid as any other value.
Mainly because it should be kernel-agnostic.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
src/conf/domain_conf.c
tests/qemuxml2argvdata/qemuxml2argv-cputune-iothreadsched-zeropriority.xml [new file with mode: 0644]
tests/qemuxml2xmltest.c

index e9554511f9736c1cef4568a5f3b54ae9a1b6f621..2c3b96b0e5785e6a4b0d7685951e69b08d7f3944 100644 (file)
@@ -21378,7 +21378,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
                           ids, virProcessSchedPolicyTypeToString(sp->policy));
         VIR_FREE(ids);
 
-        if (sp->priority)
+        if (sp->policy == VIR_PROC_POLICY_FIFO ||
+            sp->policy == VIR_PROC_POLICY_RR)
             virBufferAsprintf(&childrenBuf, " priority='%d'", sp->priority);
         virBufferAddLit(&childrenBuf, "/>\n");
     }
@@ -21393,7 +21394,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
                           ids, virProcessSchedPolicyTypeToString(sp->policy));
         VIR_FREE(ids);
 
-        if (sp->priority)
+        if (sp->policy == VIR_PROC_POLICY_FIFO ||
+            sp->policy == VIR_PROC_POLICY_RR)
             virBufferAsprintf(&childrenBuf, " priority='%d'", sp->priority);
         virBufferAddLit(&childrenBuf, "/>\n");
     }
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cputune-iothreadsched-zeropriority.xml b/tests/qemuxml2argvdata/qemuxml2argv-cputune-iothreadsched-zeropriority.xml
new file mode 100644 (file)
index 0000000..0996723
--- /dev/null
@@ -0,0 +1,38 @@
+<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'>2</vcpu>
+  <iothreads>4</iothreads>
+  <cputune>
+    <shares>2048</shares>
+    <period>1000000</period>
+    <quota>-1</quota>
+    <vcpupin vcpu='0' cpuset='0'/>
+    <vcpupin vcpu='1' cpuset='1'/>
+    <emulatorpin cpuset='1'/>
+    <vcpusched vcpus='0-1' scheduler='fifo' priority='0'/>
+    <iothreadsched iothreads='1-3' scheduler='rr' priority='0'/>
+  </cputune>
+  <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='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
index 711827dfe66d8e757bd66c77de652a5c6e3b86b8..7a41a187044da11ea30616af067e3bebf3822ff8 100644 (file)
@@ -492,6 +492,7 @@ mymain(void)
     DO_TEST("cputune");
     DO_TEST("cputune-zero-shares");
     DO_TEST_DIFFERENT("cputune-iothreadsched");
+    DO_TEST("cputune-iothreadsched-zeropriority");
     DO_TEST("cputune-numatune");
     DO_TEST("vcpu-placement-static");