Re: [libvirt] [PATCH 30/34] conf: Fix how iothread scheduler info is stored
On 01/14/2016 11:27 AM, Peter Krempa wrote: > Similarly to previous commit change the way how iothread scheduler info > is stored and clean up a lot of unnecessary code. (and hours of careful cut-n-paste ;-)) > --- > src/conf/domain_conf.c | 141 > +++-- > src/conf/domain_conf.h | 8 +- > src/libvirt_private.syms | 1 - > src/qemu/qemu_driver.c | 3 - > src/qemu/qemu_process.c| 39 +- > .../qemuxml2xmlout-cputune-iothreadsched.xml | 3 +- > 6 files changed, 53 insertions(+), 142 deletions(-) > > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c > index e2dda9a..4ca03d9 100644 > --- a/src/conf/domain_conf.c > +++ b/src/conf/domain_conf.c > @@ -2559,10 +2559,6 @@ void virDomainDefFree(virDomainDefPtr def) > > virBitmapFree(def->cputune.emulatorpin); > > -for (i = 0; i < def->cputune.niothreadsched; i++) > -virBitmapFree(def->cputune.iothreadsched[i].ids); > -VIR_FREE(def->cputune.iothreadsched); > - > virDomainNumaFree(def->numa); > > virSysinfoDefFree(def->sysinfo); > @@ -14649,25 +14645,26 @@ virDomainVcpuThreadSchedParse(xmlNodePtr node, > } > > > -static int > -virDomainThreadSchedParse(xmlNodePtr node, > - unsigned int minid, > - unsigned int maxid, > - const char *name, > - virDomainThreadSchedParamPtr sp) > -{ > -if (!(sp->ids = virDomainSchedulerParse(node, name, >policy, > ->priority))) > -return -1; > +static virDomainThreadSchedParamPtr > +virDomainDefGetIOThreadSched(virDomainDefPtr def, > + unsigned int iothread) > +{ > +virDomainIOThreadIDDefPtr iothrinfo; > > -if (virBitmapNextSetBit(sp->ids, -1) < minid || > -virBitmapLastSetBit(sp->ids) > maxid) { > -virReportError(VIR_ERR_CONFIG_UNSUPPORTED, > - _("%ssched bitmap is out of range"), name); > -return -1; > -} > +if (!(iothrinfo = virDomainIOThreadIDFind(def, iothread))) > +return NULL; > > -return 0; > +return >sched; > +} > + > + > +static int > +virDomainIOThreadSchedParse(xmlNodePtr node, > +virDomainDefPtr def) > +{ > +return virDomainThreadSchedParseHelper(node, "iothreads", Here's somewhere to think about regarding Parse using "iothreads" while Format uses "iothread" > + virDomainDefGetIOThreadSched, > + def); > } > > > @@ -15215,46 +15212,10 @@ virDomainDefParseXML(xmlDocPtr xml, > _("cannot extract iothreadsched nodes")); > goto error; > } > -if (n) { > -if (n > def->niothreadids) { > -virReportError(VIR_ERR_INTERNAL_ERROR, "%s", > - _("too many iothreadsched nodes in cputune")); > -goto error; > -} > > -if (VIR_ALLOC_N(def->cputune.iothreadsched, n) < 0) > +for (i = 0; i < n; i++) { > +if (virDomainIOThreadSchedParse(nodes[i], def) < 0) > goto error; > -def->cputune.niothreadsched = n; > - > -for (i = 0; i < def->cputune.niothreadsched; i++) { > -ssize_t pos = -1; > - > -if (virDomainThreadSchedParse(nodes[i], > - 1, UINT_MAX, > - "iothreads", > - >cputune.iothreadsched[i]) < > 0) > -goto error; > - > -while ((pos = > virBitmapNextSetBit(def->cputune.iothreadsched[i].ids, > - pos)) > -1) { > -if (!virDomainIOThreadIDFind(def, pos)) { > -virReportError(VIR_ERR_XML_DETAIL, "%s", > - _("iothreadsched attribute 'iothreads' " > - "uses undefined iothread ids")); > -goto error; > -} > -} > - > -for (j = 0; j < i; j++) { > -if (virBitmapOverlaps(def->cputune.iothreadsched[i].ids, > - def->cputune.iothreadsched[j].ids)) { > -virReportError(VIR_ERR_XML_DETAIL, "%s", > - _("iothreadsched attributes 'iothreads' " > - "must not overlap")); > -goto error; > -} > -} > -} > } > VIR_FREE(nodes); > > @@ -18448,29 +18409,6 @@ virDomainIOThreadIDDel(virDomainDefPtr def, > } > } > > -void > -virDomainIOThreadSchedDelId(virDomainDefPtr def, > -unsigned int iothreadid) > -{ > -
[libvirt] [PATCH 30/34] conf: Fix how iothread scheduler info is stored
Similarly to previous commit change the way how iothread scheduler info is stored and clean up a lot of unnecessary code. --- src/conf/domain_conf.c | 141 +++-- src/conf/domain_conf.h | 8 +- src/libvirt_private.syms | 1 - src/qemu/qemu_driver.c | 3 - src/qemu/qemu_process.c| 39 +- .../qemuxml2xmlout-cputune-iothreadsched.xml | 3 +- 6 files changed, 53 insertions(+), 142 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e2dda9a..4ca03d9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2559,10 +2559,6 @@ void virDomainDefFree(virDomainDefPtr def) virBitmapFree(def->cputune.emulatorpin); -for (i = 0; i < def->cputune.niothreadsched; i++) -virBitmapFree(def->cputune.iothreadsched[i].ids); -VIR_FREE(def->cputune.iothreadsched); - virDomainNumaFree(def->numa); virSysinfoDefFree(def->sysinfo); @@ -14649,25 +14645,26 @@ virDomainVcpuThreadSchedParse(xmlNodePtr node, } -static int -virDomainThreadSchedParse(xmlNodePtr node, - unsigned int minid, - unsigned int maxid, - const char *name, - virDomainThreadSchedParamPtr sp) -{ -if (!(sp->ids = virDomainSchedulerParse(node, name, >policy, ->priority))) -return -1; +static virDomainThreadSchedParamPtr +virDomainDefGetIOThreadSched(virDomainDefPtr def, + unsigned int iothread) +{ +virDomainIOThreadIDDefPtr iothrinfo; -if (virBitmapNextSetBit(sp->ids, -1) < minid || -virBitmapLastSetBit(sp->ids) > maxid) { -virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("%ssched bitmap is out of range"), name); -return -1; -} +if (!(iothrinfo = virDomainIOThreadIDFind(def, iothread))) +return NULL; -return 0; +return >sched; +} + + +static int +virDomainIOThreadSchedParse(xmlNodePtr node, +virDomainDefPtr def) +{ +return virDomainThreadSchedParseHelper(node, "iothreads", + virDomainDefGetIOThreadSched, + def); } @@ -15215,46 +15212,10 @@ virDomainDefParseXML(xmlDocPtr xml, _("cannot extract iothreadsched nodes")); goto error; } -if (n) { -if (n > def->niothreadids) { -virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("too many iothreadsched nodes in cputune")); -goto error; -} -if (VIR_ALLOC_N(def->cputune.iothreadsched, n) < 0) +for (i = 0; i < n; i++) { +if (virDomainIOThreadSchedParse(nodes[i], def) < 0) goto error; -def->cputune.niothreadsched = n; - -for (i = 0; i < def->cputune.niothreadsched; i++) { -ssize_t pos = -1; - -if (virDomainThreadSchedParse(nodes[i], - 1, UINT_MAX, - "iothreads", - >cputune.iothreadsched[i]) < 0) -goto error; - -while ((pos = virBitmapNextSetBit(def->cputune.iothreadsched[i].ids, - pos)) > -1) { -if (!virDomainIOThreadIDFind(def, pos)) { -virReportError(VIR_ERR_XML_DETAIL, "%s", - _("iothreadsched attribute 'iothreads' " - "uses undefined iothread ids")); -goto error; -} -} - -for (j = 0; j < i; j++) { -if (virBitmapOverlaps(def->cputune.iothreadsched[i].ids, - def->cputune.iothreadsched[j].ids)) { -virReportError(VIR_ERR_XML_DETAIL, "%s", - _("iothreadsched attributes 'iothreads' " - "must not overlap")); -goto error; -} -} -} } VIR_FREE(nodes); @@ -18448,29 +18409,6 @@ virDomainIOThreadIDDel(virDomainDefPtr def, } } -void -virDomainIOThreadSchedDelId(virDomainDefPtr def, -unsigned int iothreadid) -{ -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