[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] memtune: Add min_guarantee to the virsh tool



Hi,

I am adding the min_guarantee to the memtune command with this patch. I have
tested this at the virsh tool level. This parameter is not supported by QEMU
or LXC. Can be used by ESX and in future by other hypervisors.

Nikunj

From: Nikunj A. Dadhania <nikunj linux vnet ibm com>

tools/virsh.c: Add new memory tunable "min_guarantee", currently the user
would be ESX.
tools/virsh.pod: Update the manpage


Signed-off-by: Nikunj A. Dadhania <nikunj linux vnet ibm com>
---
 tools/virsh.c   |   17 +++++++++++++++--
 tools/virsh.pod |    2 +-
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index fe35eb9..e79bfbb 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2632,6 +2632,8 @@ static const vshCmdOptDef opts_memtune[] = {
      N_("Memory during contention in kilobytes")},
     {VIR_DOMAIN_SWAP_HARD_LIMIT, VSH_OT_STRING, VSH_OFLAG_NONE,
      N_("Max swap in kilobytes")},
+    {VIR_DOMAIN_MEMORY_MIN_GUARANTEE, VSH_OT_STRING, VSH_OFLAG_NONE,
+     N_("Min guaranteed memory in kilobytes")},
     {NULL, 0, 0, NULL}
 };
 
@@ -2639,7 +2641,7 @@ static int
 cmdMemtune(vshControl * ctl, const vshCmd * cmd)
 {
     virDomainPtr dom;
-    int hard_limit, soft_limit, swap_hard_limit;
+    int hard_limit, soft_limit, swap_hard_limit, min_guarantee;
     int nparams = 0;
     unsigned int i = 0;
     virMemoryParameterPtr params = NULL, temp = NULL;
@@ -2667,6 +2669,12 @@ cmdMemtune(vshControl * ctl, const vshCmd * cmd)
     if (swap_hard_limit)
         nparams++;
 
+    min_guarantee =
+        vshCommandOptInt(cmd, VIR_DOMAIN_MEMORY_MIN_GUARANTEE,
+                         &min_guarantee);
+    if (min_guarantee)
+        nparams++;
+
     if (nparams == 0) {
         /* get the number of memory parameters */
         if ((virDomainGetMemoryParameters(dom, NULL, &nparams, 0) != 0) &&
@@ -2711,7 +2719,7 @@ cmdMemtune(vshControl * ctl, const vshCmd * cmd)
                              params[i].value.b);
                     break;
                 default:
-                    vshPrint(ctl, "unimplemented scheduler parameter type\n");
+                    vshPrint(ctl, "unimplemented memory parameter type\n");
             }
         }
 
@@ -2746,6 +2754,11 @@ cmdMemtune(vshControl * ctl, const vshCmd * cmd)
                 strncpy(temp->field, VIR_DOMAIN_SWAP_HARD_LIMIT,
                         sizeof(temp->field));
                 swap_hard_limit = 0;
+            } else if (min_guarantee) {
+                temp->value.ul = min_guarantee;
+                strncpy(temp->field, VIR_DOMAIN_MEMORY_MIN_GUARANTEE,
+                        sizeof(temp->field));
+                min_guarantee = 0;
             }
         }
         if (virDomainSetMemoryParameters(dom, params, nparams, 0) != 0)
diff --git a/tools/virsh.pod b/tools/virsh.pod
index cb8e942..5f06360 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -460,7 +460,7 @@ kilobytes.
 
 Displays the domain memory parameters.
 
-=item B<memtune> I<domain-id> optional I<--hard-limit> B<kilobytes> optional I<--soft-limit> B<kilobytes> optional I<--swap-hard-limit> B<kilobytes>
+=item B<memtune> I<domain-id> optional I<--hard-limit> B<kilobytes> optional I<--soft-limit> B<kilobytes> optional I<--swap-hard-limit> B<kilobytes> -I<--min-guarantee> B<kilobytes>
 
 Allows you to set the domain memory parameters. LXC and QEMU/KVM supports these parameters.
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]