[libvirt] [PATCH 5/5] qemu: Sync BlkioDevice values when setting them in cgroups

Martin Kletzander mkletzan at redhat.com
Mon Aug 3 14:50:08 UTC 2015


The problem here is that there are some values that kernel accepts, but
does not set them, for example 18446744073709551615 which acts the same
way as zero.  Let's do the same thing we do with other tuning options
and re-read them right after they are set in order to keep our internal
structures up-to-date.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1165580

Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
---
 src/qemu/qemu_cgroup.c | 20 +++++++++++++++-----
 src/qemu/qemu_driver.c | 25 ++++++++++++++++++++-----
 2 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index e1a28272ee7b..0da6c0238696 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -436,27 +436,37 @@ qemuSetupBlkioCgroup(virDomainObjPtr vm)
             virBlkioDevicePtr dev = &vm->def->blkio.devices[i];
             if (dev->weight &&
                 (virCgroupSetBlkioDeviceWeight(priv->cgroup, dev->path,
-                                               dev->weight) < 0))
+                                               dev->weight) < 0 ||
+                 virCgroupGetBlkioDeviceWeight(priv->cgroup, dev->path,
+                                               &dev->weight) < 0))
                 return -1;

             if (dev->riops &&
                 (virCgroupSetBlkioDeviceReadIops(priv->cgroup, dev->path,
-                                                 dev->riops) < 0))
+                                                 dev->riops) < 0 ||
+                 virCgroupGetBlkioDeviceReadIops(priv->cgroup, dev->path,
+                                                 &dev->riops) < 0))
                 return -1;

             if (dev->wiops &&
                 (virCgroupSetBlkioDeviceWriteIops(priv->cgroup, dev->path,
-                                                  dev->wiops) < 0))
+                                                  dev->wiops) < 0 ||
+                 virCgroupGetBlkioDeviceWriteIops(priv->cgroup, dev->path,
+                                                  &dev->wiops) < 0))
                 return -1;

             if (dev->rbps &&
                 (virCgroupSetBlkioDeviceReadBps(priv->cgroup, dev->path,
-                                                dev->rbps) < 0))
+                                                dev->rbps) < 0 ||
+                 virCgroupGetBlkioDeviceReadBps(priv->cgroup, dev->path,
+                                                &dev->rbps) < 0))
                 return -1;

             if (dev->wbps &&
                 (virCgroupSetBlkioDeviceWriteBps(priv->cgroup, dev->path,
-                                                 dev->wbps) < 0))
+                                                 dev->wbps) < 0 ||
+                 virCgroupGetBlkioDeviceWriteBps(priv->cgroup, dev->path,
+                                                 &dev->wbps) < 0))
                 return -1;
         }
     }
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7a984a86ab3a..aa3e05e4a258 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -9191,7 +9191,10 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
                     for (j = 0; j < ndevices; j++) {
                         if (virCgroupSetBlkioDeviceWeight(priv->cgroup,
                                                           devices[j].path,
-                                                          devices[j].weight) < 0) {
+                                                          devices[j].weight) < 0 ||
+                            virCgroupGetBlkioDeviceWeight(priv->cgroup,
+                                                          devices[j].path,
+                                                          &devices[j].weight) < 0) {
                             ret = -1;
                             break;
                         }
@@ -9200,7 +9203,10 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
                     for (j = 0; j < ndevices; j++) {
                         if (virCgroupSetBlkioDeviceReadIops(priv->cgroup,
                                                             devices[j].path,
-                                                            devices[j].riops) < 0) {
+                                                            devices[j].riops) < 0 ||
+                            virCgroupGetBlkioDeviceReadIops(priv->cgroup,
+                                                            devices[j].path,
+                                                            &devices[j].riops) < 0) {
                             ret = -1;
                             break;
                         }
@@ -9209,7 +9215,10 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
                     for (j = 0; j < ndevices; j++) {
                         if (virCgroupSetBlkioDeviceWriteIops(priv->cgroup,
                                                              devices[j].path,
-                                                             devices[j].wiops) < 0) {
+                                                             devices[j].wiops) < 0 ||
+                            virCgroupGetBlkioDeviceWriteIops(priv->cgroup,
+                                                             devices[j].path,
+                                                             &devices[j].wiops) < 0) {
                             ret = -1;
                             break;
                         }
@@ -9218,7 +9227,10 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
                     for (j = 0; j < ndevices; j++) {
                         if (virCgroupSetBlkioDeviceReadBps(priv->cgroup,
                                                            devices[j].path,
-                                                           devices[j].rbps) < 0) {
+                                                           devices[j].rbps) < 0 ||
+                            virCgroupGetBlkioDeviceReadBps(priv->cgroup,
+                                                           devices[j].path,
+                                                           &devices[j].rbps) < 0) {
                             ret = -1;
                             break;
                         }
@@ -9227,7 +9239,10 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
                     for (j = 0; j < ndevices; j++) {
                         if (virCgroupSetBlkioDeviceWriteBps(priv->cgroup,
                                                             devices[j].path,
-                                                            devices[j].wbps) < 0) {
+                                                            devices[j].wbps) < 0 ||
+                            virCgroupGetBlkioDeviceWriteBps(priv->cgroup,
+                                                            devices[j].path,
+                                                            &devices[j].wbps) < 0) {
                             ret = -1;
                             break;
                         }
-- 
2.5.0




More information about the libvir-list mailing list