Skip to content

Commit

Permalink
libxl: setup shadow memory according to max hotplug memory
Browse files Browse the repository at this point in the history
The '<maxMemory>' domain XML element is about maximum memory to be hot
plugged. Make libxl support this for calculating shadow memory amount,
which is used by Xen for internal accounting of domain memory (among
other things). If shadow memory is calculated based on initial memory,
then the domain can hotplug up to about twice that memory, but not more
(it silently doesn't get more).

QubesOS/qubes-issues#7956
  • Loading branch information
marmarek committed Aug 6, 2023
1 parent 94aa6aa commit 62c5c57
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
55 changes: 55 additions & 0 deletions 0022-libxl-setup-shadow-memory-according-to-max-hotplug-m.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
From 3a9226aa90cd9d3e7da4bb2e1de7bc72dab087a9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
<[email protected]>
Date: Sat, 5 Aug 2023 22:53:39 +0200
Subject: [PATCH] libxl: setup shadow memory according to max hotplug memory
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The '<maxMemory>' domain XML element is about maximum memory to be hot
plugged. Make libxl support this for calculating shadow memory amount,
which is used by Xen for internal accounting of domain memory (among
other things). If shadow memory is calculated based on initial memory,
then the domain can hotplug up to about twice that memory, but not more
(it silently doesn't get more).

The 'slots' attribute of the '<maxMemory>' element is ignored.

Signed-off-by: Marek Marczykowski-Górecki <[email protected]>
---
src/libxl/libxl_conf.c | 5 +++--
src/libxl/libxl_domain.c | 1 +
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index fd57ebf79b..f89f2dd978 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -874,8 +874,9 @@ libxlMakeDomBuildInfo(virDomainDef *def,

/* Allow libxl to calculate shadow memory requirements */
b_info->shadow_memkb =
- libxl_get_required_shadow_memory(b_info->max_memkb,
- b_info->max_vcpus);
+ libxl_get_required_shadow_memory(
+ def->mem.max_memory ? : b_info->max_memkb,
+ b_info->max_vcpus);

if (def->namespaceData) {
libxlDomainXmlNsDef *nsdata = def->namespaceData;
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 8620efc4f0..6c2313fdf8 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -325,6 +325,7 @@ virDomainDefParserConfig libxlDomainDefParserConfig = {

.features = VIR_DOMAIN_DEF_FEATURE_USER_ALIAS |
VIR_DOMAIN_DEF_FEATURE_FW_AUTOSELECT |
+ VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG |
VIR_DOMAIN_DEF_FEATURE_NET_MODEL_STRING,
};

--
2.41.0

1 change: 1 addition & 0 deletions libvirt.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ Patch0018: 0018-Revert-meson-Replace-meson.build_root-with-meson.pro.patch
Patch0019: 0019-Revert-meson-Bump-minimal-required-meson-version.patch
Patch0020: 0020-libxl-adjust-ich6-sound-card-name.patch
Patch0021: 0021-libxl-set-net-disk-trusted-parameter-based-on-backen.patch
Patch0022: 0022-libxl-setup-shadow-memory-according-to-max-hotplug-m.patch

Requires: libvirt-daemon = %{epoch}:%{version}-%{release}
%if %{with_network}
Expand Down

0 comments on commit 62c5c57

Please sign in to comment.