[PATCH] qemu:conf: introduce a function to delete vcpu sched

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

 



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

We have API allow vpu to be deleted, but an vcpu may be
included in some domain vcpu sched, so add a new API to
allow removing an iothread from some entry.

Split the virDomainIOThreadSchedDelId to reuse some code.

Signed-off-by: Luyao Huang <lhuang@xxxxxxxxxx>
---
 src/conf/domain_conf.c   | 48 ++++++++++++++++++++++++++++++++++--------------
 src/conf/domain_conf.h   |  1 +
 src/libvirt_private.syms |  1 +
 src/qemu/qemu_driver.c   |  6 ++++--
 4 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 183e66c..7a464a6 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -17996,29 +17996,49 @@ virDomainIOThreadIDDel(virDomainDefPtr def,
     }
 }
 
-void
-virDomainIOThreadSchedDelId(virDomainDefPtr def,
-                            unsigned int iothreadid)
+static void
+virDomainThreadSchedDelId(virDomainThreadSchedParamPtr *threadsched,
+                          size_t *nthreadsched,
+                          unsigned int id)
 {
     size_t i;
 
-    if (!def->cputune.iothreadsched || !def->cputune.niothreadsched)
-        return;
-
-    for (i = 0; i < def->cputune.niothreadsched; i++) {
-        if (virBitmapIsBitSet(def->cputune.iothreadsched[i].ids, iothreadid)) {
-            ignore_value(virBitmapClearBit(def->cputune.iothreadsched[i].ids,
-                                           iothreadid));
-            if (virBitmapIsAllClear(def->cputune.iothreadsched[i].ids)) {
-                virBitmapFree(def->cputune.iothreadsched[i].ids);
-                VIR_DELETE_ELEMENT(def->cputune.iothreadsched, i,
-                                   def->cputune.niothreadsched);
+    for (i = 0; i < *nthreadsched; i++) {
+        if (virBitmapIsBitSet((*threadsched)[i].ids, id)) {
+            ignore_value(virBitmapClearBit((*threadsched)[i].ids, id));
+            if (virBitmapIsAllClear((*threadsched)[i].ids)) {
+                virBitmapFree((*threadsched)[i].ids);
+                VIR_DELETE_ELEMENT((*threadsched), i, *nthreadsched);
             }
             return;
         }
     }
 }
 
+void
+virDomainIOThreadSchedDelId(virDomainDefPtr def,
+                            unsigned int iothreadid)
+{
+    if (!def->cputune.iothreadsched || !def->cputune.niothreadsched)
+        return;
+
+    virDomainThreadSchedDelId(&def->cputune.iothreadsched,
+                              &def->cputune.niothreadsched,
+                              iothreadid);
+}
+
+void
+virDomainVcpuSchedDelId(virDomainDefPtr def,
+                        unsigned int vcpuid)
+{
+    if (!def->cputune.vcpusched || !def->cputune.nvcpusched)
+        return;
+
+    virDomainThreadSchedDelId(&def->cputune.vcpusched,
+                              &def->cputune.nvcpusched,
+                              vcpuid);
+}
+
 virDomainPinDefPtr
 virDomainPinFind(virDomainPinDefPtr *def,
                  int npin,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c96a6e4..a74dbc9 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2662,6 +2662,7 @@ virDomainIOThreadIDDefPtr virDomainIOThreadIDAdd(virDomainDefPtr def,
                                                  unsigned int iothread_id);
 void virDomainIOThreadIDDel(virDomainDefPtr def, unsigned int iothread_id);
 void virDomainIOThreadSchedDelId(virDomainDefPtr def, unsigned int iothread_id);
+void virDomainVcpuSchedDelId(virDomainDefPtr def, unsigned int vcpuid);
 
 unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags);
 
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 1566d11..169d641 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -479,6 +479,7 @@ virDomainTPMBackendTypeToString;
 virDomainTPMDefFree;
 virDomainTPMModelTypeFromString;
 virDomainTPMModelTypeToString;
+virDomainVcpuSchedDelId;
 virDomainVideoDefaultRAM;
 virDomainVideoDefaultType;
 virDomainVideoDefFree;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c1373de..245443c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4966,12 +4966,14 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
         }
 
         if (persistentDef) {
-            /* remove vcpupin entries for vcpus that were unplugged */
+            /* remove vcpupin and vcpusched entries for vcpus that were unplugged */
             if (nvcpus < persistentDef->vcpus) {
-                for (i = persistentDef->vcpus - 1; i >= nvcpus; i--)
+                for (i = persistentDef->vcpus - 1; i >= nvcpus; i--) {
                     virDomainPinDel(&persistentDef->cputune.vcpupin,
                                     &persistentDef->cputune.nvcpupin,
                                     i);
+                    virDomainVcpuSchedDelId(persistentDef, i);
+                }
             }
 
             if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
-- 
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]