Create qemuDomainIOThreadInfo which currently will just be the thread_id returned from IOThreadInfo, but will soon expand to handle the needs of live IOThread data for adding/deleting IOThread's Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/qemu/qemu_cgroup.c | 3 ++- src/qemu/qemu_domain.c | 19 ++++++++++++++----- src/qemu/qemu_domain.h | 10 ++++++++-- src/qemu/qemu_driver.c | 4 ++-- src/qemu/qemu_process.c | 7 ++++--- 5 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index e83342d..da07346 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -1196,7 +1196,8 @@ qemuSetupCgroupForIOThreads(virDomainObjPtr vm) goto cleanup; /* move the thread for iothread to sub dir */ - if (virCgroupAddTask(cgroup_iothread, priv->iothreadpids[i]) < 0) + if (virCgroupAddTask(cgroup_iothread, + priv->iothreadpids[i]->thread_id) < 0) goto cleanup; if (period || quota) { diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ae632c5..2b4a519 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -429,6 +429,8 @@ qemuDomainObjPrivateAlloc(void) static void qemuDomainObjPrivateFree(void *data) { + size_t i; + qemuDomainObjPrivatePtr priv = data; virObjectUnref(priv->qemuCaps); @@ -440,6 +442,8 @@ qemuDomainObjPrivateFree(void *data) virDomainChrSourceDefFree(priv->monConfig); qemuDomainObjFreeJob(priv); VIR_FREE(priv->vcpupids); + for (i = 0; i < priv->niothreadpids; i++) + VIR_FREE(priv->iothreadpids[i]); VIR_FREE(priv->iothreadpids); VIR_FREE(priv->lockState); VIR_FREE(priv->origname); @@ -507,7 +511,7 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data) virBufferAdjustIndent(buf, 2); for (i = 0; i < priv->niothreadpids; i++) { virBufferAsprintf(buf, "<iothread pid='%d'/>\n", - priv->iothreadpids[i]); + priv->iothreadpids[i]->thread_id); } virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</iothreads>\n"); @@ -638,16 +642,21 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data) goto error; if (n) { priv->niothreadpids = n; - if (VIR_REALLOC_N(priv->iothreadpids, priv->niothreadpids) < 0) + if (VIR_ALLOC_N(priv->iothreadpids, priv->niothreadpids) < 0) goto error; for (i = 0; i < n; i++) { + qemuDomainIOThreadInfoPtr info = NULL; char *pidstr = virXMLPropString(nodes[i], "pid"); - if (!pidstr) - goto error; + if (!pidstr || VIR_ALLOC(info) < 0) { + VIR_FREE(pidstr); + VIR_FREE(info); + goto error; + } + priv->iothreadpids[i] = info; if (virStrToLong_i(pidstr, NULL, 10, - &(priv->iothreadpids[i])) < 0) { + &info->thread_id) < 0) { VIR_FREE(pidstr); goto error; } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 3225abb..2f75c70 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -136,6 +136,12 @@ struct qemuDomainJobObj { typedef void (*qemuDomainCleanupCallback)(virQEMUDriverPtr driver, virDomainObjPtr vm); +typedef struct _qemuDomainIOThreadInfo qemuDomainIOThreadInfo; +typedef qemuDomainIOThreadInfo *qemuDomainIOThreadInfoPtr; +struct _qemuDomainIOThreadInfo { + int thread_id; +}; + typedef struct _qemuDomainObjPrivate qemuDomainObjPrivate; typedef qemuDomainObjPrivate *qemuDomainObjPrivatePtr; struct _qemuDomainObjPrivate { @@ -158,8 +164,8 @@ struct _qemuDomainObjPrivate { int nvcpupids; int *vcpupids; - int niothreadpids; - int *iothreadpids; + size_t niothreadpids; + qemuDomainIOThreadInfoPtr *iothreadpids; virDomainPCIAddressSetPtr pciaddrs; virDomainCCWAddressSetPtr ccwaddrs; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f37a11e..1c575d0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6053,7 +6053,7 @@ qemuDomainPinIOThread(virDomainPtr dom, if (iothread_id > priv->niothreadpids) { virReportError(VIR_ERR_INVALID_ARG, - _("iothread value out of range %d > %d"), + _("iothread value out of range %d > %zu"), iothread_id, priv->niothreadpids); goto endjob; } @@ -6092,7 +6092,7 @@ qemuDomainPinIOThread(virDomainPtr dom, goto endjob; } } else { - if (virProcessSetAffinity(priv->iothreadpids[iothread_id - 1], + if (virProcessSetAffinity(priv->iothreadpids[iothread_id - 1]->thread_id, pcpumap) < 0) { virReportError(VIR_ERR_SYSTEM_ERROR, _("failed to set cpu affinity for IOThread %d"), diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 753afe8..939b8f5 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2272,7 +2272,7 @@ qemuProcessDetectIOThreadPIDs(virQEMUDriverPtr driver, priv->niothreadpids = niothreads; for (i = 0; i < priv->niothreadpids; i++) - priv->iothreadpids[i] = iothreads[i]->thread_id; + priv->iothreadpids[i]->thread_id = iothreads[i]->thread_id; ret = 0; @@ -2469,7 +2469,8 @@ qemuProcessSetIOThreadsAffinity(virDomainObjPtr vm) i + 1))) continue; - if (virProcessSetAffinity(priv->iothreadpids[i], pininfo->cpumask) < 0) + if (virProcessSetAffinity(priv->iothreadpids[i]->thread_id, + pininfo->cpumask) < 0) goto cleanup; } ret = 0; @@ -2520,7 +2521,7 @@ qemuProcessSetSchedulers(virDomainObjPtr vm) } for (i = 0; i < priv->niothreadpids; i++) { - if (qemuProcessSetSchedParams(i + 1, priv->iothreadpids[i], + if (qemuProcessSetSchedParams(i + 1, priv->iothreadpids[i]->thread_id, vm->def->cputune.niothreadsched, vm->def->cputune.iothreadsched) < 0) return -1; -- 2.1.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list