Commit Graph

33 Commits

Author SHA1 Message Date
Fiona Ebner
2cf203194b memory: hotplug: sort by numerical ID rather than slot when unplugging
While, usually, the slot should match the ID, it's not explicitly
guaranteed and relies on QEMU internals. Using the numerical ID is
more future-proof and more consistent with plugging, where no slot
information (except the maximum limit) is relied upon.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-03-17 14:05:02 +01:00
Alexandre Derumier
d1b25a2267 memory: don't use foreach_reversedimm for unplug
simple use dimm_list() returned by qemu

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-03-16 09:53:53 +01:00
Alexandre Derumier
1e28e8ba92 memory: rename qemu_dimm_list to qemu_memdevices_list
current qemu_dimm_list can return any kind of memory devices.

make it more generic, with an optionnal type device

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-03-16 09:53:53 +01:00
Alexandre Derumier
dafb728cb8 memory: remove calls to parse_hotplug_features
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
[FE: style: avoid overly long lines]
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-02-15 14:34:25 +01:00
Alexandre Derumier
d82ae201ac memory: refactor sockets
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-02-15 14:34:25 +01:00
Alexandre Derumier
2166f6a905 memory: extract some code to their own sub for mocking
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
[FE: style: avoid overly long lines]
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-02-15 14:34:05 +01:00
Alexandre Derumier
39c074fe23 qemu_memory_hotplug: remove unused $opt arg
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-02-03 11:23:47 +01:00
Alexandre Derumier
62b26624c6 memory hot-plug: fix check for maximal memory value
Fixes: 4d3f29e ("memory hotplug patch v10")
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-01-02 13:56:43 +01:00
Thomas Lamprecht
305e9cec5d memory hot plug: round down to nearest even phys-bits for heuristics
Mira found out that 41 phys-bits the limit is pretty much the same as
with 40, as such odd sizes are a bit unexpected anyway lets mask the
LSB and use that as base, that way we're good again.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-17 17:45:59 +01:00
Thomas Lamprecht
33b0d3b7be memory hotplug: rework max memory handling, make phys-bits dependent
QEMU 7.1 introduced some actual checks for the max memory value in
1caab5cf86bd ("i386/pc: bounds check phys-bits against max used GPA")
and while correct it breaks our by-luck working hard coded max mem of
4 TB for cases with smaller phys bit address sizes, like some older
CPUs or most CPU types have per default if not 'host' or 'max'.

QEMU uses 40 bits per default if the CPU isn't set to host or
phys-bits is not set explicitly.

For 40 bit it seems that depending on machine type one has a max
possible mem of: i440 -> 752, q35 -> 722 GiB, but instead of reducing
it to 704 GiB (512+1128+64) in a hard coded way we acutally check for
the bit size that will probably be used and use that to determine the
max memory size useable.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-17 16:54:49 +01:00
Constantin Herold
ae776a6288 fix #3581: pass size via argument for memory-backend-ram qmp call
Signed-off-by: Constantin Herold <proxmox8914@herold.me>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-08-18 10:41:04 +02:00
Thomas Lamprecht
f7d1505b0c tree wide cleanups
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-16 18:03:32 +02:00
Stefan Reiter
746232eeb1 Die on misaligned memory for hotplugging
...instead of booting with an invalid config once and then silently
changing the memory size for consequent VM starts.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Tested-by: Alwin Antreich <a.antreich@proxmox.com>
2020-03-19 18:55:27 +01:00
Stefan Reiter
456bab5445 Disable memory hotplugging for custom NUMA topologies
This cannot work, since we adjust the 'memory' property of the VM config
on hotplugging, but then the user-defined NUMA topology won't match for
the next start attempt.

Check needs to happen here, since it otherwise fails early with "total
memory for NUMA nodes must be equal to vm static memory".

With this change the error message reflects what is actually happening
and doesn't allow VMs with exactly 1GB of RAM either.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Tested-by: Alwin Antreich <a.antreich@proxmox.com>
2020-03-19 18:54:53 +01:00
Stefan Reiter
0a13e08ec2 refactor: create QemuServer::Monitor for high-level QMP access
QMP and monitor helpers are moved from QemuServer.pm.

By using only vm_running_locally instead of check_running, a cyclic
dependency to QemuConfig is avoided. This also means that the $nocheck
parameter serves no more purpose, and has thus been removed along with
vm_mon_cmd_nocheck.

Care has been taken to avoid errors resulting from this, and
occasionally a manual check for a VM's existance inserted on the
callsite.

Methods have been renamed to avoid redundant naming:
* vm_qmp_command -> qmp_cmd
* vm_mon_cmd -> mon_cmd
* vm_human_monitor_command -> hmp_cmd

mon_cmd is exported since it has many users. This patch also changes all
non-package users of vm_qmp_command to use the mon_cmd helper. Includes
mocking for tests.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2019-11-20 16:29:23 +01:00
Thomas Lamprecht
93981fa799 refactor hugepages_size conf
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-29 17:58:53 +01:00
Thomas Lamprecht
71aba4eac3 refactor hugepages_size
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-29 17:49:37 +01:00
Stefan Reiter
062a7ea714 hugepages: fix memory size checking
The codepath for "any" hugepages did not check if memory size was even,
leading to the code below trying to allocate half a hugepage (e.g. VM
with 2049MiB RAM would lead to 1024.5 2kB hugepages).

Also improve error message for systems with only 1GB hugepages enabled.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2019-10-29 16:52:54 +01:00
Stefan Reiter
3d8d2e8dad fix #2402: allow 1GB hugepages if 2MB is unavailable
As reported in bug #2402, a system started with "default_hugepagesz=1G
hugepagesz=1G" does not have a /sys/kernel/mm/hugepages/hugepages-2048kB
directory.

To fix, ignore the missing directory in hugepages_mount (since it might
not be needed anyway), and correctly check if the requested hugepage
size is available in hugepages_size instead.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2019-10-10 15:32:46 +02:00
Aaron Lauterer
a022e3fdab tree-wide trailing whitespace cleanup
Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2019-09-25 16:55:53 +02:00
Wolfgang Bumiller
1d68295172 memory: fix automatic num amapping
when no numaX config options were present we returned the
hash as a list instead of a hash reference...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-02-18 10:45:17 +01:00
Kamil Trzciński
ca0ef6b148 Use nr_hugepages from /proc/cmdline
Currently Proxmox VE always deallocates HugePagesTLB
when starting a new machine and it makes it impossible
to preconfigure kernel /proc/cmdline with persistent allocation.

This change makes deallocation to prefer defaults set by /proc/cmdline,
by parsing the cmdline and respecting hugepages= and hugepagesz=.

Signed-off-by: Kamil Trzciński <ayufan@ayufan.eu>
2019-02-18 10:39:18 +01:00
Alexandre Derumier
f612bd67f2 numaX : use cpus option multiple time if cpulist
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2016-10-10 10:16:37 +02:00
Wolfgang Bumiller
aaff69ad50 memory: hugepages: map numa node IDs to host and guest correctly
foreach_dimm() provides a guest numa node index, when used
in conjunction with the guest-to-host numa node topology
mapping one has to make sure that the correct host-side
indices are used.

This covers situations where the user defines a numaX with
hostnodes=Y with Y != X.

For instance:
  cores: 2
  hotplug: disk,network,cpu,memory
  hugepages: 2
  memory: 2048
  numa: 1
  numa1: memory=512,hostnodes=0,cpus=0-1,policy=bind
  numa2: memory=512,hostnodes=0,cpus=2-3,policy=bind

Both numa IDs 1 and 2 passed by foreach_dimm() have to be
mapped to host node 0.

Note that this also reverses the foreach_reverse_dimm() numa
node numbering as the current code, while walking sizes
backwards, walked the numa IDs inside each size forward,
which makes more sense. (Memory hot-unplug is still working
with this.)
2016-08-03 08:56:30 +02:00
Alexandre Derumier
ac7b70873a hugepages: use hostnodes value as numanode for topology
also disallow more than 1 hostnode value

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2016-08-03 08:56:30 +02:00
Alexandre Derumier
a2a5ffc928 hugepages: check if numa node exist only if hugepages are enabled
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2016-07-29 09:50:53 +02:00
Alexandre Derumier
7023f3ea16 add hugepages option
vm configuration
----------------
hugepages: (any|2|1024)

any: we'll try to allocate 1GB hugepage if possible, if not we use 2MB hugepage
2: we want to use 2MB hugepage
1024: we want to use 1GB hugepage. (memory need to be multiple of 1GB in this case)

optionnal host configuration for 1GB hugepages
----------------------------------------------
1GB hugepages can be allocated at boot if user want it.
hugepages need to be contiguous, so sometime it's not possible to reserve them on the fly

/etc/default/grub : GRUB_CMDLINE_LINUX_DEFAULT="quiet hugepagesz=1G hugepages=x"

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Acked-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2016-06-22 09:11:11 +02:00
Alexandre Derumier
9a1c413f4b fix raise_param_exc in PVE::QemuServer::Memory::memory_unplug v2
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2016-06-08 18:52:01 +02:00
Alexandre Derumier
37dbec899d fix check_running in PVE::QemuServer::Memory::qemu_memory_hotplug
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2016-06-08 12:49:29 +02:00
Alexandre Derumier
0567a4d572 move memory config generation to QemuServer::Memory::config
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2016-05-23 10:04:31 +02:00
Alexandre Derumier
6779f1ac3c move qemu_memory_hotplug && qemu_dimm_list to QemuServer::Memory
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2016-05-23 10:03:40 +02:00
Alexandre Derumier
3f669af25d move foreach_dimm && foreach_reverse_dimm to QemuServer::Memory
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2016-05-23 10:02:29 +02:00
Alexandre Derumier
a0649da28b add QemuServer::Memory
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2016-05-23 10:02:07 +02:00