[libvirt] [PATCH 2/2] qemu: update domain live xml for virsh memtune with --live flag

Guannan Ren gren at redhat.com
Tue Mar 5 16:29:39 UTC 2013


virsh subcommand memtune forgot updating domain live xml
after setting cgroup value.
---
 src/qemu/qemu_driver.c | 36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 42b8c77..32b0522 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7303,11 +7303,13 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
     }
 
     if (set_swap_hard_limit) {
-        if (flags & VIR_DOMAIN_AFFECT_LIVE &&
-            (rc = virCgroupSetMemSwapHardLimit(group, swap_hard_limit)) < 0) {
-            virReportSystemError(-rc, "%s",
-                                 _("unable to set memory swap_hard_limit tunable"));
-            goto cleanup;
+        if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+            if ((rc = virCgroupSetMemSwapHardLimit(group, swap_hard_limit)) < 0) {
+                virReportSystemError(-rc, "%s",
+                                     _("unable to set memory swap_hard_limit tunable"));
+                goto cleanup;
+            }
+            vm->def->mem.swap_hard_limit = swap_hard_limit;
         }
 
         if (flags & VIR_DOMAIN_AFFECT_CONFIG)
@@ -7315,11 +7317,13 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
     }
 
     if (set_memory_hard_limit) {
-        if (flags & VIR_DOMAIN_AFFECT_LIVE &&
-            (rc = virCgroupSetMemoryHardLimit(group, memory_hard_limit)) < 0) {
-            virReportSystemError(-rc, "%s",
-                                 _("unable to set memory hard_limit tunable"));
-            goto cleanup;
+        if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+            if ((rc = virCgroupSetMemoryHardLimit(group, memory_hard_limit)) < 0) {
+                virReportSystemError(-rc, "%s",
+                                     _("unable to set memory hard_limit tunable"));
+                goto cleanup;
+            }
+            vm->def->mem.hard_limit = memory_hard_limit;
         }
 
         if (flags & VIR_DOMAIN_AFFECT_CONFIG)
@@ -7327,11 +7331,13 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
     }
 
     if (set_memory_soft_limit) {
-        if (flags & VIR_DOMAIN_AFFECT_LIVE &&
-            (rc = virCgroupSetMemorySoftLimit(group, memory_soft_limit)) < 0) {
-            virReportSystemError(-rc, "%s",
-                                 _("unable to set memory soft_limit tunable"));
-            goto cleanup;
+        if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+            if ((rc = virCgroupSetMemorySoftLimit(group, memory_soft_limit)) < 0) {
+                virReportSystemError(-rc, "%s",
+                                     _("unable to set memory soft_limit tunable"));
+                goto cleanup;
+            }
+            vm->def->mem.soft_limit = memory_soft_limit;
         }
 
         if (flags & VIR_DOMAIN_AFFECT_CONFIG)
-- 
1.7.11.2




More information about the libvir-list mailing list