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.
This commit is contained in:
parent
99c5fe0e7c
commit
6dfb4507f5
@ -2560,10 +2560,6 @@ void virDomainDefFree(virDomainDefPtr def)
|
|||||||
|
|
||||||
virBitmapFree(def->cputune.emulatorpin);
|
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);
|
virDomainNumaFree(def->numa);
|
||||||
|
|
||||||
virSysinfoDefFree(def->sysinfo);
|
virSysinfoDefFree(def->sysinfo);
|
||||||
@ -14623,25 +14619,26 @@ virDomainVcpuThreadSchedParse(xmlNodePtr node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static virDomainThreadSchedParamPtr
|
||||||
virDomainThreadSchedParse(xmlNodePtr node,
|
virDomainDefGetIOThreadSched(virDomainDefPtr def,
|
||||||
unsigned int minid,
|
unsigned int iothread)
|
||||||
unsigned int maxid,
|
|
||||||
const char *name,
|
|
||||||
virDomainThreadSchedParamPtr sp)
|
|
||||||
{
|
{
|
||||||
if (!(sp->ids = virDomainSchedulerParse(node, name, &sp->policy,
|
virDomainIOThreadIDDefPtr iothrinfo;
|
||||||
&sp->priority)))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (virBitmapNextSetBit(sp->ids, -1) < minid ||
|
if (!(iothrinfo = virDomainIOThreadIDFind(def, iothread)))
|
||||||
virBitmapLastSetBit(sp->ids) > maxid) {
|
return NULL;
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
_("%sched bitmap is out of range"), name);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return &iothrinfo->sched;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
virDomainIOThreadSchedParse(xmlNodePtr node,
|
||||||
|
virDomainDefPtr def)
|
||||||
|
{
|
||||||
|
return virDomainThreadSchedParseHelper(node, "iothreads",
|
||||||
|
virDomainDefGetIOThreadSched,
|
||||||
|
def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -15190,46 +15187,10 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|||||||
_("cannot extract iothreadsched nodes"));
|
_("cannot extract iothreadsched nodes"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (n) {
|
|
||||||
if (n > def->niothreadids) {
|
for (i = 0; i < n; i++) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
if (virDomainIOThreadSchedParse(nodes[i], def) < 0)
|
||||||
_("too many iothreadsched nodes in cputune"));
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
|
|
||||||
if (VIR_ALLOC_N(def->cputune.iothreadsched, n) < 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",
|
|
||||||
&def->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);
|
VIR_FREE(nodes);
|
||||||
|
|
||||||
@ -18381,29 +18342,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 (virBitmapIsAllClear(def->cputune.iothreadsched[i].ids)) {
|
|
||||||
virBitmapFree(def->cputune.iothreadsched[i].ids);
|
|
||||||
VIR_DELETE_ELEMENT(def->cputune.iothreadsched, i,
|
|
||||||
def->cputune.niothreadsched);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virDomainEventActionDefFormat(virBufferPtr buf,
|
virDomainEventActionDefFormat(virBufferPtr buf,
|
||||||
@ -21619,6 +21557,27 @@ virDomainFormatVcpuSchedDef(virDomainDefPtr def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
virDomainFormatIOThreadSchedDef(virDomainDefPtr def,
|
||||||
|
virBufferPtr buf)
|
||||||
|
{
|
||||||
|
virBitmapPtr allthreadmap;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (def->niothreadids == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!(allthreadmap = virDomainIOThreadIDMap(def)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
ret = virDomainFormatSchedDef(def, buf, "iothreads",
|
||||||
|
virDomainDefGetIOThreadSched, allthreadmap);
|
||||||
|
|
||||||
|
virBitmapFree(allthreadmap);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virDomainCputuneDefFormat(virBufferPtr buf,
|
virDomainCputuneDefFormat(virBufferPtr buf,
|
||||||
virDomainDefPtr def)
|
virDomainDefPtr def)
|
||||||
@ -21696,22 +21655,8 @@ virDomainCputuneDefFormat(virBufferPtr buf,
|
|||||||
if (virDomainFormatVcpuSchedDef(def, &childrenBuf) < 0)
|
if (virDomainFormatVcpuSchedDef(def, &childrenBuf) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
for (i = 0; i < def->cputune.niothreadsched; i++) {
|
if (virDomainFormatIOThreadSchedDef(def, &childrenBuf) < 0)
|
||||||
virDomainThreadSchedParamPtr sp = &def->cputune.iothreadsched[i];
|
goto cleanup;
|
||||||
char *ids = NULL;
|
|
||||||
|
|
||||||
if (!(ids = virBitmapFormat(sp->ids)))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
virBufferAsprintf(&childrenBuf, "<iothreadsched iothreads='%s' scheduler='%s'",
|
|
||||||
ids, virProcessSchedPolicyTypeToString(sp->policy));
|
|
||||||
VIR_FREE(ids);
|
|
||||||
|
|
||||||
if (sp->policy == VIR_PROC_POLICY_FIFO ||
|
|
||||||
sp->policy == VIR_PROC_POLICY_RR)
|
|
||||||
virBufferAsprintf(&childrenBuf, " priority='%d'", sp->priority);
|
|
||||||
virBufferAddLit(&childrenBuf, "/>\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virBufferUse(&childrenBuf)) {
|
if (virBufferUse(&childrenBuf)) {
|
||||||
virBufferAddLit(buf, "<cputune>\n");
|
virBufferAddLit(buf, "<cputune>\n");
|
||||||
|
@ -1898,7 +1898,6 @@ typedef enum {
|
|||||||
typedef struct _virDomainThreadSchedParam virDomainThreadSchedParam;
|
typedef struct _virDomainThreadSchedParam virDomainThreadSchedParam;
|
||||||
typedef virDomainThreadSchedParam *virDomainThreadSchedParamPtr;
|
typedef virDomainThreadSchedParam *virDomainThreadSchedParamPtr;
|
||||||
struct _virDomainThreadSchedParam {
|
struct _virDomainThreadSchedParam {
|
||||||
virBitmapPtr ids;
|
|
||||||
virProcessSchedPolicy policy;
|
virProcessSchedPolicy policy;
|
||||||
int priority;
|
int priority;
|
||||||
};
|
};
|
||||||
@ -2095,6 +2094,8 @@ struct _virDomainIOThreadIDDef {
|
|||||||
unsigned int iothread_id;
|
unsigned int iothread_id;
|
||||||
int thread_id;
|
int thread_id;
|
||||||
virBitmapPtr cpumask;
|
virBitmapPtr cpumask;
|
||||||
|
|
||||||
|
virDomainThreadSchedParam sched;
|
||||||
};
|
};
|
||||||
|
|
||||||
void virDomainIOThreadIDDefFree(virDomainIOThreadIDDefPtr def);
|
void virDomainIOThreadIDDefFree(virDomainIOThreadIDDefPtr def);
|
||||||
@ -2111,9 +2112,6 @@ struct _virDomainCputune {
|
|||||||
unsigned long long emulator_period;
|
unsigned long long emulator_period;
|
||||||
long long emulator_quota;
|
long long emulator_quota;
|
||||||
virBitmapPtr emulatorpin;
|
virBitmapPtr emulatorpin;
|
||||||
|
|
||||||
size_t niothreadsched;
|
|
||||||
virDomainThreadSchedParamPtr iothreadsched;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -2124,7 +2122,6 @@ struct _virDomainVcpuInfo {
|
|||||||
bool online;
|
bool online;
|
||||||
virBitmapPtr cpumask;
|
virBitmapPtr cpumask;
|
||||||
|
|
||||||
/* note: the sched.ids bitmap is unused so it doesn't have to be cleared */
|
|
||||||
virDomainThreadSchedParam sched;
|
virDomainThreadSchedParam sched;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2705,7 +2702,6 @@ virDomainIOThreadIDDefPtr virDomainIOThreadIDAdd(virDomainDefPtr def,
|
|||||||
virBitmapPtr virDomainIOThreadIDMap(virDomainDefPtr def)
|
virBitmapPtr virDomainIOThreadIDMap(virDomainDefPtr def)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
|
||||||
void virDomainIOThreadIDDel(virDomainDefPtr def, unsigned int iothread_id);
|
void virDomainIOThreadIDDel(virDomainDefPtr def, unsigned int iothread_id);
|
||||||
void virDomainIOThreadSchedDelId(virDomainDefPtr def, unsigned int iothread_id);
|
|
||||||
|
|
||||||
unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags);
|
unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags);
|
||||||
|
|
||||||
|
@ -346,7 +346,6 @@ virDomainIOThreadIDDefFree;
|
|||||||
virDomainIOThreadIDDel;
|
virDomainIOThreadIDDel;
|
||||||
virDomainIOThreadIDFind;
|
virDomainIOThreadIDFind;
|
||||||
virDomainIOThreadIDMap;
|
virDomainIOThreadIDMap;
|
||||||
virDomainIOThreadSchedDelId;
|
|
||||||
virDomainKeyWrapCipherNameTypeFromString;
|
virDomainKeyWrapCipherNameTypeFromString;
|
||||||
virDomainKeyWrapCipherNameTypeToString;
|
virDomainKeyWrapCipherNameTypeToString;
|
||||||
virDomainLeaseDefFree;
|
virDomainLeaseDefFree;
|
||||||
|
@ -6143,8 +6143,6 @@ qemuDomainHotplugDelIOThread(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
virDomainIOThreadIDDel(vm->def, iothread_id);
|
virDomainIOThreadIDDel(vm->def, iothread_id);
|
||||||
|
|
||||||
virDomainIOThreadSchedDelId(vm->def, iothread_id);
|
|
||||||
|
|
||||||
if (qemuDomainDelCgroupForThread(priv->cgroup,
|
if (qemuDomainDelCgroupForThread(priv->cgroup,
|
||||||
VIR_CGROUP_THREAD_IOTHREAD,
|
VIR_CGROUP_THREAD_IOTHREAD,
|
||||||
iothread_id) < 0)
|
iothread_id) < 0)
|
||||||
@ -6234,7 +6232,6 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
virDomainIOThreadIDDel(persistentDef, iothread_id);
|
virDomainIOThreadIDDel(persistentDef, iothread_id);
|
||||||
virDomainIOThreadSchedDelId(persistentDef, iothread_id);
|
|
||||||
persistentDef->iothreads--;
|
persistentDef->iothreads--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2281,34 +2281,6 @@ qemuProcessSetIOThreadsAffinity(virDomainObjPtr vm)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set Scheduler parameters for vCPU or I/O threads. */
|
|
||||||
int
|
|
||||||
qemuProcessSetSchedParams(int id,
|
|
||||||
pid_t pid,
|
|
||||||
size_t nsp,
|
|
||||||
virDomainThreadSchedParamPtr sp)
|
|
||||||
{
|
|
||||||
bool val = false;
|
|
||||||
size_t i = 0;
|
|
||||||
virDomainThreadSchedParamPtr s = NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < nsp; i++) {
|
|
||||||
if (virBitmapGetBit(sp[i].ids, id, &val) < 0) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("Cannot get bit from bitmap"));
|
|
||||||
}
|
|
||||||
if (val) {
|
|
||||||
s = &sp[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!s)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return virProcessSetScheduler(pid, s->policy, s->priority);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuProcessSetSchedulers(virDomainObjPtr vm)
|
qemuProcessSetSchedulers(virDomainObjPtr vm)
|
||||||
{
|
{
|
||||||
@ -2327,10 +2299,13 @@ qemuProcessSetSchedulers(virDomainObjPtr vm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < vm->def->niothreadids; i++) {
|
for (i = 0; i < vm->def->niothreadids; i++) {
|
||||||
if (qemuProcessSetSchedParams(vm->def->iothreadids[i]->iothread_id,
|
virDomainIOThreadIDDefPtr info = vm->def->iothreadids[i];
|
||||||
vm->def->iothreadids[i]->thread_id,
|
|
||||||
vm->def->cputune.niothreadsched,
|
if (info->sched.policy == VIR_PROC_POLICY_NONE)
|
||||||
vm->def->cputune.iothreadsched) < 0)
|
continue;
|
||||||
|
|
||||||
|
if (virProcessSetScheduler(info->thread_id, info->sched.policy,
|
||||||
|
info->sched.priority) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
<vcpupin vcpu='1' cpuset='1'/>
|
<vcpupin vcpu='1' cpuset='1'/>
|
||||||
<emulatorpin cpuset='1'/>
|
<emulatorpin cpuset='1'/>
|
||||||
<vcpusched vcpus='0-1' scheduler='fifo' priority='1'/>
|
<vcpusched vcpus='0-1' scheduler='fifo' priority='1'/>
|
||||||
<iothreadsched iothreads='1,3' scheduler='batch'/>
|
<iothreadsched iothreads='1-3' scheduler='batch'/>
|
||||||
<iothreadsched iothreads='2' scheduler='batch'/>
|
|
||||||
</cputune>
|
</cputune>
|
||||||
<os>
|
<os>
|
||||||
<type arch='i686' machine='pc'>hvm</type>
|
<type arch='i686' machine='pc'>hvm</type>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user