public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Drew Green via pve-devel <pve-devel@lists.proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Drew Green <agreenbhm@gmail.com>
Subject: [pve-devel] [PATCH qemu-server 1/1] QemuServer.pm: add support for storing VM memory in /dev/shm
Date: Wed, 19 Nov 2025 16:50:03 -0500	[thread overview]
Message-ID: <mailman.1348.1763589054.362.pve-devel@lists.proxmox.com> (raw)

[-- Attachment #1: Type: message/rfc822, Size: 7347 bytes --]

From: Drew Green <agreenbhm@gmail.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH qemu-server 1/1] QemuServer.pm: add support for storing VM memory in /dev/shm
Date: Wed, 19 Nov 2025 16:50:03 -0500
Message-ID: <CANDN8xF4U2-C=RGbJtn6y1i_ojHw0FrSc6y39+Rewha98rh8tg@mail.gmail.com>

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>

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

                 reply	other threads:[~2025-11-19 21:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mailman.1348.1763589054.362.pve-devel@lists.proxmox.com \
    --to=pve-devel@lists.proxmox.com \
    --cc=agreenbhm@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal