提交 92ff72b5 编写于 作者: D Daniel P. Berrange

Misc NUMA related fixes

上级 e4073623
Fri Apr 3 13:41:00 BST 2009 Daniel P. Berrange <berrange@redhat.com>
Misc NUMA memory fixes
* qemud/remote.c: Fix check of error status in the helper
remoteDispatchNodeGetCellsFreeMemory
* src/qemu_driver.c: Report error if requested start cell
is out of range. Fix return value if NUMA is not available
* src/virsh.c: Convert memory to KB for freecell command.
Check return value of virNodeGetFreeMemory
Fri Apr 3 11:55:00 BST 2009 Daniel P. Berrange <berrange@redhat.com>
Support PCI passthrough in Xen driver
......
......@@ -662,6 +662,7 @@ remoteDispatchNodeGetCellsFreeMemory (struct qemud_server *server ATTRIBUTE_UNUS
remote_node_get_cells_free_memory_args *args,
remote_node_get_cells_free_memory_ret *ret)
{
int err;
if (args->maxCells > REMOTE_NODE_MAX_CELLS) {
remoteDispatchFormatError (rerr,
......@@ -675,15 +676,16 @@ remoteDispatchNodeGetCellsFreeMemory (struct qemud_server *server ATTRIBUTE_UNUS
return -1;
}
ret->freeMems.freeMems_len = virNodeGetCellsFreeMemory(conn,
(unsigned long long *)ret->freeMems.freeMems_val,
args->startCell,
args->maxCells);
if (ret->freeMems.freeMems_len == 0) {
err = virNodeGetCellsFreeMemory(conn,
(unsigned long long *)ret->freeMems.freeMems_val,
args->startCell,
args->maxCells);
if (err <= 0) {
VIR_FREE(ret->freeMems.freeMems_val);
remoteDispatchConnError(rerr, conn);
return -1;
}
ret->freeMems.freeMems_len = err;
return 0;
}
......
......@@ -1878,15 +1878,23 @@ qemudNodeGetCellsFreeMemory(virConnectPtr conn,
{
int n, lastCell, numCells;
int ret = -1;
int maxCell;
if (numa_available() < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT,
"%s", _("NUMA not supported on this host"));
goto cleanup;
}
maxCell = numa_max_node();
if (startCell > maxCell) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("start cell %d out of range (0-%d)"),
startCell, maxCell);
goto cleanup;
}
lastCell = startCell + maxCells - 1;
if (lastCell > numa_max_node())
lastCell = numa_max_node();
if (lastCell > maxCell)
lastCell = maxCell;
for (numCells = 0, n = startCell ; n <= lastCell ; n++) {
long long mem;
......@@ -1906,7 +1914,7 @@ cleanup:
static unsigned long long
qemudNodeGetFreeMemory (virConnectPtr conn)
{
unsigned long long freeMem = -1;
unsigned long long freeMem = 0;
int n;
if (numa_available() < 0) {
......
......@@ -1654,6 +1654,8 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
cell = vshCommandOptInt(cmd, "cellno", &cell_given);
if (!cell_given) {
memory = virNodeGetFreeMemory(ctl->conn);
if (memory == 0)
return FALSE;
} else {
ret = virNodeGetCellsFreeMemory(ctl->conn, &memory, cell, 1);
if (ret != 1)
......@@ -1661,9 +1663,9 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
}
if (cell == -1)
vshPrint(ctl, "%s: %llu kB\n", _("Total"), memory);
vshPrint(ctl, "%s: %llu kB\n", _("Total"), (memory/1024));
else
vshPrint(ctl, "%d: %llu kB\n", cell, memory);
vshPrint(ctl, "%d: %llu kB\n", cell, (memory/1024));
return TRUE;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册