[libvirt] [PATCH] simplify xenXMDomainPinVcpu function

supersede tedious statements getting cpu bitmap from parameter cpumap by virBitmapNewData function Signed-off-by: liguang <lig.fnst@cn.fujitsu.com> --- src/xen/xm_internal.c | 38 +++----------------------------------- 1 files changed, 3 insertions(+), 35 deletions(-) diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c index a4dec62..97c19ef 100644 --- a/src/xen/xm_internal.c +++ b/src/xen/xm_internal.c @@ -827,12 +827,7 @@ int xenXMDomainPinVcpu(virDomainPtr domain, xenUnifiedPrivatePtr priv; const char *filename; xenXMConfCachePtr entry; - virBuffer mapbuf = VIR_BUFFER_INITIALIZER; - char *mapstr = NULL, *mapsave = NULL; - int i, j, n, comma = 0; int ret = -1; - virBitmapPtr cpuset = NULL; - int maxcpu = XEN_MAX_PHYSICAL_CPU; if (domain == NULL || domain->conn == NULL || domain->name == NULL || cpumap == NULL || maplen < 1 || maplen > (int)sizeof(cpumap_t)) { @@ -863,43 +858,16 @@ int xenXMDomainPinVcpu(virDomainPtr domain, goto cleanup; } - /* from bit map, build character string of mapped CPU numbers */ - for (i = 0; i < maplen; i++) - for (j = 0; j < 8; j++) - if ((cpumap[i] & (1 << j))) { - n = i*8 + j; - - if (comma) - virBufferAddLit (&mapbuf, ","); - comma = 1; - - virBufferAsprintf (&mapbuf, "%d", n); - } - - if (virBufferError(&mapbuf)) { - virBufferFreeAndReset(&mapbuf); - virReportOOMError(); - goto cleanup; - } - - mapstr = virBufferContentAndReset(&mapbuf); - mapsave = mapstr; - - if (virBitmapParse(mapstr, 0, &cpuset, maxcpu) < 0) - goto cleanup; - virBitmapFree(entry->def->cpumask); - entry->def->cpumask = cpuset; - cpuset = NULL; - + entry->def->cpumask = virBitmapNewData(cpumap, maplen); + if (!entry->def->cpumask) + goto cleanup; if (xenXMConfigSaveFile(domain->conn, entry->filename, entry->def) < 0) goto cleanup; ret = 0; cleanup: - VIR_FREE(mapsave); - VIR_FREE(cpuset); xenUnifiedUnlock(priv); return ret; } -- 1.7.2.5

On 09/20/12 07:31, liguang wrote:
supersede tedious statements getting cpu bitmap from parameter cpumap by virBitmapNewData function
Signed-off-by: liguang <lig.fnst@cn.fujitsu.com> --- src/xen/xm_internal.c | 38 +++----------------------------------- 1 files changed, 3 insertions(+), 35 deletions(-)
Please don't send the patches addressed to developers directly, just post them to the list. That approach won't guarantee you any exclusive review. Also there are other people that review patches. Now to the patch: Nice cleanup. ACK && will push soon. I also added you to the AUTHORS file. If you prefer a different spelling let us know. Peter

Hi, Peter 在 2012-09-20四的 14:07 +0200,Peter Krempa写道:
On 09/20/12 07:31, liguang wrote:
supersede tedious statements getting cpu bitmap from parameter cpumap by virBitmapNewData function
Signed-off-by: liguang <lig.fnst@cn.fujitsu.com> --- src/xen/xm_internal.c | 38 +++----------------------------------- 1 files changed, 3 insertions(+), 35 deletions(-)
Please don't send the patches addressed to developers directly, just post them to the list. That approach won't guarantee you any exclusive review. Also there are other people that review patches.
OK, I see.
Now to the patch: Nice cleanup. ACK && will push soon. I also added you to the AUTHORS file. If you prefer a different spelling let us know.
Thanks for your review.
Peter
-- liguang lig.fnst@cn.fujitsu.com FNST linux kernel team
participants (2)
-
liguang
-
Peter Krempa