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

2015-06-24 Thread Luyao Huang
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 lhu...@redhat.com
---
 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@redhat.com

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

2015-06-24 Thread Peter Krempa
On Wed, Jun 24, 2015 at 16:44:22 +0800, Luyao Huang wrote:
 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 lhu...@redhat.com
 ---
  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(-)
 

I'm going to refactor the data structures that are storing the thread
scheduler data which will inherently fix this issue so even if we apply
this patch it will be basically reverted very soon.

Peter


signature.asc
Description: Digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

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

2015-06-24 Thread lhuang


On 06/24/2015 08:51 PM, Peter Krempa wrote:

On Wed, Jun 24, 2015 at 16:44:22 +0800, Luyao Huang wrote:

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 lhu...@redhat.com
---
  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(-)


I'm going to refactor the data structures that are storing the thread
scheduler data which will inherently fix this issue so even if we apply
this patch it will be basically reverted very soon.


Yes, i see your comment in this bug (unfortunately this is after i send 
this patch :) ), i agree no need apply this patch if you will fix that 
issue together during refactor.


Thanks for your quick review.


Peter


Luyao

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