[libvirt] [PATCHv4 4/4] blkiotune: add qemu support for blkiotune.device_weight

Eric Blake eblake at redhat.com
Tue Nov 29 18:50:56 UTC 2011


On 11/15/2011 12:22 AM, Hu Tao wrote:
> On Mon, Nov 14, 2011 at 09:30:02PM -0700, Eric Blake wrote:
>> From: Hu Tao <hutao at cn.fujitsu.com>
>>
>> Implement setting/getting per-device blkio weights in qemu,
>> using the cgroups blkio.weight_device tunable.
> 
> Does more than the function name says. Would it be better to just do the
> parsing here, and set the cgroup values after parsing(see my comment to
> patch 3 for filtering out 0-weight when writing to xml):

ACK to your improvements for setting, but you forgot to do 0-weight
filtering from the getting side:

diff --git i/src/qemu/qemu_driver.c w/src/qemu/qemu_driver.c
index a8fea6c..105bdde 100644
--- i/src/qemu/qemu_driver.c
+++ w/src/qemu/qemu_driver.c
@@ -6270,9 +6270,14 @@ static int
qemuDomainGetBlkioParameters(virDomainPtr dom,
             case 1: /* blkiotune.device_weight */
                 if (vm->def->blkio.ndevices > 0) {
                     virBuffer buf = VIR_BUFFER_INITIALIZER;
+                    bool comma = false;
                     for (j = 0; j < vm->def->blkio.ndevices; j++) {
-                        if (j)
+                        if (!vm->def->blkio.devices[j].weight)
+                            continue;
+                        if (comma)
                             virBufferAddChar(&buf, ',');
+                        else
+                            comma = true;
                         virBufferAsprintf(&buf, "%s,%u",
                                           vm->def->blkio.devices[j].path,

vm->def->blkio.devices[j].weight);
@@ -6282,7 +6287,8 @@ static int
qemuDomainGetBlkioParameters(virDomainPtr dom,
                         goto cleanup;
                     }
                     param->value.s = virBufferContentAndReset(&buf);
-                } else {
+                }
+                if (!param->value.s) {
                     param->value.s = strdup("");
                     if (!param->value.s) {
                         virReportOOMError();


-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20111129/d43cf8ac/attachment-0001.sig>


More information about the libvir-list mailing list