ping :) On 02/02/2012 07:57 PM, Guannan Ren wrote:
src/qemu/qemu_driver.c When run "virsh blkiotune dom --device-weights /dev/sda,400 --config" it couldn't be persistent after dom restart. The patch fix it. --- src/qemu/qemu_driver.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d66140b..1a53088 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5975,9 +5975,13 @@ qemuDomainMergeDeviceWeights(virBlkioDeviceWeightPtr *def, size_t *def_size, virReportOOMError(); return -1; } - (*def)[*def_size - 1].path = dw->path; + (*def)[*def_size - 1].path = strdup(dw->path); + if (!(*def)[*def_size - 1].path) { + virReportOOMError(); + return -1; + } + (*def)[*def_size - 1].weight = dw->weight; - dw->path = NULL; } } @@ -5985,6 +5989,46 @@ qemuDomainMergeDeviceWeights(virBlkioDeviceWeightPtr *def, size_t *def_size, } static int +qemuDomainiDefineDeviceWeights(virDomainDefPtr persistentDef, + virBlkioDeviceWeightPtr devices, size_t ndevices) +{ + int i; + virBlkioDeviceWeightPtr dw, result = NULL; + + if (!persistentDef->blkio.devices) { + if (VIR_ALLOC_N(result, ndevices)< 0) { + virReportOOMError(); + goto cleanup; + } + + for (i = 0; i< ndevices; i++) { + dw =&devices[i]; + result[i].path = strdup(dw->path); + if (!result[i].path) { + virReportOOMError(); + goto cleanup; + } + result[i].weight = dw->weight; + } + + persistentDef->blkio.devices = result; + } else { + if (qemuDomainMergeDeviceWeights(&persistentDef->blkio.devices, +&persistentDef->blkio.ndevices, + devices, ndevices)< 0) + return -1; + } + + persistentDef->blkio.ndevices = ndevices; + return 0; + +cleanup: + virBlkioDeviceWeightArrayClear(result, ndevices); + VIR_FREE(result); + return -1; +} + +static int qemuDomainSetBlkioParameters(virDomainPtr dom, virTypedParameterPtr params, int nparams, @@ -6116,6 +6160,11 @@ qemuDomainSetBlkioParameters(virDomainPtr dom, ret = -1; continue; } + if (qemuDomainiDefineDeviceWeights(persistentDef, + devices, + ndevices)< 0) + ret = -1; + if (qemuDomainMergeDeviceWeights(&vm->def->blkio.devices, &vm->def->blkio.ndevices, devices, ndevices)< 0)
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list