tools/libs/light: update xenstore entry when setting max domain memory
authorJuergen Gross <jgross@suse.com>
Fri, 20 May 2022 10:18:50 +0000 (12:18 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 20 May 2022 10:18:50 +0000 (12:18 +0200)
libxl_domain_setmaxmem() called during "xl mem-max" should update the
domain's memory/static-max Xenstore node, as otherwise "xl mem-set"
won't be able to set the memory size to the new maximum.

Adjust the related comments and documentation accordingly.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
docs/man/xl.1.pod.in
tools/libs/light/libxl_mem.c

index e2176bd696cbb6246015cbc2832fb85b4ac8986b..101e14241d1c043e157d2000da207f7294c7c3c8 100644 (file)
@@ -442,15 +442,14 @@ allocate.
 The default unit is kiB.  Add 't' for TiB, 'g' for GiB, 'm' for
 MiB, 'k' for kiB, and 'b' for bytes (e.g., `2048m` for 2048 MiB).
 
-NB that users normally shouldn't need this command; B<xl mem-set> will
-set this as appropriate automatically.
-
 I<mem> can't be set lower than the current memory target for
 I<domain-id>.  It is allowed to be higher than the configured maximum
 memory size of the domain (B<maxmem> parameter in the domain's
-configuration). Note however that the initial B<maxmem> value is still
-used as an upper limit for B<xl mem-set>.  Also note that calling B<xl
-mem-set> will reset this value.
+configuration).
+
+Setting the maximum memory size above the configured maximum memory size
+will require special guest support (memory hotplug) in order to be usable
+by the guest.
 
 The domain will not receive any signal regarding the changed memory
 limit.
index c739d00f390c4776cd41df19c1ef7fa619f532f4..92ec09f4cfa9e84cf9612a920f24608c9a142448 100644 (file)
@@ -20,8 +20,7 @@
 /*
  * Set the maximum memory size of the domain in the hypervisor. There is no
  * change of the current memory size involved. The specified memory size can
- * even be above the configured maxmem size of the domain, but the related
- * Xenstore entry memory/static-max isn't modified!
+ * even be above the configured maxmem size of the domain.
  */
 int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint64_t max_memkb)
 {
@@ -82,6 +81,15 @@ int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint64_t max_memkb)
         goto out;
     }
 
+    rc = libxl__xs_printf(gc, XBT_NULL,
+                          GCSPRINTF("%s/memory/static-max", dompath),
+                          "%"PRIu64, max_memkb);
+    if (rc != 0) {
+        LOGED(ERROR, domid, "Couldn't set %s/memory/static-max, rc=%d\n",
+              dompath, rc);
+        goto out;
+    }
+
     rc = 0;
 out:
     libxl_domain_config_dispose(&d_config);