提交 740be006 编写于 作者: L liguang 提交者: Peter Krempa

simplify xenXMDomainPinVcpu function

supersede tedious statements getting cpu bitmap
from parameter cpumap by virBitmapNewData function
Signed-off-by: Nliguang <lig.fnst@cn.fujitsu.com>
上级 ea446266
...@@ -265,6 +265,7 @@ Patches have also been contributed by: ...@@ -265,6 +265,7 @@ Patches have also been contributed by:
Jasper Lievisse Adriaanse <jasper@humppa.nl> Jasper Lievisse Adriaanse <jasper@humppa.nl>
Paul Eggert <eggert@cs.ucla.edu> Paul Eggert <eggert@cs.ucla.edu>
Dwight Engen <dwight.engen@oracle.com> Dwight Engen <dwight.engen@oracle.com>
liguang <lig.fnst@cn.fujitsu.com>
[....send patches to get your name here....] [....send patches to get your name here....]
......
...@@ -827,12 +827,7 @@ int xenXMDomainPinVcpu(virDomainPtr domain, ...@@ -827,12 +827,7 @@ int xenXMDomainPinVcpu(virDomainPtr domain,
xenUnifiedPrivatePtr priv; xenUnifiedPrivatePtr priv;
const char *filename; const char *filename;
xenXMConfCachePtr entry; xenXMConfCachePtr entry;
virBuffer mapbuf = VIR_BUFFER_INITIALIZER;
char *mapstr = NULL, *mapsave = NULL;
int i, j, n, comma = 0;
int ret = -1; int ret = -1;
virBitmapPtr cpuset = NULL;
int maxcpu = XEN_MAX_PHYSICAL_CPU;
if (domain == NULL || domain->conn == NULL || domain->name == NULL if (domain == NULL || domain->conn == NULL || domain->name == NULL
|| cpumap == NULL || maplen < 1 || maplen > (int)sizeof(cpumap_t)) { || cpumap == NULL || maplen < 1 || maplen > (int)sizeof(cpumap_t)) {
...@@ -863,43 +858,16 @@ int xenXMDomainPinVcpu(virDomainPtr domain, ...@@ -863,43 +858,16 @@ int xenXMDomainPinVcpu(virDomainPtr domain,
goto cleanup; 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); virBitmapFree(entry->def->cpumask);
entry->def->cpumask = cpuset; entry->def->cpumask = virBitmapNewData(cpumap, maplen);
cpuset = NULL; if (!entry->def->cpumask)
goto cleanup;
if (xenXMConfigSaveFile(domain->conn, entry->filename, entry->def) < 0) if (xenXMConfigSaveFile(domain->conn, entry->filename, entry->def) < 0)
goto cleanup; goto cleanup;
ret = 0; ret = 0;
cleanup: cleanup:
VIR_FREE(mapsave);
VIR_FREE(cpuset);
xenUnifiedUnlock(priv); xenUnifiedUnlock(priv);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册