diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index a4821e1efa..a8a1fac40c 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -194,6 +194,12 @@
<memoryBacking>
<hugepages/>
</memoryBacking>
+ <memtune>
+ <hard_limit>1048576</hard_limit>
+ <soft_limit>131072</soft_limit>
+ <swap_hard_limit>2097152</swap_hard_limit>
+ <min_guarantee>65536</min_guarantee>
+ </memtune>
<vcpu cpuset="1-4,^3,6">2</vcpu>
...
@@ -211,6 +217,26 @@
hugepages
element set within it. This tells the
hypervisor that the guest should have its memory allocated using
hugepages instead of the normal native page size.
+
memtune
+ The optional memtune
element provides details
+ regarding the memory tuneable parameters for the domain. If this is
+ omitted, it defaults to the OS provided defaults.
+ hard_limit
+ The optional hard_limit
element is the maximum memory
+ the guest can use. The units for this value are kilobytes (i.e. blocks
+ of 1024 bytes)
+ soft_limit
+ The optional soft_limit
element is the memory limit to
+ enforce during memory contention. The units for this value are
+ kilobytes (i.e. blocks of 1024 bytes)
+ swap_hard_limit
+ The optional swap_hard_limit
element is the maximum
+ swap the guest can use. The units for this value are kilobytes
+ (i.e. blocks of 1024 bytes)
+ min_guarantee
+ The optional min_guarantee
element is the guaranteed
+ minimum memory allocation for the guest. The units for this value are
+ kilobytes (i.e. blocks of 1024 bytes)
vcpu
The content of this element defines the number of virtual
CPUs allocated for the guest OS, which must be between 1 and
diff --git a/src/libvirt.c b/src/libvirt.c
index 28684605dd..629d97b19d 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -3063,9 +3063,23 @@ error:
* Get the memory parameters, the @params array will be filled with the values
* equal to the number of parameters suggested by @nparams
*
- * As a special case, if @nparams is zero and @params is NULL, the API will
- * set the number of parameters supported by the HV in @nparams and return
- * SUCCESS.
+ * As the value of @nparams is dynamic, call the API setting @nparams to 0 and
+ * @params as NULL, the API returns the number of parameters supported by the
+ * HV by updating @nparams on SUCCESS. The caller should then allocate @params
+ * array, i.e. (sizeof(@virMemoryParameter) * @nparams) bytes and call the API
+ * again.
+ *
+ * Here is the sample code snippet:
+ *
+ * if ((virDomainGetMemoryParameters(dom, NULL, &nparams, 0) == 0) &&
+ * (nparams != 0)) {
+ * params = vshMalloc(ctl, sizeof(virMemoryParameter) * nparams);
+ * memset(params, 0, sizeof(virMemoryParameter) * nparams);
+ * if (virDomainGetMemoryParameters(dom, params, &nparams, 0)) {
+ * vshError(ctl, "%s", _("Unable to get memory parameters"));
+ * goto error;
+ * }
+ * }
*
* This function requires privileged access to the hypervisor. This function
* expects the caller to allocate the @param
diff --git a/tools/virsh.pod b/tools/virsh.pod
index d662b787ec..199046bc54 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -513,6 +513,14 @@ Change the maximum memory allocation limit in the guest domain. This should
not change the current memory use. The memory limit is specified in
kilobytes.
+=item B I
+
+Displays the domain memory parameters.
+
+=item B I optional I<--hard-limit> B optional I<--soft-limit> B optional I<--swap-hard-limit> B
+
+Allows you to set the domain memory parameters. LXC and QEMU/KVM supports these parameters.
+
=item B I I
Change the number of virtual CPUs active in the guest domain. Note that