[PATCH] conf: fix not format priority when it is zero

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



https://bugzilla.redhat.com/show_bug.cgi?id=1235116

We do not format the priority if it is 0, but this will
be a broken settings in guest. Change the condition of
format priority element to always format priority if
scheduler is 'fifo' or 'rr'.

Signed-off-by: Luyao Huang <lhuang@xxxxxxxxxx>
---
I haven't intorduce a new bool parameter to mark if we
set the priority value just like the other place we avoid
this issue, because i think this looks unnecessary in this
place.

 src/conf/domain_conf.c                             |  6 ++--
 ...xml2argv-cputune-iothreadsched-zeropriority.xml | 38 ++++++++++++++++++++++
 tests/qemuxml2xmltest.c                            |  1 +
 3 files changed, 43 insertions(+), 2 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cputune-iothreadsched-zeropriority.xml

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 183e66c..0c766a1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -21424,7 +21424,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(buf, " priority='%d'", sp->priority);
         virBufferAddLit(buf, "/>\n");
     }
@@ -21439,7 +21440,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(buf, " priority='%d'", sp->priority);
         virBufferAddLit(buf, "/>\n");
     }
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cputune-iothreadsched-zeropriority.xml b/tests/qemuxml2argvdata/qemuxml2argv-cputune-iothreadsched-zeropriority.xml
new file mode 100644
index 0000000..0996723
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cputune-iothreadsched-zeropriority.xml
@@ -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>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 711827d..7a41a18 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -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");
 
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]