public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server v3 6/8] snapshot: introduce running-nets-host-mtu property
Date: Thu,  4 Sep 2025 14:40:50 +0200	[thread overview]
Message-ID: <20250904124113.81772-7-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250904124113.81772-1-f.ebner@proxmox.com>

For VirtIO network devices, it is necessary to preserve the values and
presence of the host_mtu setting when restoring a snapshot. See commit
"migration: preserve host_mtu for virtio-net devices" for details.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---

New in v3.

 src/PVE/API2/Qemu.pm           | 1 +
 src/PVE/QemuConfig.pm          | 6 ++++++
 src/PVE/QemuServer.pm          | 9 +++++++++
 src/PVE/QemuServer/RunState.pm | 3 ++-
 4 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm
index 4770fbf8..ec9f31d8 100644
--- a/src/PVE/API2/Qemu.pm
+++ b/src/PVE/API2/Qemu.pm
@@ -2113,6 +2113,7 @@ my $update_vm_api = sub {
             }
             push @delete, 'runningmachine' if $conf->{runningmachine};
             push @delete, 'runningcpu' if $conf->{runningcpu};
+            push @delete, 'running-nets-host-mtu' if $conf->{'running-nets-host-mtu'};
         }
 
         PVE::QemuConfig->check_lock($conf) if !$skiplock;
diff --git a/src/PVE/QemuConfig.pm b/src/PVE/QemuConfig.pm
index 33cac3be..d0844c4c 100644
--- a/src/PVE/QemuConfig.pm
+++ b/src/PVE/QemuConfig.pm
@@ -247,6 +247,8 @@ sub __snapshot_save_vmstate {
         or die "cannot obtain PID for VM $vmid!\n";
     my $runningcpu = PVE::QemuServer::CPUConfig::get_cpu_from_running_vm($pid);
 
+    my $nets_host_mtu = PVE::QemuServer::Network::get_nets_host_mtu($vmid, $conf);
+
     if (!$suspend) {
         $conf = $conf->{snapshots}->{$snapname};
     }
@@ -254,6 +256,7 @@ sub __snapshot_save_vmstate {
     $conf->{vmstate} = $statefile;
     $conf->{runningmachine} = $runningmachine;
     $conf->{runningcpu} = $runningcpu;
+    $conf->{'running-nets-host-mtu'} = $nets_host_mtu;
 
     return $statefile;
 }
@@ -473,6 +476,8 @@ sub __snapshot_rollback_hook {
             # re-initializing its random number generator
             $conf->{vmgenid} = PVE::QemuServer::generate_uuid();
         }
+
+        $data->{'nets-host-mtu'} = delete($conf->{'running-nets-host-mtu'});
     }
 
     return;
@@ -513,6 +518,7 @@ sub __snapshot_rollback_vm_start {
         statefile => $vmstate,
         forcemachine => $data->{forcemachine},
         forcecpu => $data->{forcecpu},
+        'nets-host-mtu' => $data->{'nets-host-mtu'},
     };
     PVE::QemuServer::vm_start($storecfg, $vmid, $params);
 }
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 20e26cd5..e312acb6 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -635,6 +635,15 @@ EODESCR
         pattern => $PVE::QemuServer::CPUConfig::qemu_cmdline_cpu_re,
         format_description => 'QEMU -cpu parameter',
     },
+    'running-nets-host-mtu' => {
+        type => 'string',
+        pattern => 'net\d+=\d+(,net\d+=\d+)*',
+        optional => 1,
+        description =>
+            'List of VirtIO network devices and their effective host_mtu setting. A value of 0'
+            . ' means that the host_mtu parameter is to be avoided for the corresponding device.'
+            . ' This is used internally for snapshots.',
+    },
     machine => get_standard_option('pve-qemu-machine'),
     arch => {
         description => "Virtual processor architecture. Defaults to the host.",
diff --git a/src/PVE/QemuServer/RunState.pm b/src/PVE/QemuServer/RunState.pm
index 05e7fb47..6a5fdbd7 100644
--- a/src/PVE/QemuServer/RunState.pm
+++ b/src/PVE/QemuServer/RunState.pm
@@ -104,7 +104,8 @@ sub vm_suspend {
                         warn $@ if $@;
                         PVE::Storage::deactivate_volumes($storecfg, [$vmstate]);
                         PVE::Storage::vdisk_free($storecfg, $vmstate);
-                        delete $conf->@{qw(vmstate runningmachine runningcpu)};
+                        delete $conf->@{
+                            qw(vmstate runningmachine runningcpu running-nets-host-mtu)};
                         PVE::QemuConfig->write_config($vmid, $conf);
                     };
                     warn $@ if $@;
-- 
2.47.2



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


  parent reply	other threads:[~2025-09-04 12:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-04 12:40 [pve-devel] [PATCH-SERIES qemu-server v3 0/8] virtio-net: fix migration between default/non-default MTUs Fiona Ebner
2025-09-04 12:40 ` [pve-devel] [PATCH qemu-server v3 1/8] virtio-net: fix migration between default/non-default MTUs starting with machine version 10.0+pve1 Fiona Ebner
2025-09-04 12:40 ` [pve-devel] [PATCH qemu-server v3 2/8] api: vm start: introduce nets-host-mtu parameter for migration compat Fiona Ebner
2025-09-04 12:40 ` [pve-devel] [PATCH qemu-server v3 3/8] migration: preserve host_mtu for virtio-net devices Fiona Ebner
2025-09-04 12:40 ` [pve-devel] [PATCH qemu-server v3 4/8] snapshot: save vmstate: avoid using deprecated check_running() function Fiona Ebner
2025-09-04 12:40 ` [pve-devel] [PATCH qemu-server v3 5/8] snapshot: save vmstate: die when PID cannot be obtained Fiona Ebner
2025-09-04 12:40 ` Fiona Ebner [this message]
2025-09-04 12:40 ` [pve-devel] [PATCH qemu-server v3 stable-bookworm 7/8] api: vm start: introduce nets-host-mtu parameter for migration compat Fiona Ebner
2025-09-04 12:40 ` [pve-devel] [PATCH qemu-server v3 stable-bookworm 8/8] migration: preserve host_mtu for virtio-net devices Fiona Ebner
2025-09-04 18:11   ` Thomas Lamprecht
2025-09-05  8:54     ` Fiona Ebner
2025-09-05  9:09       ` Thomas Lamprecht
2025-09-05  9:17         ` Fiona Ebner
2025-09-04 13:06 ` [pve-devel] [PATCH-SERIES qemu-server v3 0/8] virtio-net: fix migration between default/non-default MTUs Fabian Grünbichler
2025-09-04 18:16 ` [pve-devel] applied: " Thomas Lamprecht

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=20250904124113.81772-7-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.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