All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] tools/libs/light: update xenstore entry when setting max domain memory
@ 2022-04-20  8:04 Juergen Gross
  2022-04-29 14:52 ` Anthony PERARD
  0 siblings, 1 reply; 3+ messages in thread
From: Juergen Gross @ 2022-04-20  8:04 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Wei Liu, Anthony PERARD

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>
---
V2:
- adjust comments and docs (Anthony Perard)
---
 tools/libs/light/libxl_mem.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/libs/light/libxl_mem.c b/tools/libs/light/libxl_mem.c
index c739d00f39..92ec09f4cf 100644
--- a/tools/libs/light/libxl_mem.c
+++ b/tools/libs/light/libxl_mem.c
@@ -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);
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] tools/libs/light: update xenstore entry when setting max domain memory
  2022-04-20  8:04 [PATCH v2] tools/libs/light: update xenstore entry when setting max domain memory Juergen Gross
@ 2022-04-29 14:52 ` Anthony PERARD
  2022-05-02  8:16   ` Juergen Gross
  0 siblings, 1 reply; 3+ messages in thread
From: Anthony PERARD @ 2022-04-29 14:52 UTC (permalink / raw)
  To: Juergen Gross; +Cc: xen-devel, Wei Liu

On Wed, Apr 20, 2022 at 10:04:26AM +0200, Juergen Gross wrote:
> 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.

Setting domain's memory higher than the original mem-max only works on
PV and maybe PVH guest, right? Because on HVM, QEMU is told about
maxmem when starting a guest, and allocates some stuff from this address
(vga buffer, pci rom I think) so trying to give HVM guest more memory
after the fact is probably not going to go smoothly.

> Adjust the related comments and documentation accordingly.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>
> ---
> V2:
> - adjust comments and docs (Anthony Perard)

Maybe `man xl` should be updated as well. In the section about `xl
mem-max`, there is:
    "Note however that the initial maxmem value is still used as an
    upper limit for xl mem-set.  Also note that calling xl mem-set will
    reset this value."

That wouldn't be true anymore with this patch.

Thanks,

-- 
Anthony PERARD


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] tools/libs/light: update xenstore entry when setting max domain memory
  2022-04-29 14:52 ` Anthony PERARD
@ 2022-05-02  8:16   ` Juergen Gross
  0 siblings, 0 replies; 3+ messages in thread
From: Juergen Gross @ 2022-05-02  8:16 UTC (permalink / raw)
  To: Anthony PERARD; +Cc: xen-devel, Wei Liu


[-- Attachment #1.1.1: Type: text/plain, Size: 1479 bytes --]

On 29.04.22 16:52, Anthony PERARD wrote:
> On Wed, Apr 20, 2022 at 10:04:26AM +0200, Juergen Gross wrote:
>> 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.
> 
> Setting domain's memory higher than the original mem-max only works on
> PV and maybe PVH guest, right? Because on HVM, QEMU is told about
> maxmem when starting a guest, and allocates some stuff from this address
> (vga buffer, pci rom I think) so trying to give HVM guest more memory
> after the fact is probably not going to go smoothly.

Works without a problem.

This area is marked in the e820 memory map, so the guest won't use it to
add memory.

> 
>> Adjust the related comments and documentation accordingly.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>> ---
>> V2:
>> - adjust comments and docs (Anthony Perard)
> 
> Maybe `man xl` should be updated as well. In the section about `xl
> mem-max`, there is:
>      "Note however that the initial maxmem value is still used as an
>      upper limit for xl mem-set.  Also note that calling xl mem-set will
>      reset this value."
> 
> That wouldn't be true anymore with this patch.

Weird. I did modify that man page, but obviously didn't check it was
really added to the patch. Sorry for that, will resend the patch with
that change included.


Juergen


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-02  8:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-20  8:04 [PATCH v2] tools/libs/light: update xenstore entry when setting max domain memory Juergen Gross
2022-04-29 14:52 ` Anthony PERARD
2022-05-02  8:16   ` Juergen Gross

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.