]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Format thread IDs optionally
authorMartin Kletzander <mkletzan@redhat.com>
Mon, 15 Apr 2019 08:48:07 +0000 (10:48 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 16 Apr 2019 11:46:17 +0000 (13:46 +0200)
This will be used later when we want to format emulator scheduler parameters
which don't apply for multiple threads.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/domain_conf.c

index 15838c2a23f54729d5fa087dc495594e8937fc23..e7b8b51aad0e30278b0dbf25277ba63ddeaf1bce 100644 (file)
@@ -27205,22 +27205,25 @@ static void
 virDomainSchedulerFormat(virBufferPtr buf,
                          const char *name,
                          virDomainThreadSchedParamPtr sched,
-                         size_t id)
+                         size_t id,
+                         bool multiple_threads)
 {
     switch (sched->policy) {
         case VIR_PROC_POLICY_BATCH:
         case VIR_PROC_POLICY_IDLE:
-            virBufferAsprintf(buf, "<%ssched "
-                              "%ss='%zu' scheduler='%s'/>\n",
-                              name, name, id,
+            virBufferAsprintf(buf, "<%ssched", name);
+            if (multiple_threads)
+                virBufferAsprintf(buf, " %ss='%zu'", name, id);
+            virBufferAsprintf(buf, " scheduler='%s'/>\n",
                               virProcessSchedPolicyTypeToString(sched->policy));
             break;
 
         case VIR_PROC_POLICY_RR:
         case VIR_PROC_POLICY_FIFO:
-            virBufferAsprintf(buf, "<%ssched "
-                              "%ss='%zu' scheduler='%s' priority='%d'/>\n",
-                              name, name, id,
+            virBufferAsprintf(buf, "<%ssched", name);
+            if (multiple_threads)
+                virBufferAsprintf(buf, " %ss='%zu'", name, id);
+            virBufferAsprintf(buf, " scheduler='%s' priority='%d'/>\n",
                               virProcessSchedPolicyTypeToString(sched->policy),
                               sched->priority);
             break;
@@ -27489,13 +27492,14 @@ virDomainCputuneDefFormat(virBufferPtr buf,
 
     for (i = 0; i < def->maxvcpus; i++) {
         virDomainSchedulerFormat(&childrenBuf, "vcpu",
-                                 &def->vcpus[i]->sched, i);
+                                 &def->vcpus[i]->sched, i, true);
     }
 
     for (i = 0; i < def->niothreadids; i++) {
         virDomainSchedulerFormat(&childrenBuf, "iothread",
                                  &def->iothreadids[i]->sched,
-                                 def->iothreadids[i]->iothread_id);
+                                 def->iothreadids[i]->iothread_id,
+                                 true);
     }
 
     for (i = 0; i < def->nresctrls; i++)