[PATCH qemu-server 1/1] QemuServer.pm: add support for storing VM memory in /dev/shm
Drew Green
agreenbhm at gmail.com
Wed Nov 19 22:50:03 CET 2025
PVE supports the VM option "ivshmem" which creates a memory-backed file on
the host operating system in /dev/shm to allow sharing resources between
the guest and host and other guests. There is currently no support for
utilizing the Qemu feature to make the guest's system memory available via
the filesystem, which can be useful for experimentation and testing
purposes. This patch adds an additional boolean option to the existing
"ivshmem" configuration called "ram", which when set to 1 will store the
guest's memory in the same location in /dev/shm that "ivshmem" normally
would. Additional logic is added to support that option, such as adding an
additional "-machine" argument required for this and excluding the
"-device" argument normally required for traditional "ivshmem".
--- PVE/QemuServer.pm 2025-11-19 21:33:15.962832901 +0000
+++ PVE/QemuServer.pm 2025-11-19 21:36:40.390068876 +0000
@@ -199,6 +199,13 @@
description =>
"The name of the file. Will be prefixed with 'pve-shm-'.
Default is the VMID. Will be deleted when the VM is stopped.",
},
+ ram => {
+ type => 'boolean',
+ optional => 1,
+ default => 0,
+ description =>
+ "Whether to use Inter-VM Shared Memory as backing for VM's RAM.",
+ },
};
my $audio_fmt = {
@@ -3711,17 +3718,21 @@
if ($conf->{ivshmem}) {
my $ivshmem = parse_property_string($ivshmem_fmt,
$conf->{ivshmem});
- my $bus;
- if ($q35) {
- $bus = print_pcie_addr("ivshmem");
+ if (!$ivshmem->{ram}) {
+ my $bus;
+ if ($q35) {
+ $bus = print_pcie_addr("ivshmem");
+ } else {
+ $bus = print_pci_addr("ivshmem", $bridges, $arch);
+ }
+ push @$devices, '-device', "ivshmem-plain,memdev=ivshmem$bus,";
} else {
- $bus = print_pci_addr("ivshmem", $bridges, $arch);
- }
+ push @$machineFlags, 'memory-backend=ivshmem';
+ }
my $ivshmem_name = $ivshmem->{name} // $vmid;
my $path = '/dev/shm/pve-shm-' . $ivshmem_name;
- push @$devices, '-device', "ivshmem-plain,memdev=ivshmem$bus,";
push @$devices, '-object',
"memory-backend-file,id=ivshmem,share=on,mem-path=$path" .
",size=$ivshmem->{size}M";
}
--
Drew Green
www.drewgreen.net
PGP: 17BDDD7E
<https://pgp.mit.edu/pks/lookup?op=get&search=0x37F838ED17BDDD7E>
More information about the pve-devel
mailing list