mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
hostmem: Wire up RAM_NORESERVE via "reserve" property
Let's provide a way to control the use of RAM_NORESERVE via memory backends using the "reserve" property which defaults to true (old behavior). Only Linux currently supports clearing the flag (and support is checked at runtime, depending on the setting of "/proc/sys/vm/overcommit_memory"). Windows and other POSIX systems will bail out with "reserve=false". The target use case is virtio-mem, which dynamically exposes memory inside a large, sparse memory area to the VM. This essentially allows avoiding to set "/proc/sys/vm/overcommit_memory == 0") when using virtio-mem and also supporting hugetlbfs in the future. As really only Linux implements RAM_NORESERVE right now, let's expose the property only with CONFIG_LINUX. Setting the property to "false" will then only fail in corner cases -- for example on very old kernels or when memory overcommit was completely disabled by the admin. Reviewed-by: Peter Xu <peterx@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Acked-by: Eduardo Habkost <ehabkost@redhat.com> for memory backend and machine core Cc: Markus Armbruster <armbru@redhat.com> Cc: Eric Blake <eblake@redhat.com> Cc: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20210510114328.21835-11-david@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
committed by
Paolo Bonzini
parent
d94e0bc9ef
commit
9181fb7043
@@ -545,6 +545,9 @@
|
||||
# @share: if false, the memory is private to QEMU; if true, it is shared
|
||||
# (default: false)
|
||||
#
|
||||
# @reserve: if true, reserve swap space (or huge pages) if applicable
|
||||
# (default: true) (since 6.1)
|
||||
#
|
||||
# @size: size of the memory region in bytes
|
||||
#
|
||||
# @x-use-canonical-path-for-ramblock-id: if true, the canoncial path is used
|
||||
@@ -556,6 +559,12 @@
|
||||
# false generally, but true for machine
|
||||
# types <= 4.0)
|
||||
#
|
||||
# Note: prealloc=true and reserve=false cannot be set at the same time. With
|
||||
# reserve=true, the behavior depends on the operating system: for example,
|
||||
# Linux will not reserve swap space for shared file mappings --
|
||||
# "not applicable". In contrast, reserve=false will bail out if it cannot
|
||||
# be configured accordingly.
|
||||
#
|
||||
# Since: 2.1
|
||||
##
|
||||
{ 'struct': 'MemoryBackendProperties',
|
||||
@@ -566,6 +575,7 @@
|
||||
'*prealloc': 'bool',
|
||||
'*prealloc-threads': 'uint32',
|
||||
'*share': 'bool',
|
||||
'*reserve': 'bool',
|
||||
'size': 'size',
|
||||
'*x-use-canonical-path-for-ramblock-id': 'bool' } }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user