mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 23:37:42 +00:00
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.
This commit is contained in:
parent
ba8074b807
commit
b0bfbd82d1
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user