]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
memtune: Add min_guarantee to the virsh memtune command
authorNikunj A. Dadhania <nikunj@linux.vnet.ibm.com>
Tue, 19 Oct 2010 12:45:35 +0000 (14:45 +0200)
committerDaniel Veillard <veillard@redhat.com>
Tue, 19 Oct 2010 12:45:35 +0000 (14:45 +0200)
* tools/virsh.c: Add new memory tunable "min_guarantee", currently only
  ESX can use this
* tools/virsh.pod: Update the manpage

tools/virsh.c
tools/virsh.pod

index 17cc763052fe3d6c94010aae5941367eefbb16d0..4f8c49547b4f40c25972e98792c78222fdfc46ee 100644 (file)
@@ -2693,6 +2693,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}
 };
 
@@ -2700,7 +2702,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;
@@ -2728,6 +2730,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) &&
@@ -2772,7 +2780,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");
             }
         }
 
@@ -2807,6 +2815,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)
index 199046bc54a9ea981920d57d7843c7b01517b9fc..943a56325710d4caf91f3ca2b38fcbe638b23675 100644 (file)
@@ -517,7 +517,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.