提交 b0bfbd82 编写于 作者: E Eric Blake

qemu: make blkiodevice weights easier to read

The merge code had too many indirections to easily analyze.

* src/qemu/qemu_driver.c (qemuDomainMergeDeviceWeights): Pick
better variable names.
上级 ba8074b8
...@@ -5976,35 +5976,40 @@ cleanup: ...@@ -5976,35 +5976,40 @@ cleanup:
return -1; return -1;
} }
/* Modify def to reflect all device weight changes described in tmp. */ /* Modify dest_array to reflect all device weight changes described in
* src_array. */
static int static int
qemuDomainMergeDeviceWeights(virBlkioDeviceWeightPtr *def, size_t *def_size, qemuDomainMergeDeviceWeights(virBlkioDeviceWeightPtr *dest_array,
virBlkioDeviceWeightPtr tmp, size_t tmp_size) size_t *dest_size,
virBlkioDeviceWeightPtr src_array,
size_t src_size)
{ {
int i, j; int i, j;
virBlkioDeviceWeightPtr dw; virBlkioDeviceWeightPtr dest, src;
for (i = 0; i < tmp_size; i++) { for (i = 0; i < src_size; i++) {
bool found = false; bool found = false;
dw = &tmp[i]; src = &src_array[i];
for (j = 0; j < *def_size; j++) { for (j = 0; j < *dest_size; j++) {
if (STREQ(dw->path, (*def)[j].path)) { dest = &(*dest_array)[j];
if (STREQ(src->path, dest->path)) {
found = true; found = true;
(*def)[j].weight = dw->weight; dest->weight = src->weight;
break; break;
} }
} }
if (!found) { if (!found) {
if (!dw->weight) if (!src->weight)
continue; continue;
if (VIR_EXPAND_N(*def, *def_size, 1) < 0) { if (VIR_EXPAND_N(*dest_array, *dest_size, 1) < 0) {
virReportOOMError(); virReportOOMError();
return -1; return -1;
} }
(*def)[*def_size - 1].path = dw->path; dest = &(*dest_array)[*dest_size - 1];
(*def)[*def_size - 1].weight = dw->weight; dest->path = src->path;
dw->path = NULL; dest->weight = src->weight;
src->path = NULL;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册